From: | Bosco Rama <postgres(at)boscorama(dot)com> |
---|---|
To: | Leif Jensen <leif(at)crysberg(dot)dk> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: ECPG selecting into char arrays |
Date: | 2011-05-19 21:14:06 |
Message-ID: | 4DD5881E.9020209@boscorama.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Leif Jensen wrote:
>
> With that note in mind, how do I select from a table field of type 'text' ?
If the type is text and you have no idea how long it will be have ecpg/libpq
allocate a buffer for you by using a pointer set to NULL as the variable:
exec sql char *val = NULL;
/* Use an indicator here if you allow the field to be a DB NULL */
exec sql
select text_field into :val
from table
where condition;
/* Check sqlca.sqlcode here */
/* val will now contain the address of an area allocated by ecpg
* holding the contents of the DB field. You can use it and then
* pass val to free() after you're done with it
*/
(do something with val)
/* Clean up */
free(val);
/* Live happily ever after */
HTH
Bosco.
From | Date | Subject | |
---|---|---|---|
Next Message | Merlin Moncure | 2011-05-20 00:07:39 | Re: Unique Session ID in PGSQL? |
Previous Message | egomez@adgsystems.com.do | 2011-05-19 20:45:01 | Unexpected protocol character='j' during authentication.. |