RE: Calling a PostgreSQL function via DBI



Christian Stalp [mailto:christian.stalp@xxxxxx] wrote:
See if this works:

my $sth = $dbh->prepare(<<"EndOfSQL");
SELECT neue_auktion ( ?, ?::text, ?::text,
?::timestamp, ?::timestamp,
?, ?, ? )
EndOfSQL

$sth->execute($cookieValue, $ueberschrift, $beschreibung,
$system_zeit, "2001-11-11 11:11:11",
$startpreis, $startpreis, $kategorie_nummer);

Ronald

I don't know if this is what you mean, or should I put it in exactly as
you
wrote? I tried this:
$arg1 = $cookieValue;
$arg2 = $dbh->quote ( $ueberschrift );
$arg3 = $dbh->quote ( $beschreibung );
$arg4 = $system_zeit;
$arg5 = "2001-11-11 11:11:11";
$arg6 = $startpreis;
$arg7 = $startpreis;
$arg8 = $kategorie_nummer;

$result = $dbh->prepare ( "SELECT neue_auktion ( ?, ?::text, ?::text,
?::timestamp, ?::timestamp, ?, ?, ? ) " ) or die "Vorbereitung nicht
durchfuehrbar!\n";
$result->bind_param ( 1, $arg1 );
$result->bind_param ( 2, $arg2 );
$result->bind_param ( 3, $arg3 );
$result->bind_param ( 4, $arg4 );
$result->bind_param ( 5, $arg5 );
$result->bind_param ( 6, $arg6 );
$result->bind_param ( 7, $arg7 );
$result->bind_param ( 8, $arg8 );
$result->execute() or die "Abfrage nicht ausfuehrbar -suchprofil!
$DBI::errstr\n";
$result->finish();

But its crazy, it has the same result. Still the error-code that the
column
'zeitwert' has ... no, one moment its >startpreis<. We are one step
further!

As I said, *you should not use both quote() and placeholders at the same
time*. When you bind a value to a placeholder, DBI quotes the value for
you.


Try the code exactly as I wrote it (except that you can add in the error
messages and change the variable names, of course).


If that doesn't work, try passing the type to bind_param():

$sth->bind_param($p_num, $bind_value, $bind_type);

You'll have to look at the docs for PostgreSQL to see how to specify the
bind type.


Ronald


.