Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re:RE: SQL%ROWCOUNT with update statement

Re:RE: SQL%ROWCOUNT with update statement

From: <dgoulet_at_vicr.com>
Date: Mon, 18 Dec 2000 16:47:59 -0500
Message-Id: <10714.124873@fatcity.com>


Lisa,

    There is one and only one case I've seen where the implicit cursor attribute returned an unexpected value. In this case it was not Oracle's fault, but the developers. What he had was basically the following (shortened for brevity & to save the list some work):

for a in (select <a_pile_of_columns> from <user_defined_table>) loop

    if(a.<some_column> = <a_value>) then

        update <results_table>
      end if;

    if(SQL%ROWCOUNT > 0) then .....
    end if;
end loop

Care to guess what SQL%ROWCOUNT was referring to? It depended on whether or not the update statement fired. Kind of weird, but if you read the PL/SQL manual it's clear.

Dick Goulet

____________________Reply Separator____________________
Subject: RE: SQL%ROWCOUNT with update statement Author: "Bala; Prakash" <prakash.bala_at_cingular.com> Date: 12/18/2000 12:31 PM

Lisa, so far sql%rowcount has returned me the right values.  

Prakash

-----Original Message-----
Sent: Monday, December 18, 2000 2:41 PM
To: Multiple recipients of list ORACLE-L

Hello all,

One of the developers here is having trouble using this cursor attribute. He swears up and down the statement is correct and should be updating rows. I tried to recreate his problem and wasn't able to. Below is an example of the type of code I'm referencing.

Has anyone ever seen the implicit cursor attributes screw up and return wrong values? I don't believe I ever have. Any responses are appreciated.

Thanks

SQL> l
  1 declare
  2 ln_rowcount NUMBER;
  3 ln_dummy DATE;
  4 BEGIN
  5 UPDATE BIN_LIST
  6 SET LAST_MOD_TMSTMP = SYSDATE;
  7 LN_ROWCOUNT := SQL%ROWCOUNT;
  8 DBMS_OUTPUT.PUT_LINE(ln_rowcount);   9 COMMIT;
 10 LN_ROWCOUNT := SQL%ROWCOUNT;
 11 DBMS_OUTPUT.PUT_LINE(ln_rowcount);  12
 13 select sysdate into ln_dummy from dual;  14 LN_ROWCOUNT := SQL%ROWCOUNT;
 15 DBMS_OUTPUT.PUT_LINE(ln_rowcount);  16
 17
 18* END;
SQL> /
3062
3062
1

PL/SQL procedure successfully completed.

SQL> Lisa Rutland Koivu
Oracle Database Administrator
Qode.com
4850 North State Road 7
Suite G104
Fort Lauderdale, FL 33319

V: 954.484.3191, x174 
F: 954.484.2933 
C: 954.658.5849 

http://www.qode.com <http://www.qode.com>

"The information contained herein does not express the opinion or position of Qode.com and cannot be attributed to or made binding upon Qode.com."

--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author: Bala, Prakash
  INET: prakash.bala_at_cingular.com

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: ListGuru_at_fatcity.com (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 Received on Mon Dec 18 2000 - 15:47:59 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US