Jain wrote :

>Hi,

>   here I want to use a dynamic query(changes depends on condition) for 
>$cursor.

>eg:

>    str VARCHAR(2000);

>     str="select * from tablename"; ( This will change depends on condition)


>    SET $CURSOR = 'TEST';
>    DECLARE :$CURSOR CURSOR FOR SELECT :str ;

>but I am gettin error.

>what to do to use a string (str) to the cursor declaration
>Thanx in advance.

Please try the following :

str VARCHAR(2000);
SET $CURSOR = 'TEST';
str='DECLARE ' || $CURSOR || ' CURSOR FOR ' || 'select * from tablename'; 
EXECUTE str;

Regards,
Thomas

-- 
Thomas Anhaus
SAP DB, SAP Labs Berlin
[EMAIL PROTECTED]
http://www.sapdb.org/
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general


_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general

Reply via email to