Click to See Complete Forum and Search --> : Problem with a parameter in a cursor


Coco
02-24-2003, 07:28 AM
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.

jovery
02-24-2003, 07:59 AM
Change your v_string = line to

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

Coco
02-24-2003, 10:38 AM
Your solution is perfect.
Thanks to it my procedure is now ok.
Thank you very much.