Re: [HACKERS] Re: [INTERFACES] retrieving varchar size

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: hannu(at)trust(dot)ee (Hannu Krosing)
Cc: hannu(at)trust(dot)ee, byronn(at)insightdist(dot)com, pgsql-hackers(at)postgreSQL(dot)org, pgsql-interfaces(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Re: [INTERFACES] retrieving varchar size
Date: 1998-04-23 17:35:43
Message-ID: 199804231736.NAA29768@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-interfaces

>
> In the latter case, I would suggest an additional SQL command for open
> cursors,
> or a pseudo table for open cursor where you could do a simple select
> statement:
>
> DECLARE CURSOR FOO_CURSOR FOR SELECT * FROM MYTABLE;
>
> SELECT _FIELD_NAME,_FIELD_TYPE,_FIELD_SIZE FROM
> FOO_CURSOR_INFO_PSEUTOTABLE;

The information you want is in pg_attribute.atttypmod. It is normally
-1, but is set for char() and varchar() fields, and includes the 4-byte
length. See bin/psql/psql.c for a sample of its use.

--
Bruce Momjian | 830 Blythe Avenue
maillist(at)candle(dot)pha(dot)pa(dot)us | Drexel Hill, Pennsylvania 19026
+ If your life is a hard drive, | (610) 353-9879(w)
+ Christ can be your backup. | (610) 853-3000(h)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Hartwig 1998-04-23 19:29:55 Re: [HACKERS] Re: [INTERFACES] retrieving varchar size
Previous Message Hannu Krosing 1998-04-23 17:28:39 Re: [HACKERS] Re: [INTERFACES] retrieving varchar size

Browse pgsql-interfaces by date

  From Date Subject
Next Message Byron Nikolaidis 1998-04-23 18:23:02 Re: [INTERFACES] ODBC Driver fixes (Borland, etc).
Previous Message Hannu Krosing 1998-04-23 17:28:39 Re: [HACKERS] Re: [INTERFACES] retrieving varchar size