Thread: rowcount function in postgres???

rowcount function in postgres???

From
Karthikeyan Sundaram
Date:
Hi,
 
   I am using 8.1.0 postgres and trying to write a plpgsql block.  In that I am inserting a row.  I want to check to see if the row has been inserted or not.
 
  In oracle we can say like this
 
   begin
     insert into table_a values (1);
     if sql%rowcount > 0
     then
       dbms.output.put_line('rows inserted');
     else
       dbms.output.put_line('rows not inserted');
    end if;
end;
 
Is there something equal to sql%rowcount in postgres?   Please help.
 
Regards
skarthi
 


It’s tax season, make sure to follow these few simple tips Check it out!

Re: rowcount function in postgres???

From
Michael Fuhr
Date:
On Sat, Apr 07, 2007 at 10:33:19AM -0700, Karthikeyan Sundaram wrote:
> I am using 8.1.0 postgres and trying to write a plpgsql block.

8.1.8 is the latest version in that branch.  Read the Release Notes
for each minor release to see what bug fixes you're missing.

http://www.postgresql.org/docs/8.1/interactive/release.html

> In that I am inserting a row.  I want to check to see if the row
> has been inserted or not.

See "Obtaining the Result Status" and "Trapping Errors" in the
PL/pgSQL documentation.

http://www.postgresql.org/docs/8.1/interactive/plpgsql-statements.html#PLPGSQL-STATEMENTS-DIAGNOSTICS
http://www.postgresql.org/docs/8.1/interactive/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING

-- 
Michael Fuhr


Re: rowcount function in postgres???

From
"Rodrigo De León"
Date:
On 4/7/07, Karthikeyan Sundaram <skarthi98@hotmail.com> wrote:
>
>  Hi,
>
>     I am using 8.1.0 postgres and trying to write a plpgsql block.  In that
> I am inserting a row.  I want to check to see if the row has been inserted
> or not.
>
>    In oracle we can say like this
>
>     begin
>       insert into table_a values (1);
>       if sql%rowcount > 0
>       then
>         dbms.output.put_line('rows inserted');
>       else
>         dbms.output.put_line('rows not inserted');
>      end if;
>  end;
>
>  Is there something equal to sql%rowcount in postgres?   Please help.
>
>  Regards
>  skarthi

Maybe:

http://www.postgresql.org/docs/8.2/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-SQL-ONEROW