I’m trying to run SQL in a PL/SQL procedure. If I were to say:
SELECT * FROM myTable WHERE FNAME like 'Joe%' AND dept = 'xyz';
this runs instantly.
if I try putting ‘Joe’ in a variable it takes forever to run, about 3 minutes. Here is some syntax I found for using like with variables.
PROCEDURE myProcedure(firstName IN VARCHAR,
cEmployees OUT cursor_type)
IS
BEGIN
OPEN cEmployees FOR
SELECT * FROM myTable WHERE FNAME like firstName || '%' AND dept = 'xyz';
END myProcedure;
what am I doing wrong? thanks.
I haven’t worked on Oracle for some time.
However, you could avoid this
Instead, set the
firstNamevariable before the above statement.e.g.
firstName = firstName || '%'(pardon the syntax)and then
SELECT * FROM myTable WHERE FNAME like firstName