Received: from resy5.fzk.de (resy5.fzk.de [141.52.68.8]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f9NCCBP04473 for ; Tue, 23 Oct 2001 08:12:11 -0400 (EDT) (envelope-from ch@rodos.fzk.de) Received: by rodos.fzk.de with ESMTP (8.8.6 (PHNE_17135)/8.7.1) id OAA09851; Tue, 23 Oct 2001 14:13:52 +0200 (METDST) From: Haller Christoph Message-Id: <200110231210.OAA29557@rodos> Subject: Re: pgsql embedded again! To: esgutier@sauce.chillan.ubiobio.cl (Esteban Gutierrez Abarzua) Date: Tue, 23 Oct 2001 14:10:35 METDST Cc: pgsql-sql@postgresql.org In-Reply-To: ; from "Esteban Gutierrez Abarzua" at Oct 23, 101 4:13 am X-Mailer: Elm [revision: 212.4] X-Archive-Number: 200110/311 X-Sequence-Number: 5264 Hi Esteban, Your problem looks familiar to me, and it seems you did not follow my advice. Anyway, here is a C sample program which works. It has nothing to do with wrong types, but with a missing connection, but see for yourself. /* /opt/pgsql/bin/ecpg -o sampleprog01.c sampleprog01.sql the compile command is for HP-UX - you have to adapt it for your machine cc -Aa +w1 -g -I/opt/pgsql/include/ -L/opt/pgsql/lib/ sampleprog01.c -Wl,-a,archive -lecpg -lpq -o sampleprog01 */ #include #include #include #include "libpq-fe.h" exec sql include sqlca; void main() { EXEC SQL BEGIN DECLARE SECTION; char *dbName; VARCHAR tabla[50]; EXEC SQL END DECLARE SECTION; int nrows; dbName = "template1"; EXEC SQL CONNECT TO :dbName ; printf("sqlca.sqlcode = %d \n", sqlca.sqlcode) ; EXEC SQL BEGIN ; EXEC SQL DECLARE T99 CURSOR FOR select relname from pg_class ; EXEC SQL OPEN T99; for(nrows = 0;; nrows++) { EXEC SQL FETCH IN T99 INTO :tabla; if ( sqlca.sqlcode != 0 ) break; printf("%.*s \n", tabla.len, tabla.arr ); } printf("nrows = %d ; sqlca.sqlcode = %d \n", nrows, sqlca.sqlcode) ; EXEC SQL CLOSE T99; EXEC SQL END ; EXEC SQL DISCONNECT ; }