Using host variables -- segmentation fault - Mailing list pgsql-novice

From Yadnyesh Joshi
Subject Using host variables -- segmentation fault
Date
Msg-id 20061016121606.15623.qmail@web53204.mail.yahoo.com
Whole thread Raw
Responses Re: Using host variables -- segmentation fault  (Michael Fuhr <mike@fuhr.org>)
List 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@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

pgsql-novice by date:

Previous
From: Shane Ambler
Date:
Subject: Re: Question about Referential Integrity in Microsoft Access
Next
From: Michael Fuhr
Date:
Subject: Re: Using host variables -- segmentation fault