Connecting Tech Pros Worldwide Forums | Help | Site Map

Create Cursor from prepare statement!!!!

Member
 
Join Date: Feb 2009
Posts: 57
#1: Oct 13 '09
Hi Friends,
I want to create a cursor which will get filled up from a dynamic query. For example:

Expand|Select|Wrap|Line Numbers
  1. SET @sqlQuery := CONCAT('SELECT <field1> FROM <table> WHERE <field2> = <some_value>');
  2. PREPARE stmt FROM @sqlQuery;
Where <some_value> will be decided based on some input value to the procedure.

Can i create a cursor from the above PREPARE statement??

Thanks,
Lauren

Member
 
Join Date: Feb 2009
Posts: 57
#2: Oct 14 '09

re: Create Cursor from prepare statement!!!!


I could be able to do this with the help of "View". I created a view by selecting the required columns from the dynamic query and then created the cursor from the view.

Thanks,
Lauren
Reply