I just reviewed the link I sent you and I might not have provided enough
information. That section of the documents discusses explicit cursors but
the is an implicit cursor called SQL which you can use to access the
attributes of the last DML statement you ran.
SQL> create table test (x number);
Table created.
SQL> insert into test values (1);
1 row created.
SQL> commit;
SQL> ed
Wrote file afiedt.buf
1 begin
2 update test set x = x + 1 where x = 0;
3 if sql%rowcount = 0 then
4 dbms_output.put_line('Nothing Found');
5 end if;
6 update test set x = x + 1 where x = 1;
7 if sql%rowcount > 0 then
8 dbms_output.put_line('Updated It');
9 end if;
10* end;
SQL> /
Nothing Found
Updated It
PL/SQL procedure successfully completed.
SQL>
>-----Original Message-----
>From: Thompson, Todd [mailto:[EMAIL PROTECTED]]
>Sent: Thursday, August 09, 2001 3:56 PM
>To: Multiple recipients of list ORACLE-L
>Subject: CODE to trap an update statement in PL*SQL that updates 0 rows
>
>
>Hello everyone.......... I'm trying to trap the case where an
>update in
>PL*SQL updates 0 rows. I've tried using the "returning into"
>clause hoping
>it would put null in the returning field - but it seems to retain the
>previous updates value. Can anyone help??
>
>SQL*Plus: Release 8.1.7.0.0 -
>
>
>drop table test;
>create table test(col1 number);
>insert into test values (1);
>insert into test values (3);
>insert into test values (5);
>insert into test values (7);
>insert into test values (9);
>declare
>v_key pls_integer;
>cursor c is select 1 as key from dual
> union
> select 2 as key from dual
> union
> select 3 as key from dual;
>begin
>for x in c loop
>begin
>v_key:=null;
>Update test set col1=x.key
>where col1=x.key
>returning col1 into v_key;
>---
>--- Put trap code here when 0 rows updated
>--
>dbms_output.put_line('curr'|| x.key||' '|| v_key);
>end;
>end loop;
>end;
>/
>
>
>Table dropped.
>
>
>Table created.
>
>
>1 row created.
>
>
>1 row created.
>
>
>1 row created.
>
>
>1 row created.
>
>
>1 row created.
>
>curr1 1
>curr2 1
>curr3 3
>
>PL/SQL procedure successfully completed.
>
>Todd Thompson
>
>Architecture and Technology Team
>Harris Publishing
>6363 Center Drive, Norfolk VA, 23502
>Email: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
>
>
>begin 600 winmail.dat
>M>)\^(A`5`0:0"``$```````!``$``0>0!@`(````Y`0```````#H``$(@`<`
>M&````$E032Y-:6-R;W-O9G0@36%I;"Y.;W1E`#$(`06``P`.````T0<(``D`
>M$0`V``H`!``^`0$@@`,`#@```-$'"``)`!$`-@`.``0`0@$!"8`!`"$````P
>M.4(Q.#,S-S`Q.$1$-3$Q.4)&1#`P03!#.4%",D$X,@`;!P$$@`$`0````$-/
>M1$4@=&\@=')A<"!A;B!U<&1A=&4@<W1A=&5M96YT("!I;B!03"I344P@=&AA
>M="!U<&1A=&5S(#`@<F]W<P"+%0$-@`0``@````(``@`!`Y`&`'05```T````
>M`P`)60(````>`.F`""`&``````#`````````1@`````XA0```0````$`````
>M`````@%Q``$````6`````<$A'=>&8J?S=HS&$=6/5`!0VFO]&````P#>/Z]O
>M```#`*N`""`&``````#`````````1@````!2A0``?AX``!X`RX`((`8`````
>M`,````````!&`````%2%```!````!````#@N-0`+`-.!""`&``````#`````
>M````1@`````&A0````````,`S(`((`8``````,````````!&``````&%````
>M````"P"F@`@@!@``````P````````$8``````X4````````+`-6`""`&````
>M``#`````````1@`````.A0````````,`J(`((`8``````,````````!&````
>M`!"%`````````P#6@`@@!@``````P````````$8`````$84````````#`-B`
>M""`&``````#`````````1@`````8A0```````!X`H(`((`8``````,``````
>M``!&`````(.%```!````$P```#@W,3`P,S,R,2TP.3`X,C`P,0``"P!1@0L@
>M!@``````P````````$8``````(@````````+`%.!"R`&``````#`````````
>M1@`````%B`````````(!"1`!````/P\``#L/``"33@``3%I&=2"!SL\#``H`
>M<F-P9S$R-8(R`T-H=&UL,0,P/P$#`?<*@`*D`^,"`&-HP0K`<V5T,"`'$P*`
>M_Q`#`%`$5@A5![(1U0Y1`P'=$-<R!@`&PQ'5,P1&$-GY$N]F-!!O$781XPCO
>M"??V.QJ_#C`U&]\;L1'A#&#.8P!0"PD!9#,V$6`+I9480&,!,"`0`BI<#K(%
>M`9!G()`S(#PA1`!/0U194$4@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=J.#DI'WV(``#`"8```````,`-@``````"P`"``$````#`/T_Y`0`
>M`!X`Z(`((`8``````,````````!&`````#>%```!`````0`````````>`'``
>M`0```$````!#3T1%('1O('1R87`@86X@=7!D871E('-T871E;65N="`@:6X@
>M4$PJ4U%,('1H870@=7!D871E<R`P(')O=W,`'@#G@`@@!@``````P```````
>M`$8`````-H4```$````!`````````$``.0#POM?1'2'!`0,`\3\)!```'@`Q
>M0`$````)````5%1(3TU04T\``````P`:0``````>`#!``0````D```!45$A/
>M35!33P`````#`!E```````,`@!#_____"P#R$`$````"`4<``0```#0```!C
>M/553.V$](#MP/4)#2$%24DE34%5".VP]5DE3,#`Q+3`Q,#@P.3(Q-30Q,%HM
>M-S0P-S,``@'Y/P$```!+`````````-RG0,C`0A`:M+D(`"LOX8(!````````
>M`"]//4)#2$%24DE34%5"+T]5/458+T-./5)%0TE0245.5%,O0TX]5%1(3TU0
>M4T\``!X`^#\!````#P```%1H;VUP<V]N+"!4;V1D```>`#A``0````D```!4
>M5$A/35!33P`````"`?L_`0```$L`````````W*=`R,!"$!JTN0@`*R_A@@$`
>M````````+T\]0D-(05)225-054(O3U4]15@O0TX]4D5#25!)14Y44R]#3CU4
>M5$A/35!33P``'@#Z/P$````/````5&AO;7!S;VXL(%1O9&0``!X`.4`!````
>M"0```%142$]-4%-/`````$``!S"(IM#1'2'!`4``"#!,(Y?4'2'!`1X`/0`!
>M`````0`````````>`!T.`0```$````!#3T1%('1O('1R87`@86X@=7!D871E
>M('-T871E;65N="`@:6X@4$PJ4U%,('1H870@=7!D871E<R`P(')O=W,`'@`U
>M$`$```!`````/#)%139!-3`W,D)%0T0T,3$Y0D8X,#!!,$,Y04(R03@R-C0W
>M-$9"0'9I<S`P,2YB8VAA<G)I<W!U8BYC;VT^``L`*0``````"P`C```````#
>M``80;PF@G0,`!Q"Q`P```P`0$``````#`!$0`0```!X`"!`!````90```$A%
>M3$Q/159%4EE/3D5)351264E.1U1/5%)!4%1(14-!4T572$5214%.55!$051%
>M24Y03"I344Q54$1!5$53,%)/5U-)5D544DE%1%5324Y'5$A%(E)%5%523DE.
>M1TE.5$\B0TP``````@%_``$```!`````/#)%139!-3`W,D)%0T0T,3$Y0D8X
>M,#!!,$,Y04(R03@R-C0W-$9"0'9I<S`P,2YB8VAA<G)I<W!U8BYC;VT^`/PR
>`
>end
>--
>Please see the official ORACLE-L FAQ: http://www.orafaq.com
>--
>Author: Thompson, Todd
> INET: [EMAIL PROTECTED]
>
>Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
>San Diego, California -- Public Internet access / Mailing Lists
>--------------------------------------------------------------------
>To REMOVE yourself from this mailing list, send an E-Mail message
>to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
>the message BODY, include a line containing: UNSUB ORACLE-L
>(or the name of mailing list you want to be removed from). You may
>also send the HELP command for other information (like subscribing).
>
------------------------------------------------------------------------------
This e-mail is intended for the use of the addressee(s) only and may contain
privileged, confidential, or proprietary information that is exempt from disclosure
under law. If you have received this message in error, please inform us promptly by
reply e-mail, then delete the e-mail and destroy any printed copy. Thank you.
==============================================================================
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Post, Ethan
INET: [EMAIL PROTECTED]
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
San Diego, California -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).