Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic SQL within cursor DB2

Status
Not open for further replies.
Oct 10, 2003
2,323
US
I'm having some sort of bind problem with the below. Any help/suggestions welcome!
Code:
BEGIN;
DECLARE TS CHAR(128);
        TN CHAR(128);
        CN CHAR(128);
        sql_stmt CHAR(500);

DECLARE TCC_CURSOR CURSOR FOR
    SELECT TABLE_SCHEMA, TABLE_NM, COLUMN_NM
     FROM WRKCIM.TABLE_COLUMN_COUNTS;

OPEN TCC_CURSOR
WHENEVER NOT FOUND
    GO TO CLOSE-TCC_CURSOR

FETCH TCC_CURSOR INTO :TS, :TN, :CN;

SET sql_stmt = 'UPDATE WRKCIM.TABLE_COLUMN_COUNTS SET FREQ = '
SET sql_stmt = sql_stmt || '(select count(*) from '||TRIM(TS)||.TRIM(TN)|| ' );'

PREPARE S2 from sql_stmt;
EXECUTE S2;

CLOSE-TCC_CURSOR.
CLOSE TCC_CURSOR; 

END;

==================================
advanced cognitive capabilities and other marketing buzzwords explained with sarcastic simplicity


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top