SQLCURSOR use a dynamically built SQL statement ?

From: flyershistory <flyershistory_at_hockeymail.com>
Date: 27 Feb 2003 06:58:21 -0800
Message-ID: <d7bdcf6c.0302270658.d126e07_at_posting.google.com>


Using pro*fortran I know you can use a cursor variable in the following way :

EXEC SQL ALLOCATE :cursor;
EXEC SQL EXECUTE
  BEGIN
    OPEN :cursor FOR SELECT empno, ename FROM emp;   END;
END-EXEC;
EXEC SQL FETCH :cursor INTO :numbers, :names;

I also know that you can have a dynamic SQL statement in the following way :

sqlsmt = "SELECT empno, ename FROM emp"
EXEC SQL PREPARE STMT FROM :sqlstmt;
EXEC SQL DECLARE B_CURS CURSOR FOR STMT; EXEC SQL OPEN B_CURS;
EXEC SQL FETCH B_CURS INTO :numbers, :names;

What I need to do is combined those two - have a SQLCURSOR cursor variable that uses a dynamic sql statement. In my case building the "sqlstmt" isn't as simple as the above example - it's a complex procedure (otherwise I would do it the same way as the first example). Does anyone know how I can have a SQLCURSOR variable use a dynamic built SQL statement ?

Thanks,
Peter Received on Thu Feb 27 2003 - 15:58:21 CET

Original text of this message