MySQL Forums
Forum List  »  Newbie

How to 'turn' a string into a variable within a query?
Posted by: Dobra Golonka
Date: August 23, 2005 05:54AM

Hi all

Below is an extract of a query I’m trying to run:

BEGIN

DECLARE v_CrewRoleID TINYINT;
DECLARE v_CrewRoleVariable VARCHAR(30);

DECLARE c_InsertCrew CURSOR FOR
SELECT
CrewRoleID,
CrewRoleVariable
FROM
crew_role;

OPEN c_InsertCrew;
REPEAT
FETCH
c_InsertCrew
INTO
v_CrewRoleID,
v_CrewRoleVariable; /* This contains a string representation of other variables in the script */

IF NOT v_NotFound THEN
CALL sp_InsertCrew(v_IndexNo, v_CrewRoleID, v_CrewRoleVariable); /* v_CrewRoleVariable is passed as a literal string */
END IF;

UNTIL v_NotFound = TRUE
END REPEAT;
CLOSE c_InsertCrew;

END

The CrewRoleVariable field in the crew_role table contains string representations of other variables declared in this procedure.

When I call the Stored Procedure sp_InsertCrew, the input variable is being taken literally, and not as the variable contained within crew_role.CrewRoleVariable. What do I need to do to pass the the contents of this variable, and not the string?

Regards

DG

Options: ReplyQuote


Subject
Written By
Posted
How to 'turn' a string into a variable within a query?
August 23, 2005 05:54AM


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.