Skip navigation links

MySQL Forums :: Stored Procedures :: Variables in Record Cursor Select Statement?


Advanced Search

Variables in Record Cursor Select Statement?
Posted by: Justin Noel ()
Date: November 03, 2009 01:26PM

Is there any way to use variables in the select statement for a cursor? I can't make it work at all.

Partial Example :
CREATE PROCEDURE `process_call_records`(IN dbName varchar(25), OUT returnCode SMALLINT)
cdr_records:BEGIN

# Main procedure

DECLARE cdr_record_cursor CURSOR FOR

SELECT cdrs_id, called, calling FROM dbName.cdrs limit 50;
# Setup logging
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
#call log_debug('Got exception in update_cdrs_lnp_data');
SET returnCode = -1;
END;

DECLARE CONTINUE HANDLER FOR NOT FOUND SET cdr_last_record = 1;

I want to use the variable dbName in the select statment. However, MySQL errors out with that as there is no database called "dbName". It's not using the variable value, it's using "dbName" literally.

Any suggestions?

Options: ReplyQuote


Subject Views Written By Posted
Variables in Record Cursor Select Statement? 232 Justin Noel 11/03/2009 01:26PM


Sorry, only registered users may post in this forum.