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 > Execute Immediate...problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-27-05, 10:28
pradeepbill pradeepbill is offline
Registered User
 
Join Date: Sep 2005
Posts: 5
Execute Immediate...problem

DECLARE client_cd VARCHAR(40) ;
DECLARE v_client_cd VARCHAR(40) ;

SET client_cd=' 301';

SET newsqlQuery=' SELECT COUNT(CLIENT_CD) INTO'|| v_client_cd ||'FROM PRV.ARTPROA WHERE CLIENT_CD ='|| client_cd ;

EXECUTE IMMEDIATE newsqlQuery ;


when I run the code above it says .........

A database manager error occurred.[IBM][CLI Driver][DB2/NT] SQL0198N The statement string of the PREPARE or EXECUTE IMMEDIATE statement is blank or empty. SQLSTATE=42617

PLEASE HELP
THANKS
PRADEEP
Reply With Quote
  #2 (permalink)  
Old 09-27-05, 10:34
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
The variable v_client_cd was not initialized so after concatenation newsqlQuery is NULL. However, this is the most harmless of your errors.
Reply With Quote
  #3 (permalink)  
Old 09-27-05, 10:57
pradeepbill pradeepbill is offline
Registered User
 
Join Date: Sep 2005
Posts: 5
Re:

n_i,

I debugged and saw newsqlQuery has no statement , now I have the code below and this is the new error...please advice

SET newQ= 'SELECT COUNT(CLIENT_CD) INTO '|| v_client_cd ||' FROM PRV.ARTPROA WHERE CLIENT_CD ='|| '301;' ;
EXECUTE IMMEDIATE newQ ;

A database manager error occurred.[IBM][CLI Driver][DB2/NT] SQL0104N An unexpected token ";" was found following "CLIENT_CD=client_cd". Expected tokens may include: "END-OF-STATEMENT". SQLSTATE=42601
Reply With Quote
  #4 (permalink)  
Old 09-27-05, 11:43
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
I think the error message says it all.
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