> This is a multi-part message in MIME format.
> Content-Type: text/plain; charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
> Hi everybody,
> I'm using Postgresql 7.03 (but I'm going to migrate soon to 7.1) and I have=
> a big doubt about how to work with User defined types in my tables using l=
> ibpq and the documentation does not help at all.
> Anyone have any sample about how to use libpq with PQGetValue or similar to=
> read records which have fields defined as Arrays or User defined types?. =
> I looked for samples in the documentation or in the mailing list but I coul=
> dn't find anything.=20=20=20
> For example, if I define the user-defined type "complex" just like in http:=
> //www.postgresql.org/idocs/index.php?xtypes.html#XTYPES-USERDEFINED and the=
> n I use it in a table, how can I read the field?. Must I use the complex_in=
> (char *str) function passing as a parameter the PQGetValue result associate=
> d to this field number?. I have the same doubt when I define an array fiel=
> By the way, do you know if there is any documentation/sample about libpq ex=
> plaining these more advanced topics which are not fully explained in the ge=
> neral documentation?
> Best regards and thanks in advance,
Basicly, everything returned by PQGetValue is a string representation of the data (ignoring binary cursors for the moment). If you application wants to use an internal representation of the data, you will have to parse/convert the string (eg. strtol() for int2 and int4, strtoll() for int8, etc.). As an example, you can get the source for my PostgreSQL/Python interface (pyPgSQL) which contains code for converting PQgetvalue() results into Python Objects. Currently, the only types that are converted are INT2, INT8, BOOL, date/time types, NUMERIC, MONEY, and arrays of these types. All other types are left as strings. This code may provide some useful examples. In particular, look at pgresult.c and PgSQL.py.
____ | Billy G. Allie | Domain....: Bill(dot)Allie(at)mug(dot)org
| /| | 7436 Hartwell | MSN.......: B_G_Allie(at)email(dot)msn(dot)com
|-/-|----- | Dearborn, MI 48126|
|/ |LLIE | (313) 582-1540 |
pgsql-interfaces by date
|Next:||From: Marc G. Fournier||Date: 2001-08-29 15:00:38|
|Subject: List archives moved and cleaned up ... |
|Previous:||From: Bruce Momjian||Date: 2001-08-28 16:34:16|
|Subject: Re: libpq++ current sources don't compile with older C++ compilers|