|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Dyanmic query help
Hi,
I'm having trouble getting this stored procedure to run: CREATE PROCEDURE FOO ( ) LANGUAGE SQL BEGIN DECLARE FED_NAME VARCHAR(20); DECLARE ID INTEGER; DECLARE END_TABLE INT DEFAULT 0; DECLARE STMT CHAR(100); DECLARE C1 CURSOR FOR SELECT REMOTEID, OUT_SERVERNAME||'.SYSVERSIONS' FROM BAR.BLAH WHERE REMOTEID > 1; DECLARE CONTINUE HANDLER FOR NOT FOUND SET END_TABLE = 1; OPEN C1; FETCH C1 INTO ID, FED_NAME; WHILE END_TABLE = 0 DO SET STMT = 'UPDATE NSTANFORD.FOO SET C=(SELECT VERSIONNUMBER FROM ?) WHERE A=?'; PREPARE S1 FROM STMT; EXECUTE S1 USING FED_NAME,ID; FETCH C1 INTO ID, FED_NAME; END WHILE; CLOSE C1; END This is the error message I get "An unexpected token "SELECT VERSIONNUMBER FROM" was found following "STANFORD.FOO SET C=(". Expected tokens may include: "<space>". SQLSTATE=42601" I get this error when I call the stored procedure. Any help would be great. Thanks. |
![]() |
| Viewing: Dev Shed Forums > Databases > DB2 Development > Dyanmic query help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|