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

ecpg and VARCHAR

From: Dirk Jagdmann <doj(at)cubic(dot)org>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: ecpg and VARCHAR
Date: 2005-07-09 21:26:00
Message-ID: 42D040E8.8060309@cubic.org (view raw or flat)
Thread:
Lists: pgsql-interfaces
Hello developers,

I'd like to get some information on VARCHAR types with ecpg. If I 
declare a VARCHAR without any size information I get a compilation error 
from my gcc 3.4.4:

--- file z.pgc ----
int main()
{
   EXEC SQL BEGIN DECLARE SECTION;
   VARCHAR v;
   EXEC SQL END DECLARE SECTION;
   return 0;
}
-------------------
z.pgc: In function `main':
z.pgc:4: error: size of array `arr' is negative

Now I suppose this negative declaration should have initialized an empty 
array and the generated sql code then allocates the space as needed?

If I declared the VARCHAR with a size everything works fine. However I'd 
like to know if the characters in the array contain a trailing 0 or if I 
have to set this explicitely?

And then I'd like to know which is the preferred way to retrieve "text" 
columns which contain arbitrary length texts with ecpg?

-- 
---> doj / cubic
----> http://cubic.org/~doj
-----> http://llg.cubic.org

Responses

pgsql-interfaces by date

Next:From: Tim JacksonDate: 2005-07-11 21:37:07
Subject: Re: C set return function differences on 8.0?]]
Previous:From: Tom LaneDate: 2005-07-09 02:13:23
Subject: Re: C set return function differences on 8.0?

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