Thread: existence of column name

existence of column name

From
Eric Smith
Date:
All,

 From the C API, how do I check for the existence of a column name in
a given table?

Thanks,
Eric


Re: existence of column name

From
John R Pierce
Date:
Eric Smith wrote:
> All,
>
> From the C API, how do I check for the existence of a column name in a
> given table?

    select data_type from information_schema.columns where
table_schema='public' and table_name='given_table' and
column_name='some_column';

that will return the data_type if the column exists, or return zero rows
if it doesn't.



Re: existence of column name

From
Jasen Betts
Date:
On 2009-04-09, Eric Smith <eric_h_smith@mac.com> wrote:
> All,
>
>  From the C API, how do I check for the existence of a column name in
> a given table?

you can look at the information schema, column-names in a result-set,
or error messages.  which is most apropriate depends on the context.



Re: existence of column name

From
Eric Smith
Date:
Tried this out, and got a very familiar error that I don't know what
to do with :  "Error: expected just one rule action".

I'm using 8.3.5, and see this error quite a bit.  Anyone know what's
behind this error?

Thanks,
Eric

On Apr 8, 2009, at 8:54 PM, John R Pierce wrote:

> Eric Smith wrote:
>> All,
>>
>> From the C API, how do I check for the existence of a column name
>> in a given table?
>
>   select data_type from information_schema.columns where
> table_schema='public' and table_name='given_table' and
> column_name='some_column';
>
> that will return the data_type if the column exists, or return zero
> rows if it doesn't.
>
>


Re: existence of column name

From
Tom Lane
Date:
Eric Smith <eric_h_smith@mac.com> writes:
> Tried this out, and got a very familiar error that I don't know what
> to do with :  "Error: expected just one rule action".

Er, tried *what* out?  That's supposed to be a can't-happen case,
so I'd like to see just what you did to trigger it.

            regards, tom lane