Cursor operation, checking return result [message #265469] |
Thu, 06 September 2007 07:03  |
nashrul
Messages: 7 Registered: August 2007 Location: Indonesia
|
Junior Member |
|
|
I have this code snippet below,
CURSOR MCUR_CHECKEXIST(SC IN VARCHAR2, DT IN DATE)
IS
SELECT
BASIC_AMOUNT
FROM
AL_DS_BASIC
WHERE
SALES_CODE= SC
AND
to_char(REPORT_PERIOD,'MMYYYY')= to_char(DT,'MMYYYY');
OPEN MCUR_CHECKEXIST(PI_SALES_CODE, PI_DATE);
IF (MCUR_CHECKEXIST%NOTFOUND) THEN
-- Do something here
END IF;
Can I do the checking (MCUR_CHECKEXIST%NOTFOUND) without doing the fetching operation (the checking statements above still result to boolean TRUE or FALSE) ??
Thanks in advance
|
|
|
|
|
Re: Cursor operation, checking return result [message #265483 is a reply to message #265469] |
Thu, 06 September 2007 07:23  |
 |
Michel Cadot
Messages: 68733 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
You have to fetch to get %found/%notfound attribute set:
SQL> declare cursor c is select * from t;
2 begin
3 open c;
4 if c%notfound then dbms_output.put_line('not found');
5 elsif c%found then dbms_output.put_line('found');
6 else dbms_output.put_line('unknown'); end if;
7 end;
8 /
unknown
PL/SQL procedure successfully completed.
SQL> select count(*) from t;
COUNT(*)
----------
0
1 row selected.
Regards
Michel
|
|
|