Re: Perl DBI and placeheld values

Поиск
Список
Период
Сортировка
От Williams, Travis L, NPONS
Тема Re: Perl DBI and placeheld values
Дата
Msg-id AB815D267EC31A4693CC24D234F8291603799CE1@ACCLUST02EVS1.ugd.att.com
обсуждение исходный текст
Ответ на Perl DBI and placeheld values  ("Nigel J. Andrews" <nandrews@investsystems.co.uk>)
Список pgsql-general
I write it into my script also if I know that the second and 37th value
of an array are always quoted.. or not quoted.. I do that right off of
the bat.  I have a couple of systems that dump the time/date together as
01/28/200300:00:000 (it comes from a wierd system!).. so I always know I
have to changed those values before I push into the db..

Travis

-----Original Message-----
From: Nigel J. Andrews [mailto:nandrews@investsystems.co.uk]
Sent: Wednesday, January 29, 2003 7:17 PM
To: Williams, Travis L, NPONS
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] Perl DBI and placeheld values




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 по дате отправления:

Предыдущее
От: "Mathew Frank"
Дата:
Сообщение: Re: Unsubscribing
Следующее
От: Owen Jacobson
Дата:
Сообщение: Crypt in queries and functions?