Simple question - If I'm trying to build a dynamic query and run it in a PL/SQL Stored Procedure, how do I enclose the variable in single quotes so that it is called correctly?
For example:
I first declare a variable to hold a cursor's column value. I also declare a variable to hold the dynamic query:
vTest VARCHAR(200);
l_cur_string VARCHAR2(128);
After defining my cursor, I loop through it like so:
For entry in c1
LOOP
vTest:= entry.variable;
l_cur_string := 'SELECT ex1, ex2FROM exTable WHERE col1= || vTest;
END LOOP;
Of course, when I print out the dynamic query, it doesn't have the single quotes around vTest
. I've tried adding them, but nothing I do compiles correctly.
Any help for a simple question? Thanks!