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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cursor with dynamic SQL

Status
Not open for further replies.
Oct 10, 2003
2,323
US
Although this problem is actually in DB2, cursors and dynamic SQL are quite similar between Oracle and DB2. I'm having some sort of bind problem - any help or suggestions appeciated.
SQL:
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


 
I'm not too familiar with DB2 syntax, but what happens if you change
FETCH TCC_CURSOR INTO :TS, :TN, :CN;
to
FETCH TCC_CURSOR INTO TS, TN, CN;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top