Re: Perl DBI and placeheld values - Mailing list pgsql-general

From Nigel J. Andrews
Subject Re: Perl DBI and placeheld values
Date
Msg-id Pine.LNX.4.21.0301300107390.2839-100000@ponder.fairway2k.co.uk
Whole thread Raw
In response to Re: Perl DBI and placeheld values  ("Williams, Travis L, NPONS" <tlw@att.com>)
List pgsql-general

Thanks for the response. Damn quick as well.

This is exactly what I was meaning about special casing and is the route I'd
finally decided I couldn't avoid.

I have tried to generalise it a bit hoping to be able to catch more expressions
by matching against:

   /cur|now|int|'/

and quoting if it fails. The 'catch-all' in this is probably the single
quote. If it's already got a quote in it then it's unlikely we should be adding
more all around the value. Obviously this is targeted at timestamp types and
will fail miserably should it ever be used to try and use with things like text
columns.


Nigel Andrews


On Wed, 29 Jan 2003, Williams, Travis L, NPONS wrote:

> I construct the ? into a variable before I ever call the prepare.  I go
> through an array and check for things like if the info is all numbers
> then I don't need qoutes.. but if it is numbers and :'s then you'll need
> quotes.. in you situation I would specifically look for
> current_timestamp and make sure it doesn't have quotes.
>
> Travis
>
> -----Original Message-----
> From: Nigel J. Andrews [mailto:nandrews@investsystems.co.uk]
>
> ...
>
> First off this is not really postgresql specific but it is driving me
> nuts.
>
>..
>
> Anyway, back on to the subject. I'm a little stuck and I'm wondering how
> people
> handle the situation where a variable can contain a value _or_ a
> function
> call. For example:
>
> psql> create table mytab ( thetime timestamptz );
>
> perl:
>     $sth = $dbh->prepare('insert into mytab values ( ? )');
>     $sth->execute($thetime);
>
> where $thetime could hold 2003-01-29 13:45:06+00 _or_ current_timestamp.
>
> ...
>
> So just how do others manage this situation without resorting to special
> casing
> everything?


pgsql-general by date:

Previous
From: "Glen Parker"
Date:
Subject: Re: Dropping column silently kills multi-coumn index (was [ODBC] Error when accessing tables with deleted columns)
Next
From: steve
Date:
Subject: Re: unsubscribe