-
Problem with a parameter in a cursor
I have a problem with a cursor.
I use a like clause with a parameter in my cursor and the cursor doesn't works, no records are retrieved. It is something like this:
CREATE OR REPLACE PROCEDURE My_Proc(p_Param IN VARCHAR2) IS
v_String VARCHAR2(100);
CURSOR c_Cursor IS
SELECT Id_Cod
FROM my_table
WHERE NAME LIKE v_String;
BEGIN
v_String := '''' || p_Param || '%' || '''';
FOR cur_Cursor IN c_Cursor LOOP;
DBMS_OUTPUT.PUT_LINE('id_cod = ' || cur_Cursor.Id_Cod);
END LOOP;
END My_Proc;
The dbms_output show me nothing.
If somebody knows how to do this, please, help me.
Thanks.
-
Change your v_string = line to
Code:
v_String := p_Param || '%';
If you use quotes in the actual column content then just remove the last set of quotes on the v_string definition.
At the moment you searching for something like 'A_Word%' what you should be searching for is A_Word%
Regards
Jim
Oracle Certified Professional
"Build your reputation by helping other people build theirs."
"Sarcasm may be the lowest form of wit but its still funny"
Click HERE to vist my website!
-
Your solution is perfect.
Thanks to it my procedure is now ok.
Thank you very much.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|