RE: Calling a PostgreSQL function via DBI



In that case $dbh->quote() is considered the portable way of inserting quote marks, in that the underlying db driver, which is hidden from your code, determines in what form those quote marks will be constructed, so as to be compatible with your particular database.

If you try 'man DBI' or read one of the other available references, it will make this point clear.

However, using prepare() and bind_param() is even more portable, if you can get it to work for calling predefined functions. Others on this list might have more experience in that area than I do.

In particular, I'm uncomfortable with forms like 1::numeric, etc., where your code contains assumptions about the data types of your columns. If you let DBI control it through its knowledge of the schema, then you don't have to put those assumptions into your code. bind_param() takes care of that for you, so your code can be more maintainable and portable.

-Will

-----Original Message-----
From: Christian Stalp [mailto:christian.stalp@xxxxxx]
Sent: Thursday 23 February 2006 16:32
To: Louis Gonzales
Cc: dbi-users@xxxxxxxx
Subject: Re: Calling a PostgreSQL function via DBI



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 variable needs to be: > '2001-11-11 11:11:11'::timestamp
Is that how it needs to go into your db table?

Thats right, that is the way how the psql-shell accepted it:
SELECT neue_auktion ( 1::numeric, 'robot'::text, 'robot'::text, '1999-01-08
04:05:06'::timestamp, '1999-01-08 04:05:06'::timestamp, 10::numeric,
10::numeric, 1::numeric);

I think that the numeric 'type-cast' are redundant, but I put it in.

Gruss Christian

--
Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko!
Satte Provisionen für GMX Partner: http://www.gmx.net/de/go/partner


- - - - - - - Appended by Scientific-Atlanta, Inc. - - - - - - -
This e-mail and any attachments may contain information which is confidential, proprietary, privileged or otherwise protected by law. The information is solely intended for the named addressee (or a person responsible for delivering it to the addressee). If you are not the intended recipient of this message, you are not authorized to read, print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, please notify the sender immediately by return e-mail and delete it from your computer.

.



Relevant Pages

  • NOT getting "duplicate entry" error with DBI/MySQL
    ... Is this a bug in the DBI? ... FOREIGN KEYREFERENCES rt_prodcategory1 ... database gives me the "duplicate entry" error just as it ...
    (perl.dbi.users)
  • RE: Calling a PostgreSQL function via DBI
    ... Calling a PostgreSQL function via DBI ... However I'm still concerned with why you need the nonportable form of ... So it doesn't has to be portable for other databases. ...
    (perl.dbi.users)
  • Re: adding key to DB object
    ... you are actually calling the STORE() and FETCHmethods of ... > j> the DBD and by DBI, ...
    (perl.dbi.users)
  • Re: adding key to DB object
    ... It may look like a hash, but when you set or query ... you are actually calling the STOREand FETCHmethods of ... j> the DBD and by DBI, ...
    (perl.dbi.users)
  • RE: Calling a PostgreSQL function via DBI
    ... However I'm still concerned with why you need the nonportable form of ??::text etc. ... Calling a PostgreSQL function via DBI ... "Vorbereitung nicht durchfuehrbar!\n"; ...
    (perl.dbi.users)