Thread: Syntax question

Syntax question

From
Tony Li
Date:
Hi,

I'm trying to write an application to allow a user to edit an arbitrary
table.
How can I determine the type of a particular field and figure out
whether or
not I should be quoting the value?

I found PQftype() and have reviewed pg_type and pg_attribute, but don't
see
a clean way of figuring this out.

Thanks,
Tony


Re: Syntax question

From
David Helgason
Date:
(forgot to reply on-list the first time around)

On 7. jul 2004, at 02:28, Tony Li wrote:
> On Jul 6, 2004, at 4:51 PM, David Helgason wrote:
>> On 7. jul 2004, at 00:42, Tony Li wrote:
>>> I'm trying to write an application to allow a user to edit an
>>> arbitrary table.
>>> How can I determine the type of a particular field and figure out
>>> whether or
>>> not I should be quoting the value?
>>
>> You can always quote a value (or just usually?) in PostgreSQL, even
>> numbers, so it shouldn't be a problem. The database will throw an
>> error if the value you sent in can't be coerced into the right type,
>> and that error you can forward to your user. I.e.
>>
>>     create table delme (foo integer, bar text);
>>     insert into delme (foo, bar) values ('11', 'fru');
>>
> Thanks, but one of my "requirements" is that the user never has to
> type quotes, so
> I have to figure this out.

I see, but if your app just always adds quotes, you'll be allright. See
my example above.

> Tony

David Helgason,
Over the Edge Entertainment
(makers of the Unity 3d-engine http://otee.dk)