pg.ddx.io pgsql-sql@postgresql.org mailing list archivehelp / color / mirror / Atom feed
Re: pgsql embedded again! 2+ messages / 2 participants [nested] [flat]
* Re: pgsql embedded again!
@ 1970-01-01 00:00 Haller Christoph <ch@rodos.fzk.de>
parent: Esteban Gutierrez Abarzua <esgutier@sauce.chillan.ubiobio.cl>
0 siblings, 0 replies; 2+ messages in thread
From: Haller Christoph @ 1970-01-01 00:00 UTC (permalink / raw)
To: esgutier@sauce.chillan.ubiobio.cl; +Cc: pgsql-sql
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 ;
}
^ permalink raw reply [nested|flat] 2+ messages in thread
* pgsql embedded again!
@ 2001-10-22 13:51 Esteban Gutierrez Abarzua <esgutier@sauce.chillan.ubiobio.cl>
0 siblings, 1 reply; 2+ messages in thread
From: Esteban Gutierrez Abarzua @ 2001-10-22 13:51 UTC (permalink / raw)
To: pgsql-sql
hi.
I still have the data type problem.
I am working with the postgresql system catalog and I wanna get all
relname of pg_class relation on a C variable.
-----> \d pg_class
Attribute | Type | Modifier
--------------+-----------+----------
relname | name |
reltype | oid |
relowner | integer |
relam | oid |
.........
......
.....
...
..
C program.
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR tabla[50]; I also tried with char tabla[50];
......
....
.
EXEC SQL END DECLARE SECTION;
I used a cursor for results.....
EXEC SQL DECLARE T99 CURSOR FOR select relname from pg_class
now I want to get the results of query... then:
EXEC SQL OPEN T99;
EXEC SQL FETCH IN T99 INTO :tabla; here is the problem, I can't
to get on tabla variable results.
I think that may be the data type ..... I don't know ....
do you know about psql embedded mail list?
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2001-10-22 13:51 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2001-10-22 13:51 pgsql embedded again! Esteban Gutierrez Abarzua <esgutier@sauce.chillan.ubiobio.cl> 1970-01-01 00:00 ` Haller Christoph <ch@rodos.fzk.de>
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