Help: Using variables in the cursor select statement
From: Bart Crider <bcrider_at_io.com>
Date: Thu, 06 May 1999 04:54:26 -0500
Message-ID: <373166D2.24A65846_at_io.com>
I'm having trouble using variables in the cursor select statement of a procedure.
Below is my test code for running it from the command line. My basic problem is getting the code to replace the table attribute in the where clause with the value in the variable searchby. It keeps looking for the table attribute searchby rather than the variable value. I'm relatively new to this so please excuse in glaring errors. You can reply via email.
Date: Thu, 06 May 1999 04:54:26 -0500
Message-ID: <373166D2.24A65846_at_io.com>
I'm having trouble using variables in the cursor select statement of a procedure.
Below is my test code for running it from the command line. My basic problem is getting the code to replace the table attribute in the where clause with the value in the variable searchby. It keeps looking for the table attribute searchby rather than the variable value. I'm relatively new to this so please excuse in glaring errors. You can reply via email.
Thanks,
Bart
bcrider_at_io.com
CREATE OR REPLACE PROCEDURE testsearch (keywrd in varchar2, searchby in varchar2) AS
cursor c_search(keywrd VARCHAR2, searchby VARCHAR2) is
select offering_id, title, author, subject, end_date
from offering
where '"&||searchby||&"' LIKE '%'||keywrd||'%'
order by end_date;
where
BEGIN
for c_result in c_search(keywrd, searchby) loop
DBMS_OUTPUT.PUT_LINE (c_result.offering_id);
end loop;
end;
/
Received on Thu May 06 1999 - 11:54:26 CEST