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 > Dynamic SQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-11-08, 06:23
usDB2 usDB2 is offline
Registered User
 
Join Date: May 2008
Posts: 39
Dynamic SQL

--=======================================

SET SCOUNT_STMT = 'SELECT COUNT(*) INTO '''|| Char(SCOUNT) || ''' FROM '||SCHEMA_NAME||'.RTBL RTBL,'||SCHEMA_NAME||'.ETL_LINEAGE A
WHERE A.DM_LINEAGE_CREATE_TS = '''|| CAST(RUN_DT AS CHAR(26) ) ||''' AND
A.PROCESS_NM = '''||PROCESS_NAME||'''';

--PREPARE SCOUNT_STMT1 FROM SCOUNT_STMT;
EXECUTE IMMEDIATE SCOUNT_STMT;
SET SOURCE_COUNT = SCOUNT;

Hi

I try to execute the above statement.There are around 12 rows in my table.But I get the below err.
SQL0198N The statement string of the PREPARE or EXECUTE IMMEDIATE statement
is blank or empty. SQLSTATE=42617


Statement processed with ERROR.
Please help
Thanks
Reply With Quote
  #2 (permalink)  
Old 08-11-08, 07:08
umayer umayer is offline
Registered User
 
Join Date: Dec 2005
Posts: 273
correct me if I'm wrong, but

SELECT INTO is not valid for dynamic sql. You have to use a cursor.


by the way:
There are two tables in your query ( RTBL and ETL_LINEAGE ), but there is no join condition.
Reply With Quote
  #3 (permalink)  
Old 08-11-08, 07:14
usDB2 usDB2 is offline
Registered User
 
Join Date: May 2008
Posts: 39
Am passing that as parameter,those records are fecthed from ETL lineage tbl...handled in script.

Can you pls give more idea on handling it cursor(count into)
Reply With Quote
  #4 (permalink)  
Old 08-11-08, 07:47
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
  #5 (permalink)  
Old 08-11-08, 09:32
usDB2 usDB2 is offline
Registered User
 
Join Date: May 2008
Posts: 39
Still am facing same issue after replacing with cursor
Reply With Quote
  #6 (permalink)  
Old 08-11-08, 11:40
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
You should have a look at the final statement that's being generated. Pass it as an OUT parameter back from your stored procedure. Maybe you have a schema name that requires delimiters, maybe something else.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
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