existence of column name

Started by Eric Smithabout 17 years ago5 messagesgeneral
Jump to latest
#1Eric 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

#2John R Pierce
pierce@hogranch.com
In reply to: Eric Smith (#1)
Re: existence of column name

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.

#3Jasen Betts
jasen@xnet.co.nz
In reply to: Eric Smith (#1)
Re: existence of column name

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.

#4Eric Smith
eric_h_smith@mac.com
In reply to: John R Pierce (#2)
Re: existence of column name

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:

Show quoted text

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.

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Eric Smith (#4)
Re: existence of column name

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