pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedplperlu hash problem
3+ messages / 2 participants
[nested] [flat]
* plperlu hash problem
@ 2007-04-23 15:09 Bart Degryse <Bart.Degryse@indicator.be>
0 siblings, 0 replies; 3+ messages in thread
From: Bart Degryse @ 2007-04-23 15:09 UTC (permalink / raw)
To: pgsql-sql
I have a little Perl problem. When I call function dbi_select_test like
SELECT * from dbi_select_test() I get the expected result.
However when I call SELECT * from dbi_select I get an error message
saying "ERROR: error from Perl function: setof-composite-returning Perl
function must call return_next with reference to hash at line 9." My
perl knowledge seems to be too limited to find the solution myself. Can
anyone help me out, please?
CREATE OR REPLACE FUNCTION "public"."dbi_select_test" () RETURNS SETOF
text AS
$body$
use DBI;
my $dbh =
DBI->connect('dbi:Oracle:bmssa;host=firev120-1.indicator.be;sid=mars',
'bmssa', '********')
or die "Couldn't connect to database: " . DBI->errstr;
my $sth = $dbh->prepare('SELECT * FROM address')
or die "Couldn't prepare statement: " . $dbh->errstr;
$sth->execute() or die "Couldn't execute statement: " . $sth->errstr;
while (my $row = $sth->fetchrow_hashref) {
return_next($$row{'ADDRTABLEID'});
}
$sth->finish;
return;
$body$
LANGUAGE 'plperlu' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;
CREATE OR REPLACE FUNCTION "public"."dbi_select" () RETURNS SETOF
"bmssa"."ADDRESS" AS
$body$
use DBI;
my $dbh =
DBI->connect('dbi:Oracle:bmssa;host=firev120-1.indicator.be;sid=mars',
'bmssa', '********')
or die "Couldn't connect to database: " . DBI->errstr;
my $sth = $dbh->prepare('SELECT * FROM address')
or die "Couldn't prepare statement: " . $dbh->errstr;
$sth->execute() or die "Couldn't execute statement: " .
$sth->errstr;
while (my %row = $sth->fetchrow_hashref) {
return_next($row);
}
$sth->finish;
return;
$body$
LANGUAGE 'plperlu' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;
CREATE TABLE "bmssa"."ADDRESS" (
"ADDRTABLEID" TEXT,
"ADDRRECID" TEXT,
"LINENUM" TEXT,
"TYPE" TEXT,
"NAME" TEXT,
"ADDRESS" TEXT,
"PHONE" TEXT,
"TELEFAX" TEXT,
"COUNTRY" TEXT,
"DEL_SWIFTNUMBER" TEXT,
"ZIPCODE" TEXT,
"STATE" TEXT,
"COUNTY" TEXT,
"TELEX" TEXT,
"URL" TEXT,
"PHONELOCAL" TEXT,
"CELLULARPHONE" TEXT,
"EMAIL" TEXT,
"TAXGROUP" TEXT,
"CITY" TEXT,
"STREET" TEXT,
"PAGER" TEXT,
"SMS" TEXT,
"REFZIPCODE" TEXT,
"DATAAREAID" TEXT,
"RECID" TEXT
) WITHOUT OIDS;
^ permalink raw reply [nested|flat] 3+ messages in thread
* plperlu hash problem
@ 2007-04-26 07:07 Bart Degryse <Bart.Degryse@indicator.be>
2007-04-26 09:33 ` Re: plperlu hash problem Richard Huxton <dev@archonet.com>
0 siblings, 1 reply; 3+ messages in thread
From: Bart Degryse @ 2007-04-26 07:07 UTC (permalink / raw)
To: pgsql-sql
I have a little Perl problem. When I call function dbi_select_test like
SELECT * from dbi_select_test() I get the expected result.
However when I call SELECT * from dbi_select I get an error message
saying "ERROR: error from Perl function: setof-composite-returning Perl
function must call return_next with reference to hash at line 9." My
perl knowledge seems to be too limited to find the solution myself. Can
anyone help me out or refer me to a better suited forum? Thanks
CREATE OR REPLACE FUNCTION "public"."dbi_select_test" () RETURNS SETOF
text AS
$body$
use DBI;
my $dbh =
DBI->connect('dbi:Oracle:bmssa;host=firev120-1.indicator.be;sid=mars',
'bmssa', '********')
or die "Couldn't connect to database: " . DBI->errstr;
my $sth = $dbh->prepare('SELECT * FROM address')
or die "Couldn't prepare statement: " . $dbh->errstr;
$sth->execute() or die "Couldn't execute statement: " . $sth->errstr;
while (my $row = $sth->fetchrow_hashref) {
return_next($$row{'ADDRTABLEID'});
}
$sth->finish;
return;
$body$
LANGUAGE 'plperlu' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;
CREATE OR REPLACE FUNCTION "public"."dbi_select" () RETURNS SETOF
"bmssa"."ADDRESS" AS
$body$
use DBI;
my $dbh =
DBI->connect('dbi:Oracle:bmssa;host=firev120-1.indicator.be;sid=mars',
'bmssa', '********')
or die "Couldn't connect to database: " . DBI->errstr;
my $sth = $dbh->prepare('SELECT * FROM address')
or die "Couldn't prepare statement: " . $dbh->errstr;
$sth->execute() or die "Couldn't execute statement: " .
$sth->errstr;
while (my %row = $sth->fetchrow_hashref) {
return_next($row);
}
$sth->finish;
return;
$body$
LANGUAGE 'plperlu' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;
CREATE TABLE "bmssa"."ADDRESS" (
"ADDRTABLEID" TEXT,
"ADDRRECID" TEXT,
"LINENUM" TEXT,
"TYPE" TEXT,
"NAME" TEXT,
"ADDRESS" TEXT,
"PHONE" TEXT,
"TELEFAX" TEXT,
"COUNTRY" TEXT,
"DEL_SWIFTNUMBER" TEXT,
"ZIPCODE" TEXT,
"STATE" TEXT,
"COUNTY" TEXT,
"TELEX" TEXT,
"URL" TEXT,
"PHONELOCAL" TEXT,
"CELLULARPHONE" TEXT,
"EMAIL" TEXT,
"TAXGROUP" TEXT,
"CITY" TEXT,
"STREET" TEXT,
"PAGER" TEXT,
"SMS" TEXT,
"REFZIPCODE" TEXT,
"DATAAREAID" TEXT,
"RECID" TEXT
) WITHOUT OIDS;
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: plperlu hash problem
2007-04-26 07:07 plperlu hash problem Bart Degryse <Bart.Degryse@indicator.be>
@ 2007-04-26 09:33 ` Richard Huxton <dev@archonet.com>
0 siblings, 0 replies; 3+ messages in thread
From: Richard Huxton @ 2007-04-26 09:33 UTC (permalink / raw)
To: Bart Degryse <Bart.Degryse@indicator.be>; +Cc: pgsql-sql
Bart Degryse wrote:
> while (my %row = $sth->fetchrow_hashref) {
Well, that should be $row for a start.
> return_next($row);
> }
--
Richard Huxton
Archonet Ltd
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2007-04-26 09:33 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-04-23 15:09 plperlu hash problem Bart Degryse <Bart.Degryse@indicator.be>
2007-04-26 07:07 plperlu hash problem Bart Degryse <Bart.Degryse@indicator.be>
2007-04-26 09:33 ` Richard Huxton <dev@archonet.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox