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

[INTERFACES] my problems with ecpg and arrays

From: "Coleman, Andrew" <colemana(at)navo(dot)navy(dot)mil>
To: pgsql-interfaces(at)postgreSQL(dot)org
Subject: [INTERFACES] my problems with ecpg and arrays
Date: 1999-11-08 16:39:12
Message-ID: (view raw or whole thread)
Lists: pgsql-interfaces
  I'm having problems loading (insert into ..) a c array into a postgres
I have tried all the variations on syntax I can think of, and searched for
answer... and either didn't find it or didn't recognize it..

SHORT version:
How do I replace {1,2...} with a c array,
exec sql insert into testtab (fname,fid,farr) values

LONG,LONG version:
typos are mine (I have to retype from the system I'm running postgres :( )
I can do this in psql:
create type int2array
create table sampletab2 (id int4, narr int2array);
insert into sampletab2 (id,narr) values (12,'{3,2}');
and everything looks ok with both \d sampletab2 and select * from sampletab2

And this code works great:
#include <stdio.h>
#include <libpq-fe.h>
#include <math.h>

exec sql whenever sqlerror sqlprint;
exec sql include sqlca;

exec sql begin declare section;
  int fid;
  int fidarr[10];
  varchar sqlcom[80];
exec sql end declare section;

  int ii;
  printf("Begin \n");
  for (ii=0;ii<=9;ii++) {fidarr[ii]=ii;printf("fidarr[%d]=%d
  fname.len=sprintf(fname.arr,"doodah day");
  printf("fid equals : %d \n",fid);
  exec sql connect to testdb1;
  exec sql create table testtab (fname varchar(40),fid int, fidarr int[10]);
  exec sql insert into testtab (fname,fid,farr) values
  exec sql commit;
  exec sql disconnect;
  printf ("Done \n");

How do a do something like:
exec sql insert into testtab (fname,fid,farr) values (:fname,:fid,:fidarr);

Thanks (and sorry for the long post)


pgsql-interfaces by date

Next:From: RaviDate: 1999-11-08 19:51:55
Subject: postgre and sqlerror handling
Previous:From: Robert HiltibidalDate: 1999-11-08 15:38:40
Subject: openssl

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