No Data Found in SELECT INTO
693765Feb 25 2010 — edited Feb 25 2010Hi all,
I try to select into a variable in a cursor loop but I get NO DATA FOUND when
the select doesn't return a value.
I want to set the variable to be 0 when the select fails.
I tried to add an exception but I get the following:
ORA-00900: invalid SQL statement
Here is the code I'm trying to execute (The exception is commented):
Line: -----
PROCEDURE MyProc IS
v_op NUMBER;
BEGIN
FOR cursor1 IN (select * from myTable)
LOOP
SELECT operation INTO v_op FROM operationsTable where id=cursor1.ID;
--EXCEPTION*
-- WHEN NO_DATA_FOUND THEN
-- v_op :=0;
--END;*
END LOOP;
END MyProc ;
Line: -----
Does anybody know how to set a variable when the select fails with NO DATA FOUND?
Thanks
dyahav