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: <jgotthelf_at_my-deja.com>
Date: Tue, 22 Aug 2000 13:26:21 GMT
Message-ID: <8ntv18$bhh$1@nnrp1.deja.com>

This won't work from ODBC calls that I can tell though; at the very least, sending "var n number;" via ODBC seems to be rejected as an "Invalid SQL statement".

Also, I haven't yet found a way to get variables sent back via ODBC.

In article <8nkpuu$djt$1_at_nnrp1.deja.com>,   sergey_s_at_my-deja.com wrote:
> 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.
>

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Tue Aug 22 2000 - 08:26:21 CDT

Original text of this message

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