RE: Calling a PostgreSQL function via DBI
- From: rjk-dbi@xxxxxxxxxxx (Ronald J Kimball)
- Date: Thu, 23 Feb 2006 16:44:22 -0500
Christian Stalp [mailto:christian.stalp@xxxxxx] wrote:
yes i seems to be so. I tried it with differnt versions.
Now this is where I stand:
$arg1 = $cookieValue;
$arg2 = $dbh->quote ( $ueberschrift ) . "::text";
$arg3 = $dbh->quote ( $beschreibung ) . "::text";
$arg4 = $dbh->quote ( $system_zeit ) . "::timestamp";
$arg5 = $dbh->quote ( "2001-11-11 11:11:11" ) . "::timestamp";
$arg6 = $startpreis;
$arg7 = $startpreis;
$arg8 = $kategorie_nummer;
$result = $dbh->prepare ( "SELECT neue_auktion ( ?, ?, ?, ?, ?, ?, ?, ? )
"
) 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();
And now I get this error again, that the argument 'startzeit' (english
start-time) is of type timestamp without time zone but the expression has
the type text. "Hint: you should make a typecast", but this is what I'm
doing all the time.
First of all, you should use *either* quote() or placeholders, not both.
Binding a value to a placeholder quotes the value for you automatically.
Second, the typecast is not part of the actual value, so you should not be
including it in the bind value.
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
.
- References:
- Re: Calling a PostgreSQL function via DBI
- From: Christian Stalp
- Re: Calling a PostgreSQL function via DBI
- Prev by Date: Re: Calling a PostgreSQL function via DBI
- Next by Date: RE: Calling a PostgreSQL function via DBI
- Previous by thread: Re: Calling a PostgreSQL function via DBI
- Next by thread: RE: Calling a PostgreSQL function via DBI
- Index(es):