c - Program with embedded sql gives compilation error -


#include<stdio.h> #include<error.h> #include<sys/shm.h>  #include "/opt/postgresql/9.1/include/libpq-fe.h" int main() {    pgconn *conn;    int buf_ptr=0;    int i;    {       fprintf(stderr,"connection database failed:%s",pqerrormessage(conn));       exit(0);    }    else    {       printf("connection database successful \n");    }    printf("do want create table enter 1 \n ");    scanf("%d",&i);    if(i==1)    {       exec sql create    table empoye(              eno      int,              ename    varchar(10));    }    return 0; } 

hello newbie learning embedded c want create simple code table created in c when compiling above program getting error like

    embc.c:25: error: âexecâ undeclared (first use in function)     embc.c:25: error: (each undeclared identifier reported once     embc.c:25: error: each function appears in.)     embc.c:25: error: expected â;â before âsqlâ  please    

first, connection database missing, should have :

int i=0; exec sql connect target [as connection-name] [user user-name]; 

or

pgconn *conn; int buf_ptr=0; int i=0; conn = pqconnectdbparams(const char **keywords, const char **values, int expand_dbname); 

then save source file prog.pgc , run :

ecpg prog.pgc 

this create file called prog.c can compiled standard c file.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -