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

How to obtain the size of a field VARCHAR, NUMERIC(7,2) after a query with libpq?

From: Gilberto Ribeiro de Queiroz <gribeiro(at)dpi(dot)inpe(dot)br>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: How to obtain the size of a field VARCHAR, NUMERIC(7,2) after a query with libpq?
Date: 2001-10-27 20:30:33
Message-ID: 1004214633.3bdb1969d53e5@lagavulin.ltid.inpe.br (view raw or flat)
Thread:
Lists: pgsql-interfaces
I am using the library C of the PostgreSQL "libpq" in some academic projects. I 
am needing to recover the size of the resulting fields of a given 
query so that, if necessary, I create a new table in another database or so that 
my program has this information for posterior use.    
    
Below, it is an example that I want to do    
    
Given the tables:    
T1(C1 VARCHAR(89), C2 NUMERIC(7,2))    
T2(C2 NUMERIC(7,2))    
    
1 - the user executes a consultation like:    
SELECT C1 FROM T1, T2 WHERE T1.C2 = T2.C2 ORDER BY C1    

2 - later he (or she) decides, inside of my program, to export the result for a 
table of another database (like MySQL for example) => Then, I will have to know 
the type (this libpq gives) and the size of each field so that I can create a 
table in MySQL, in the case of this example, I will have to discover that the 
field C1 of the table T1 is a varchar of length "89".

===> How could I get this length ?

Since now i thanks everybody, Gilberto.


Responses

pgsql-interfaces by date

Next:From: Tom LaneDate: 2001-10-28 01:45:48
Subject: Re: How to obtain the size of a field VARCHAR, NUMERIC(7,2) after a query with libpq?
Previous:From: Egidijus KizlaitisDate: 2001-10-27 13:48:49
Subject: problems with libpq on windows

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