Re: [SQL] Getting datatype before SELECT

Поиск
Список
Период
Сортировка
От Bob Smither
Тема Re: [SQL] Getting datatype before SELECT
Дата
Msg-id Pine.LNX.3.96.980929212156.20458A-100000@cci.c-c-i.com
обсуждение исходный текст
Ответ на Getting datatype before SELECT  (Glenn Sullivan <glenn.sullivan@nmr.varian.com>)
Список pgsql-sql
On Tue, 29 Sep 1998, Glenn Sullivan wrote:

:In my C code which communicates with the Postgres database,
:I have the need to determine the datatype of a column, before
:I have done a SELECT command.  I have the name of the column,
:but I cannot seem to figure out how to get the datatype information
:until after I have done a SELECT.  Then I can call  PQfnumber() and
:PQftype() to get the type.  Does anyone know how to do this?

Not at all sure how to do this from C, but from perl I do something like
this:

  $temp = `psql -d databasename -c "\\d tablename"`

The item between the `s is executed and the result returned to the
variable.  $temp now has the full structure of the table and can be parsed
to extract the column names and types.  The double \\ is needed to prevent
perl from thinking that \d is a meta character (I think).

The output of the command between the `s could also be redirected to a
file.

Hope this helps,
======================================================================
Bob Smither, Ph.D.      281-331-2744; fax:-4616      Smither@C-C-I.Com
Windows - making simple things easy, and interesting things impossible
======================================================================


В списке pgsql-sql по дате отправления:

Предыдущее
От: darcy@druid.net (D'Arcy J.M. Cain)
Дата:
Сообщение: Re: [SQL] Getting datatype before SELECT
Следующее
От: James Olin Oden
Дата:
Сообщение: Re: [SQL] Getting datatype before SELECT