Re: Perl DBI and placeheld values

From: "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk>
To: "Williams, Travis L, NPONS" <tlw(at)att(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Perl DBI and placeheld values
Date: 2003-01-30 01:16:36
Message-ID: Pine.LNX.4.21.0301300107390.2839-100000@ponder.fairway2k.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)investsystems(dot)co(dot)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?

In response to

Browse pgsql-general by date

  From Date Subject
Next Message steve 2003-01-30 01:18:34 Re: unsubscribe
Previous Message Glen Parker 2003-01-30 00:43:09 Re: Dropping column silently kills multi-coumn index (was [ODBC] Error when accessing tables with deleted columns)