Hi,
I am trying to use C variables in embedded sql statements.
But I am getting a segmentation fault.
Also, out put at server is :
LOG: unexpected EOF on client connection
When I try to insert values without using C variables, they're added to database without any problem.
Problem occurs when I try to insert values from C variables.
Here is the simple program I have written -
/*first.c*/
/*Assume create table simple (s int);*/
#include<stdio.h>
int main()
{
EXEC SQL BEGIN DECLARE SECTION;
char *target="mydb@localhost";
int i;
char msg[10];
EXEC SQL END DECLARE SECTION;
//strcpy(msg,"\'AAAA\'");
EXEC SQL CONNECT TO :target;
EXEC SQL INSERT INTO simple values (6);
EXEC SQL COMMIT;
EXEC SQL INSERT INTO simple values (:i);
EXEC SQL COMMIT;
//EXEC SQL INSERT INTO fromprg values (:i,:msg);
//EXEC SQL COMMIT;
EXEC SQL DISCONNECT;
}
Then as usual, I executed two commands -
ecpg first.pgc
gcc first.c -o first -lecpg
I get segmentation fault.
LOG: unexpected EOF on client connection
The first EXEC SQL INSERT INTO simple values (6); executes fine. The value is added in the database as I am doing a COMMIT.
However, segmentation fault occurs at EXEC SQL INSERT INTO simple values (:i);
What can be the problem?
Thank you,
Yadnyesh.
Find out what India is talking about on -
Yahoo! Answers India Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8.
Get it NOW