From: Haller Christoph <ch@rodos.fzk.de>
To: esgutier@sauce.chillan.ubiobio.cl
Cc: pgsql-sql@postgresql.org
Subject: Re: pgsql embedded again!
Date: Tue, 23 Oct 2001 14:10:35 METDST
Message-ID: <200110231210.OAA29557@rodos> (raw)
In-Reply-To: <Pine.LNX.4.21.0110221050001.3475-100000@sauce.chillan.ubiobio.cl>
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 <stdio.h>
#include <string.h>
#include <stdlib.h>
#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 ;
}
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: ch@rodos.fzk.de, esgutier@sauce.chillan.ubiobio.cl
Subject: Re: pgsql embedded again!
In-Reply-To: <200110231210.OAA29557@rodos>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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