pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedwhat's wrong with my plperl function?
4+ messages / 2 participants
[nested] [flat]
* what's wrong with my plperl function?
@ 2000-12-06 12:01 Bruno Boettcher <bboett@erm1.u-strasbg.fr>
2000-12-06 15:54 ` Re: what's wrong with my plperl function? Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: Bruno Boettcher @ 2000-12-06 12:01 UTC (permalink / raw)
To: pgsql-sql
Hello,
i am still at the same stage.... thanks to Oliver Elphick the plperl
module is working, as a stand alone per program the thing works (sole
difference, i use $toparse = shift; instead of the $toparse = $_[0];
in the sql-function....
here's the thing:
CREATE FUNCTION cleanFromSep(text,text) RETURNS int4
AS '
$toparse = $_[0];
$work = $_[0];
$format = $_[1];
print "first step $work\n";
$work =~s/\.//g;
print "second step $work\n";
$work =~s/\,//g;
print "final step $work\n";
$work *= 100
if($format =~/,\d{2}$/ && !($toparse=~/,\d{2}$/));
print "eventual mult step $work\n";
return $work;
' LANGUAGE 'plperl';
the perl script gives:
./test.pl 1.000.000 999.999.999,99
first step 1.000.000
second step 1000000
final step 1000000
eventual mult step 100000000
and the SQL function:
select cleanFromSep('1.000.000','999.999.999,99');
cleanfromsep
--------------
0
(1 row)
so what am i doing wrong? besides how can i output debug stuff from the
perl script? print manifestingly doesn't work...
--
ciao bboett
==============================================================
bboett@earthling.net
http://inforezo.u-strasbg.fr/~bboett http://erm1.u-strasbg.fr/~bboett
===============================================================
the total amount of intelligence on earth is constant.
human population is growing....
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: what's wrong with my plperl function?
2000-12-06 12:01 what's wrong with my plperl function? Bruno Boettcher <bboett@erm1.u-strasbg.fr>
@ 2000-12-06 15:54 ` Tom Lane <tgl@sss.pgh.pa.us>
2000-12-06 16:52 ` Re: what's wrong with my plperl function? Bruno Boettcher <bboett@erm1.u-strasbg.fr>
0 siblings, 1 reply; 4+ messages in thread
From: Tom Lane @ 2000-12-06 15:54 UTC (permalink / raw)
To: Bruno Boettcher <bboett@erm1.u-strasbg.fr>; +Cc: pgsql-sql
Bruno Boettcher <bboett@erm1.u-strasbg.fr> writes:
> so what am i doing wrong?
I'm confused too...
> besides how can i output debug stuff from the
> perl script? print manifestingly doesn't work...
I don't see why print wouldn't work. Realize however that it will
go to the postmaster's stdout, so you'd better not have started the
postmaster with -S, and you should have redirected the postmaster's
stdout/stderr into a log file someplace.
You might have better luck printing to stderr, BTW ... that should
get flushed to the disk file once per line, whereas Perl might think
it only needs to flush stdout once per block.
Also, it looks like plperl supports elog(NOTICE, "text") and
elog(ERROR, "text"), though I haven't tried 'em.
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: what's wrong with my plperl function?
2000-12-06 12:01 what's wrong with my plperl function? Bruno Boettcher <bboett@erm1.u-strasbg.fr>
2000-12-06 15:54 ` Re: what's wrong with my plperl function? Tom Lane <tgl@sss.pgh.pa.us>
@ 2000-12-06 16:52 ` Bruno Boettcher <bboett@erm1.u-strasbg.fr>
2000-12-06 16:59 ` Re: what's wrong with my plperl function? Bruno Boettcher <bboett@erm1.u-strasbg.fr>
0 siblings, 1 reply; 4+ messages in thread
From: Bruno Boettcher @ 2000-12-06 16:52 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-sql
On Wed, Dec 06, 2000 at 10:54:58AM -0500, Tom Lane wrote:
> I'm confused too...
:D
> I don't see why print wouldn't work. Realize however that it will
> go to the postmaster's stdout, so you'd better not have started the
yep found it in the log....
> Also, it looks like plperl supports elog(NOTICE, "text") and
> elog(ERROR, "text"), though I haven't tried 'em.
that does it!
but another strange thing:
first step 1.000.000
second step
final step
code was
print "first step $work\n";
$work =~s/\.//g;
print "second step $work\n";
$work =~s/\,//g;
print "final step $work\n";
seems the =~ isn't supported..... ? :(
tryed even this:
$_ = $work;
s/\.//g;
$work =$_;
but same.... this is basic perl.... at least i thought so...
--
ciao bboett
==============================================================
bboett@earthling.net
http://inforezo.u-strasbg.fr/~bboett http://erm1.u-strasbg.fr/~bboett
===============================================================
the total amount of intelligence on earth is constant.
human population is growing....
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: what's wrong with my plperl function?
2000-12-06 12:01 what's wrong with my plperl function? Bruno Boettcher <bboett@erm1.u-strasbg.fr>
2000-12-06 15:54 ` Re: what's wrong with my plperl function? Tom Lane <tgl@sss.pgh.pa.us>
2000-12-06 16:52 ` Re: what's wrong with my plperl function? Bruno Boettcher <bboett@erm1.u-strasbg.fr>
@ 2000-12-06 16:59 ` Bruno Boettcher <bboett@erm1.u-strasbg.fr>
0 siblings, 0 replies; 4+ messages in thread
From: Bruno Boettcher @ 2000-12-06 16:59 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-sql
On Wed, Dec 06, 2000 at 05:52:13PM +0100, Bruno Boettcher wrote:
> $work =~s/\.//g;
ehm yeah stupid me... think i even read it somewhere in the docu....
should be $work =~ s/\\.//g;
:(
at least it works now...
--
ciao bboett
==============================================================
bboett@earthling.net
http://inforezo.u-strasbg.fr/~bboett http://erm1.u-strasbg.fr/~bboett
===============================================================
the total amount of intelligence on earth is constant.
human population is growing....
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2000-12-06 16:59 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-12-06 12:01 what's wrong with my plperl function? Bruno Boettcher <bboett@erm1.u-strasbg.fr>
2000-12-06 15:54 ` Tom Lane <tgl@sss.pgh.pa.us>
2000-12-06 16:52 ` Bruno Boettcher <bboett@erm1.u-strasbg.fr>
2000-12-06 16:59 ` Bruno Boettcher <bboett@erm1.u-strasbg.fr>
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