RE: Calling a PostgreSQL function via DBI




Christian Stalp [mailto:christian.stalp@xxxxxx] wrote:

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);

This looks very tricky and cryptic. What does it mean? I mean you should
insert the statement "SELECT neue_auktion ( ?, ?::text, ?::text,
?::timestamp, ?::timestamp, ?, ?, ? )" into any perl-function or what is
the
meaning of "<<"EndOfSQL"" ? Never seen this.


It's just a way of creating a string, called a here-document. It allows me
to format the SQL statement nicely. It's documented in perldata if you want
to know more about it.

Here's another way of doing the same thing:

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

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

Ronald


.



Relevant Pages

  • Re: SINGLE variable question
    ... Doing this with a non-integer number such as a single will be more tricky. ... btLastXNumbers As Byte) As Integer ... Dim lDivider As Long ... I suppose I could set a string variable equal to a Single variable, ...
    (microsoft.public.excel.programming)
  • Re: How to populate struct with struct dynamically?
    ... I would lke to get all 3 entries ... and display it as a string? ... the tricky part is that the first ...
    (comp.soft-sys.matlab)
  • Re: Comparing byte arrays
    ... >> The only tricky bit would be taking ... >> into account that a Read from a stream might not return as much data as ... > the string will have that length but only is not showable. ...
    (microsoft.public.dotnet.general)
  • Re: Replace escapeable characters with escape sequence?
    ... returning a string from a function can be tricky. ... I said it was tricky, ... requires the caller to free the allocated string. ... pre-allocate a buffer and pass a pointer to it, ...
    (comp.lang.c)
  • Re: Trouble with m///g
    ... > For example, the string ... > should yield ... That's actually kind of tricky. ... lookassertions ...
    (perl.beginners)