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

Home -> Community -> Usenet -> c.d.o.server -> Re: HOw many records were affected?

Re: HOw many records were affected?

From: <sergey_s_at_my-deja.com>
Date: Sat, 19 Aug 2000 02:04:22 GMT
Message-ID: <8nkpuu$djt$1@nnrp1.deja.com>

SQL> create table t (i number);

Table created.

SQL> insert into t values (1);

1 row created.

SQL> var n number; <- This creates a global variable n in sqlplus SQL>begin
  2 update t set i=13 where i=1;
  3 :n := sql%rowcount; <- Number of affected rows assigned to n   4 end;
  5 /

PL/SQL procedure successfully completed.

SQL> print n

         N


         1

SQL> So, you need to assign sql%rowcount to a variable of your choice and do it inside a stored proc immediately after the execution of the desired statement.

hth

Sergey

In article <8njova$700$1_at_nnrp1.deja.com>,   jgotthelf_at_my-deja.com wrote:
> Hi,
>
> I'm accessing Oracle via ODBC Passthrough - and after and UPDATE or
> INSERT I need to find out how many records were updated. IN SQL
 Server
> I do:
>
> update table_name set value = 42 where key_field = 11
> select @@rowcount
>
> If the update was successfull, @@rowcount returns a 1, else it returns
> a zero.
>
> How can I accomplish the same in Oracle?
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Fri Aug 18 2000 - 21:04:22 CDT

Original text of this message

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