MySQL Forums
Forum List  »  Oracle

Cursor and Prepared statement
Posted by: Rajarshi Biswas
Date: September 19, 2006 02:32AM

Is it possible to create a query using the prepared statement and use the prepared query in the Cursor, say creating a sql which is taking the table name dynamically as parameter on the procedure.
Do cursor support prepare statements .
If not then what is the alternative .

The code given below fails to compile as the error comes when the cursor is Declared



create procedure test(IN tablename varchar(255), IN columnname varchar(20))
BEGIN
SET @query = CONCAT ('SELECT ',columnname,' FROM ', tablename);
PREPARE stmt from @query;
BEGIN
DECLARE test_cursor CURSOR FOR stmt;
END;
END;
//


Pls suggest if the code has an alternative.

Options: ReplyQuote


Subject
Views
Written By
Posted
Cursor and Prepared statement
25767
September 19, 2006 02:32AM
10480
June 02, 2008 03:56AM
11705
July 21, 2008 06:21PM
24523
September 10, 2008 05:27PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.