pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Datatypes in embedded SQL
2+ messages / 2 participants
[nested] [flat]

* Datatypes in embedded SQL
@ 2001-03-26 18:35 Mic <Mic.c@sloten.demon.nl>
  2001-03-28 06:51 ` Re: Datatypes in embedded SQL Michael Meskes <meskes@postgresql.org>
  0 siblings, 1 reply; 2+ messages in thread

From: Mic @ 2001-03-26 18:35 UTC (permalink / raw)
  To: pgsql-interfaces

Hey all.

I've a question on embedded sql.
Thing is, I'm trying to declare a struct in the embedded SQL part in my C
program, but the preprocessor complains about an 'unknown data type in line
162'. Is it not possible at all in Postgres to declare a structure? I tried
writing out the DBstruct in the SQL DECLARE section, that didn't work
either.
When i don't use the struct, passing 4 variables instead, all goes well.

 I Am using Postgres server 7.0.2, and the pgcl preprocessor, running under
Mandrake Linux.

Regards,
Mic


preveously defined:

typedef struct {
   int  line_nr,
        type;
   char nick[10],
        line[161];
} DBstruct;

/* ------------------------------------------------------DBinsRecord--------
does   : Inserts a line in the db
args   :
return : error code (0 = ok)
 ---------------------------------------------------------------------------
*/
static int DBinsRecord (
   DBstruct *Values
)
{
   EXEC SQL BEGIN DECLARE SECTION;
    DBstruct *pRec = Values;
   EXEC SQL END DECLARE SECTION;

   EXEC SQL
      INSERT INTO channel
      (line_nr
      ,nick
      ,type
      ,line)
      VALUES
      ( :pRec->line_nr
      , :pRec->nick
      , :pRec->type
      , :pRec->line);

   return (sqlca.sqlcode);
}







^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Datatypes in embedded SQL
  2001-03-26 18:35 Datatypes in embedded SQL Mic <Mic.c@sloten.demon.nl>
@ 2001-03-28 06:51 ` Michael Meskes <meskes@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Michael Meskes @ 2001-03-28 06:51 UTC (permalink / raw)
  To: Mic <Mic.c@sloten.demon.nl>; +Cc: pgsql-interfaces

On Mon, Mar 26, 2001 at 08:35:05PM +0200, Mic wrote:
> Thing is, I'm trying to declare a struct in the embedded SQL part in my C
> program, but the preprocessor complains about an 'unknown data type in line
> 162'. Is it not possible at all in Postgres to declare a structure? I tried

Which data type are you using? It is possible to declare a struct inside
the declare section.

> writing out the DBstruct in the SQL DECLARE section, that didn't work
> either.

You have to write it out there or else the statement using the struct won't
work because the preproc never saw the definition.

> typedef struct {
>    int  line_nr,
>         type;
>    char nick[10],
>         line[161];
> } DBstruct;

That won't work. ECPG will not see this part of the code. Did you try the
latest CVS version aka PostgreSQL 7.1?

Michael

-- 
Michael Meskes
Michael@Fam-Meskes.De
Go SF 49ers! Go Rhein Fire!
Use Debian GNU/Linux! Use PostgreSQL!



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2001-03-28 06:51 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-03-26 18:35 Datatypes in embedded SQL Mic <Mic.c@sloten.demon.nl>
2001-03-28 06:51 ` Michael Meskes <meskes@postgresql.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox