The question is similar to using LIKE in SQL *PLUS, where a select statement contains a LIKE clause as follows:
select * from sometable where somecolumn LIKE 'something%';
How could one use the same within a cursor? I tried using the following:
cursor c is select * from sometable where somecolumn like 'something%';
same as above
EDIT: I need to get something as a parameter, meaning, the select statement is executed within a stored procedure.
EDIT 2:
create procedure proc1 (search VARCHAR) is
cursor c is select student_name from students where student_name like 'search%';
–I know using ‘search%’ retrieves student names containing ‘the key search’, but is there any other way to use such a variable.
do something;
end;
In short, I need to select student names containing a value that is passed as a parameter; this may not be the whole name, and may suffice enough to be used within a like clause.
As per my understanding to your issue, you are using variable
searchwithin quotes. Put your variable outside the quotes, e.g.: