Received: from candle.pha.pa.us (root@s5-03.ppp.op.net [209.152.195.67]) by hub.org (8.8.8/8.7.5) with ESMTP id OAA13064; Thu, 23 Apr 1998 14:01:31 -0400 (EDT) Received: (from maillist@localhost) by candle.pha.pa.us (8.8.5/8.8.5) id NAA29768; Thu, 23 Apr 1998 13:36:58 -0400 (EDT) From: Bruce Momjian Message-Id: <199804231736.NAA29768@candle.pha.pa.us> Subject: Re: [HACKERS] Re: [INTERFACES] retrieving varchar size To: hannu@trust.ee (Hannu Krosing) Date: Thu, 23 Apr 1998 13:35:43 -0400 (EDT) Cc: hannu@trust.ee, byronn@insightdist.com, pgsql-hackers@postgreSQL.org, pgsql-interfaces@postgreSQL.org In-Reply-To: <353F7A47.3C8D677F@sid.trust.ee> from "Hannu Krosing" at Apr 23, 98 08:28:39 pm X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit > > 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@candle.pha.pa.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)