Hi
Below is the sample ECPG test case what i have prepared.
Sample ECPG Scripts
================
-bash-4.1$ more foo2.h typedef struct { foo123 a[8]; } bar; -bash-4.1$ more foo1.h typedef struct { int x; }foo123;-bash-4.1$ more foo.pgc EXEC SQL INCLUDE "foo1.h"; EXEC SQL INCLUDE "foo2.h"; int main() { EXEC SQL BEGIN DECLARE SECTION; char* dbname = "edb"; char* db = "edb@localhost:5444"; char* user = "enterprisedb"; char* passwd = "adminedb"; EXEC SQL END DECLARE SECTION; bar records; EXEC SQL WHENEVER SQLERROR GOTO sql_error; EXEC SQL CONNECT :user IDENTIFIED BY :passwd AT :dbname USING :db; EXEC SQL AT :dbname DECLARE cur_TBL CURSOR FOR SELECT COUNT(*) AS rec_count FROM EMP ; EXEC SQL AT :dbname OPEN cur_TBL; EXEC SQL AT :dbname FETCH cur_TBL INTO :records.a[0].x; EXEC SQL AT :dbname CLOSE cur_TBL; EXEC SQL DISCONNECT CURRENT; printf("OK\n"); printf("RECORD COUNT = %d\n",records.a[0].x); return 0; sql_error: printf("ERROR\n"); return 1; }Make File ========= -bash-4.1$ more Makefile all: ecpg -C PROC foo.pgc cc -o foo foo.c -I /opt/PostgresPlus/9.1AS/include -L /opt/PostgresPlus/9.1AS/lib -lecpg Execution ========= -bash-4.1$ ./foo OK RECORD COUNT = 14
à°¦ిà°¨ేà°·్ à°•ుà°®ాà°°్
Dinesh Kumar
Comments
Post a Comment