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?
|
Variables in Record Cursor Select Statement? |
232 | Justin Noel |
11/03/2009 01:26PM |
Sorry, only registered users may post in this forum.
© 1995-2008 MySQL AB, 2008- Sun Microsystems, Inc.