do not forget to compile your package code after adding those
debug messages before you run it otherwise we will not
get to see those debug messages.
Main Topics
Browse All TopicsDear Experts,
My problem is as follows,
I have a Package, PKG_SETTLE_POLICY_PROCESS which has several procedures, but the one causing the problem is P_PROCESS_INSTALLMENT
Now this procedure P_PROCESS_INSTALLMENT has severals cursors within it declared and the one ive figured that is cozing the problem is declared as,
CURSOR C_AMF (al_cy NUMBER, al_gl NUMBER, al_cif NUMBER,al_branch_code NUMBER,as_account_type VARCHAR2 , al_process_yn NUMBER) IS
SELECT "AMF"."CURRENCY_CODE" CURRENCY_CODE ,
"AMF"."GL_CODE" GL_CODE ,
"AMF"."CIF_SUB_NO" CIF_SUB_NO
blah
blah
blah....
it is called as follows,
FOR C_AMF_REC IN C_AMF(C_PRIORITY_REC.CY_CO
blah
blah
blah
END LOOP;
Now the problem is,this cursor loops for certain parameters passed to it.. but once it receives a particular set of parameters which coz it to return no rows, it raises an exception of NO DATA FOUND
What i undertand is, if the cursor doesnt return any rows then itll exit from it and loop thru the outer cursor and come back again to C_AMF cursor. Wonder why its throwing an exception.
Any suggestions...
Cheers,
Rosh
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi,
i did try adding debug messages and thats how i reached the conclusion that the exception arrives just before C_AMF...
like i said above, the problem is,this cursor loops for certain parameters passed to it.. but once it receives a particular set of parameters which coz it to return no rows, it raises an exception of NO DATA FOUND
Cheers,
Rosh
Once you get to reproduce the problem in sqlplus you'll solve it easily: Copy/paste the cursor to sqlplus, substitute the binds by the actual parameters that cause it to fail. My bet is that you are calling some plsql function within the SELECT statement, and the function fails with that error when invoked with those parameters.
Since you know that this cursor causes an error when there is no data returned, I would suggest adding some error handling for that situation.
See http://download-uk.oracle.
Obviously, you'll have to decide on a particular action to take when that cursor has no rows, but all you have to do is add
BEGIN
-- Your FOR loop and associated code would go here
EXCEPTION
WHEN NO_DATA_FOUND
-- Exit the procedure, with appropriate values for any OUT arguments.
END;
However, nav_kum_v is correct, and it is not normal for a cursor loop like this to raise an error when no data is found. Ususally, this kind of error is seen when you do a SELECT cols INTO variables... statement.
Hope that helps,
Nick
I'm assuming that the "outer loop" you're referring to is something you haven't shown us here, and that it is in fact something that assigns values to these variables (and possibly others):
- C_PRIORITY_REC.CY_CODE
- C_PRIORITY_REC.GL_CODE
- C_PLAN_REC.COUNTER_PARTY
- C_PRIORITY_REC.ACC_BRANCH
- C_PRIORITY_REC.ACC_TYPE
I believe the assignment of these values is the place where the problem is (you say the exception is raised *before* C_AMF; which I understand means that it happens before the loop cursor is opened).
As has been said, using a cursor-based loop should not raise an exception when used like you're doing. Unless of course the used cursor contains calls to functions which might raise unhandled exceptions, in which case the exception would bubble from the function call into the cursor stopping it's execution and continue it's way upwards in the stack until something (eventually Oracle itself, unless you're providing handling for the exception) catches it.
If this is the case, you should find the function where the exception occurs and handle it there, and provide something that's usefull (ot at least - not lethal) to the cursor in order to continue the loop.
Hi,
i have debug messages before Cursor Loop C_AMF and inside the loop...
i get the debug messages for BOTH before and inside the loop...
BUT FOR A CERTAIN COMBINATION OF PARAMETERS PASSED TO C_AMF, i get NO_DATA_FOUND
When i query the C_AMF cusror SQL with these parameters, i get no records... which means no data found... but as we all know, using a cursor-based loop should not raise an exception.
i do have other procedures being called withing cursor loop C_AMF, but im sure for that combination of parameters Oracle cannot enter the loop, hence no question of those procedures returning an exception...
i cannot paste the entire procedure here... its briefly 5000 lines and wont make too much sense...
anything else i need to look into??
im not yet in the fire fighthing stage,coz this exception hasnt popped up at the clients place... but wanna get armed before that happens...
NickPrice0001:
i did try exception handling before ur post but i got compilation errors, will try again,
where do i put my END LOOP in ur code below???
BEGIN
-- Your FOR loop and associated code would go here
EXCEPTION
WHEN NO_DATA_FOUND
-- Exit the procedure, with appropriate values for any OUT arguments.
END;
thanx for all the posts guys... im sure ill reach a solution soon... keep posting...
Cheers,
Rosh
can you just paste that chunk of code where you have added
a debug message before the loop and inside the loop ? i am not
asking for the whole code to be pasted
How do we infer that cursor loop for certain combination
is raising that...Do you get the debug message which should be your
first line inside the loop before any code gets executed ..
Also add a debug message at the last line of the code inside the loop
and see whether you are getting that...
Thanks
Diaroshan,
You'd put the end loop inside the Begin / Exception block. Here's a trivial example:
DECLARE
CURSOR c_test (al_value NUMBER) IS
SELECT al_value FROM dual WHERE 1 = 0;
BEGIN
DBMS_OUTPUT.PUT_LINE('Befo
FOR c_test_rec IN c_test(5) LOOP
DBMS_OUTPUT.PUT_LINE('In Cursor');
END LOOP;
DBMS_OUTPUT.PUT_LINE('Afte
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('No data found exception');
WHEN OTHERS THEN
RAISE;
END;
However, this trivial example does not cause the NO_DATA_FOUND exception, and as nav_kum_v is saying, it's not possible for this particular error to occur using a cursor like this.
(I thought I'd managed to replicate it, but I can't do it today, so it must have been a mistake)
Business Accounts
Answer for Membership
by: nav_kum_vPosted on 2007-11-03 at 03:13:36ID: 20206414
your cursor in such a case will not throw an exception... There is somewhere a select statement which is throwing that exception..
DE, C_PRIORITY_REC.GL_CODE,C_P LAN_REC.CO UNTER_PART Y,C_PRIORI TY_REC.ACC _BRANCH,C_ PRIORITY_R EC.ACC_TYP E, 1 ) LOOP
paste your full code to help you identify potential select.
It would be nice if you add some debug messages into your package to
see where exactly it is coming out. But set the serveroutput on to get
debug messages.
CURSOR C_AMF (al_cy NUMBER, al_gl NUMBER, al_cif NUMBER,al_branch_code NUMBER,as_account_type VARCHAR2 , al_process_yn NUMBER) IS
SELECT "AMF"."CURRENCY_CODE" CURRENCY_CODE ,
"AMF"."GL_CODE" GL_CODE ,
"AMF"."CIF_SUB_NO" CIF_SUB_NO
blah
blah
blah....
it is called as follows,
dbms_output.put_line('i am before the start of the loop - C_AMF');
FOR C_AMF_REC IN C_AMF(C_PRIORITY_REC.CY_CO
blah
blah -- add some debug messages here as well, so we can get to see
blah -- if some sql is raising that exception...
END LOOP;
dbms_output.put_line('i am after the end of the loop - C_AMF');
SQL>set serveroutput on
SQL>
Thanks