Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-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

pgsql-hackers by date

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

pgsql-interfaces by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group