Re: Calling a PostgreSQL function via DBI



Christian Stalp wrote:

Back to the problem with my plpgsql-procedures. I have another problem with
another procedure, with even more aguments:

$arg1 = $cookieValue . "::numeric";
$arg2 = $ueberschrift . "::text";
$arg3 = $beschreibung . "::text";
$arg4 = $system_zeit . "::timestamp";
$arg5 = "2001-11-11 11:11:11" . "::timestamp";
$arg6 = $startpreis . "::numeric";
$arg7 = $startpreis . "::numeric";
$arg8 = $kategorie_nummer . "::numeric";


$result = $dbh->prepare ( "SELECT neue_auktion ( $arg1, '$arg2', '$arg3',
'$arg4', '$arg5', $arg6, $arg7, $arg8 ) " ) or die "Vorbereitung nicht
durchfuehrbar!\n";
$result->execute() or die "Abfrage nicht ausfuehrbar -suchprofil!
$DBI::errstr\n";
$result->finish();

I know, shouldn't do it with interpolate variables but how ever it should
work. The error-dump I get with this function is:

"Fehler »Syntaxfehler« bei »::« at character 123" which means:
Syntaxerror at >>::<< at character 123

And how I can avoid interpolate variables? Is it simmular to this:
$dbh->do( qq{INSERT INTO kunden ( kid, nachname, vorname, strasse, plz,
email, wohnort, bankid, kontonr) VALUES(?,?,?,?,?,?,?,?,?)},
undef,
$user_nummer,
$nachname,
$vorname,
$strasse,
$plz,
$email,
$wohnort,
$bankid,
$kontonummer
) or die "Kann nicht eintragen kunden\n";

Thank you.

Gruss Christian



Christian,
As an example, I'd do the following:

$arg1 = "$cookieValue" . "::numeric";
....

$result = $dbh->prepare ( "insert into kunden ( kid, nachname, ..., ) values ( ?, ?, ... )" );

$sqls->bind_param(1, $user_nummer);
$sqls->bind_param(2, $nachname);
....

$sqls->execute();
$sqls->finish();

That will take care of your inserting issues. the "bind_param()" function takes care of the variables and puts them in a 'proper' form.


As for your select statement with the $arg1, ..., $argN, the bind_param() function will work on those arguments too, I'd just suggest to use the process of double quoting your string concatenation assignments upfront:

$arg1 = "$someVariable" . "::someText";

Hope this helps.







Relevant Pages

  • Re: I tried to grow a beard
    ... sham of a christian that you are... ... Do you need me to point out for you what Jesus said about lying? ... so you don't care about your little factoid either. ... >>> My identity is available to those who have a right and reason to know ...
    (rec.music.gdead)
  • Re: Michael Moore would be proud...
    ... He's a veteran and has a good HMO (Pacific Care). ... I just don't think you should pay for my bad decisions.. ... Christian," are so lacking in compassion, while I, most definitely *not* ... yet I am much more of a "compassionate Christian" than ...
    (rec.boats)
  • Re: Dont miss Hovind speak at upcoming event!
    ... Upcoming Events ... Our children attended Christian day care. ... they shall take away thy nose and thine ears; ...
    (talk.origins)
  • Re: Dont miss Hovind speak at upcoming event!
    ... Upcoming Events ... Our children attended Christian day care. ... Compare and contrast with Jackson Hole Bible College. ...
    (talk.origins)
  • "Christian" frauds exposed - again.
    ... Bill Moyers did a program where he showed how some christian ... They teach that we should take care of the land and the environment, ... Somehow - though I can't imagine how - these ultra conservatives manage to ... The mixing of right wing republican politics and right wing fanatical ...
    (alt.religion.christian)