From: | Yadnyesh Joshi <yadnyesh_joshi(at)yahoo(dot)com> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Using host variables -- segmentation fault |
Date: | 2006-10-16 12:16:06 |
Message-ID: | 20061016121606.15623.qmail@web53204.mail.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
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(at)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.
__________________________________________________________
Yahoo! India Answers: Share what you know. Learn something new
http://in.answers.yahoo.com/
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Fuhr | 2006-10-16 13:41:24 | Re: Using host variables -- segmentation fault |
Previous Message | Shane Ambler | 2006-10-16 11:30:50 | Re: Question about Referential Integrity in Microsoft Access |