existence of column name

Поиск
Список
Период
Сортировка
Искать

existence of column name

От:
Eric Smith <eric_h_smith@mac.com>
Дата:
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

От:
John R Pierce <pierce@hogranch.com>
Дата:
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

От:
Jasen Betts <jasen@xnet.co.nz>
Дата:
On 2009-04-09, Eric Smith  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

От:
Eric Smith <eric_h_smith@mac.com>
Дата:
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

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Eric Smith  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
FAQ