Yes, The API is changed slightly, which I should have made clear.

The number of rows is reported in a member called 'processed'. If actual data is returned (i.e. from a select), then that data is returned in the 'rows' member (it will be a ref to an array of refs to hash.

Run this sample script (requires plperlu) and you will see what's happening:

create function showme(text) returns text language plperlu as $$
my $query = shift;
my $rv = spi_exec_query($query);
use Data::Dumper;
return Dumper($rv);
$$;
create table tst(i int, v text);
insert into tst values(2,'two');
select showme('select * from tst');
select showme($$insert into tst values(3,'three')$$);
select showme($$create table tst2(q int, r text)$$);
select * from tst;
select showme($$update tst set i = i + 1$$);
select * from tst;


cheers

andrew


elein wrote:

The README said that $rv->{rows} should return the number of
rows affected for INSERT, UPDATE & DELETE.  It seems to return NULL.
@{$rv->{rows}} also returns NULL.


-- drop table users ( email text, who text ); create table users ( email text, who text ); insert into users values ('[EMAIL PROTECTED]', USER);

create or replace function upd_user( text )
returns integer as
'
my $email = $_[0];
my $qry = "update users set email=''".$email."'' where who = USER ; ";
my $rv = spi_exec_query( $qry );
elog NOTICE, $qry;
elog NOTICE, $rv->{status};
elog NOTICE, $rv->{rows};
return $rv->{rows};
' language 'plperl';

select val_user('[EMAIL PROTECTED]');





---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
     subscribe-nomail command to [EMAIL PROTECTED] so that your
     message can get through to the mailing list cleanly

Reply via email to