If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Error in Compilation of SQL Stored Procedure

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-25-04, 18:19
gbag gbag is offline
Registered User
 
Join Date: Dec 2003
Posts: 9
Error in Compilation of SQL Stored Procedure

Hi,
I am trying to create a simple stored procedure. But I am hitting to a starnge problem.

C:\temp>db2 -td@ -vf samp.sql
CREATE PROCEDURE get_count(OUT counter INT)
LANGUAGE SQL
BEGIN
DECLARE SQLSTATE CHAR(5);
DECLARE v_id CHAR(1);
DECLARE v_name VARCHAR(15);
DECLARE v_counter SMALLINT DEFAULT 0;
DECLARE at_end SMALLINT DEFAULT 0;

DECLARE not_found
CONDITION for SQLSTATE '02000';
DECLARE c1 CURSOR FOR
SELECT id, name
FROM stores;
DECLARE CONTINUE HANDLER for not_found
SET at_end = 1;
SET counter = 0;

OPEN c1;
fetch_loop:
LOOP
FETCH c1 INTO
v_id, v_name;
IF at_end <> 0 THEN LEAVE fetch_loop;
END IF;
SET v_counter = v_counter + 1;
END LOOP fetch_loop;
CLOSE c1;
SET counter = v_counter;
END
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0444N Routine "build_sqlroutine" (specific name "SQL040225135440430") is
implemented with code in library or path "\db2udp", function
"build_sqlroutine" which cannot be accessed. Reason code: "4".
SQLSTATE=42724
C:\temp>whereis vcvars32
C:\MicrosoftVisualStudio\VC98\bin/vcvars32.bat



I have included the path for Visual C++ compiler [vcvars32.bat]. Is there anything that I am missing? Can anybody help me in resolving this.
Thanks in advance.
Reply With Quote
  #2 (permalink)  
Old 02-26-04, 07:31
achiola achiola is offline
Registered User
 
Join Date: May 2002
Location: General Deheza, Cba, Arg.
Posts: 273
Re: Error in Compilation of SQL Stored Procedure

hi

do you run the vcvars32.bat?
Reply With Quote
  #3 (permalink)  
Old 02-26-04, 14:13
gbag gbag is offline
Registered User
 
Join Date: Dec 2003
Posts: 9
Re: Error in Compilation of SQL Stored Procedure

Quote:
Originally posted by achiola
hi

do you run the vcvars32.bat?
No. In one of the README documents, it says thatvcvars32 should be in path. Hence I included that in the path. But still I don't know what I am missing.
thanks
Reply With Quote
  #4 (permalink)  
Old 02-26-04, 14:15
achiola achiola is offline
Registered User
 
Join Date: May 2002
Location: General Deheza, Cba, Arg.
Posts: 273
Re: Error in Compilation of SQL Stored Procedure

run this .bat.
this bat make environment varibales, for exp. the path of the C.

and tell me.
Reply With Quote
  #5 (permalink)  
Old 02-26-04, 20:39
gbag gbag is offline
Registered User
 
Join Date: Dec 2003
Posts: 9
Re: Error in Compilation of SQL Stored Procedure

Quote:
Originally posted by achiola
hi

do you run the vcvars32.bat?
No. In one of the README documents, it says thatvcvars32 should be in path. Hence I included that in the path. But still I don't know what I am missing.
thanks
Reply With Quote
  #6 (permalink)  
Old 02-26-04, 20:45
gbag gbag is offline
Registered User
 
Join Date: Dec 2003
Posts: 9
No, the result is same.
C:\temp>vcvars32
Setting environment for using Microsoft Visual C++ tools.
C:\temp>db2 -td@ -vf samp.sql
CREATE PROCEDURE get_count(OUT counter INT)
LANGUAGE SQL
BEGIN
DECLARE SQLSTATE CHAR(5);
DECLARE v_id CHAR(1);
DECLARE v_name VARCHAR(15);
DECLARE v_counter SMALLINT DEFAULT 0;
DECLARE at_end SMALLINT DEFAULT 0;

DECLARE not_found
CONDITION for SQLSTATE '02000';
DECLARE c1 CURSOR FOR
SELECT store_id, name
FROM stores;
DECLARE CONTINUE HANDLER for not_found
SET at_end = 1;

-- initialize OUT parameter
SET counter = 0;

OPEN c1;
fetch_loop:
LOOP
FETCH c1 INTO
v_id, v_name;
IF at_end <> 0 THEN LEAVE fetch_loop;
END IF;
SET v_counter = v_counter + 1;
END LOOP fetch_loop;
CLOSE c1;
SET counter = v_counter;
END
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0444N Routine "build_sqlroutine" (specific name "SQL040226174241540") is
implemented with code in library or path "\db2udp", function
"build_sqlroutine" which cannot be accessed. Reason code: "4".
SQLSTATE=42724

It is complaining against build_routine. Any clues?
Thanks
Reply With Quote
  #7 (permalink)  
Old 02-27-04, 07:07
achiola achiola is offline
Registered User
 
Join Date: May 2002
Location: General Deheza, Cba, Arg.
Posts: 273
ok test this command
C:\temp>db2 -vf samp.sql
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On