ECTED]
Sent: Thursday 23 February 2006 20:42
To: dbi-users@perl.org
Subject: Re: Calling a PostgreSQL function via DBI
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Some minor notes and corrections. First, hopefully the most important
thing to learn from this thread is to always use placeholder
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Some minor notes and corrections. First, hopefully the most important
thing to learn from this thread is to always use placeholders. It just
saves you so much pain and trouble. :)
Louis Gonzales asked:
> Two, you didn't actually put ( $1, $2, ...
> Vielen Glueck mit ihren Aufgabe an der Uni.
>
> -Will
>
8O Who else speaks german on this list ;-) This is really funny. :-)
And this is my university
[url]http://fh-web1.informatik.fh-wiesbaden.de/go.cfm/fb/6/sprachid/2/lpid/0/sid/0.html[/url]
Other question, has anybody experences with PL
Vielen Glueck mit ihren Aufgabe an der Uni.
-Will
-Original Message-
From: Christian Stalp [mailto:[EMAIL PROTECTED]
Sent: Thursday 23 February 2006 18:24
To: Rutherdale, Will
Cc: dbi-users@perl.org
Subject: RE: Calling a PostgreSQL function via DBI
> I'm glad it worked.
>
> I'm glad it worked.
>
> However I'm still concerned with why you need the nonportable form of
> ??::text etc.
>
> Is this because you are running a user defined function which has no
> schema associated with it the way a regular table or view would?
>
> Is there some way to make it more porta
Christian Stalp [mailto:[EMAIL PROTECTED] wrote:
> >
> > my $sth = $dbh->prepare(<<"EndOfSQL");
> > SELECT neue_auktion ( ?, ?::text, ?::text,
> > ?::timestamp, ?::timestamp,
> > ?, ?, ? )
> > EndOfSQL
> >
> > $sth->execute($cookieValue, $uebersch
, i.e. not needing to specify
explicit types for columns?
-Will
-Original Message-
From: Christian Stalp [mailto:[EMAIL PROTECTED]
Sent: Thursday 23 February 2006 17:46
To: dbi-users@perl.org
Subject: RE: Calling a PostgreSQL function via DBI
That the way:
$arg1 = $cookieValue;
$arg2 = $
>
> my $sth = $dbh->prepare(<<"EndOfSQL");
> SELECT neue_auktion ( ?, ?::text, ?::text,
> ?::timestamp, ?::timestamp,
> ?, ?, ? )
> EndOfSQL
>
> $sth->execute($cookieValue, $ueberschrift, $beschreibung,
> $system_zeit, "2001-11-11 1
Christian Stalp wrote:
That the way:
$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 ne
That the way:
$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, ?
Christian Stalp [mailto:[EMAIL PROTECTED] wrote:
> > See if this works:
> >
> > my $sth = $dbh->prepare(<<"EndOfSQL");
> > SELECT neue_auktion ( ?, ?::text, ?::text,
> > ?::timestamp, ?::timestamp,
> > ?, ?, ? )
> > EndOfSQL
> >
> > $sth->execute($c
Christian,
On looking at your output once more, if you're trying to insert a
string, "2001-11-11 11:11:11::timestamp" into a TIMESTAMP datatype, this
won't work.
That's why it's complaining about a typecast... this at least makes
logical sense to me.
You'd have to change the datatype to accept
> See if this works:
>
> my $sth = $dbh->prepare(<<"EndOfSQL");
> SELECT neue_auktion ( ?, ?::text, ?::text,
> ?::timestamp, ?::timestamp,
> ?, ?, ? )
> EndOfSQL
>
> $sth->execute($cookieValue, $ueberschrift, $beschreibung,
> $syste
Christian Stalp wrote:
Bitte kannst du das probieren fuer spass? ( English: Could you just
try this for fun :)
$arg5 = "\'2001-11-11 11:11:11\'" . "::timestamp";
Was werde denn passiert? (what would happen then? )
The same effect,
this is the dump on the website:
Software error:
[
> Bitte kannst du das probieren fuer spass? ( English: Could you just
> try this for fun :)
>
> $arg5 = "\'2001-11-11 11:11:11\'" . "::timestamp";
>
> Was werde denn passiert? (what would happen then? )
The same effect,
this is the dump on the website:
Software error:
[quote]
Abfrage nich
for you, so
your code can be more maintainable and portable.
-Will
-Original Message-
From: Christian Stalp [mailto:[EMAIL PROTECTED]
Sent: Thursday 23 February 2006 16:32
To: Louis Gonzales
Cc: dbi-users@perl.org
Subject: Re: Calling a PostgreSQL function via DBI
> Ja Christian,
Christian Stalp [mailto:[EMAIL PROTECTED] 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_z
> Ja Christian,
> Ich verstehe ein bischen Deutsch, besonders "startzeit" :) Ich habe ein
> buch ueber des Lebens Albert Schweizer gelesen, so ich kann 'basic'
> Duetsch verstehen.
Wow, not bad. And you learned it just with this one book?
>
> From one of the earlier emails I saw, your variab
Thank you Will, I'll opt for discontinuing this discussion with you. I
apologize to the dbi-user community in general.
Sincerely,
> Based on what you have here, this will bind all of the "arg" variables
> with the respective 'positional' "?"s I'd even venture to say, you can
> put a little loop on a single bind_param( $i, $arg$i ); where your:
> i = index counter # haven't tried that yet, but think it would work.
omeText";
Please spare us the rudeness while you're at it and just stick to the
technical issues.
-Will
-Original Message-
From: Louis Gonzales [mailto:[EMAIL PROTECTED]
Sent: Thursday 23 February 2006 15:47
To: Christian Stalp
Cc: dbi-users@perl.org; [EMAIL PROTECTED]
Subject: Re
> Halo Christian,
> $sqls is the object returned by the prepare() method, as in:
>
> my $sqls = $dbh->prepare( "insert into table $table ( userNumber,
> lastName) values ( ?, ?)" );
>
> $sqls->bind_param(1, $user_nummer);
> $sqls->bind_param(2, $nachname);
>
> but, if i understand your last me
ah I see, in my case is it $result:
$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 );
$re
> >
> 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);
> ...
>
> $sq
ot; . "::timestamp";
does not work, because putting quotes around the variable ("$system_zeit") does
*not* produce a string with quote marks in it. This is elementary Perl syntax. And it
is very easy to verify with a test program.
If you want quotes, use $dbh->quote() as I
->quote( $system_zeit ) . "::timestamp";
-Will
-Original Message-
From: Christian Stalp [mailto:[EMAIL PROTECTED]
Sent: Thursday 23 February 2006 15:09
To: dbi-users@perl.org
Subject: Re: Calling a PostgreSQL function via DBI
> Christian,
> As an example, I'
> 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->
ouis Gonzales [mailto:[EMAIL PROTECTED]
Sent: Thursday 23 February 2006 10:28
To: Christian Stalp
Cc: dbi-users@perl.org; [EMAIL PROTECTED]
Subject: Re: Calling a PostgreSQL function via DBI
As for your select statement with the $arg1, ..., $argN, the
bind_param() function will work on those argume
ROTECTED]
Sent: Thursday 23 February 2006 10:28
To: Christian Stalp
Cc: dbi-users@perl.org; [EMAIL PROTECTED]
Subject: Re: Calling a PostgreSQL function via DBI
As for your select statement with the $arg1, ..., $argN, the
bind_param() function will work on those arguments too, I'd just sug
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 = "2
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" . "::t
You should not interpolate variables into the SQL statement, especially
not when you work in a CGI environment (or similar). You are begging for
big trouble. Learn what SQL injection means, and avoid it like hell.
Use:
use $dbh->prepare('SELECT neues_suchprofil (?::numeric,?::text)'); #
single
> Thank you Greg,
> I allready solf it. First I changed the code this way:
> my $arg1 = $cookieValue . "::numeric";
> my $arg2 = $suchprofil_name . "::text";
>
> $result = $dbh->prepare ( "SELECT neues_suchprofil ( $arg1, '$arg2' ) " )
> or
> die "Vorbereitung nicht durchfuehrbar!\n";
> $result-
Thank you Greg,
I allready solf it. First I changed the code this way:
my $arg1 = $cookieValue . "::numeric";
my $arg2 = $suchprofil_name . "::text";
$result = $dbh->prepare ( "SELECT neues_suchprofil ( $arg1, '$arg2' ) " ) or
die "Vorbereitung nicht durchfuehrbar!\n";
$result->execute() or die "
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
> $result = $dbh->prepare ( "SELECT neues_suchprofil ( $cookieValue::numeric,
> '$suchprofil_name::text' ) " ) or die "Vorbereitung nicht durchfuehrbar!\n";
You are mixing up your syntaxes: double-colons in Perl are not the same as
double
colons in
Hello out there,
I just try to call a PostgreSQL-function via the DBI.
The function is very simple:
CREATE OR REPLACE FUNCTION neues_suchprofil ( NUMERIC, TEXT ) RETURNS void
AS $$
BEGIN
INSERT INTO suchprofile ( kid, spname ) VALUES ( $1, $2 );
END
$$ LANGUAGE plpgsql;
It is as you can see ma
36 matches
Mail list logo