Skip site navigation (1) Skip section navigation (2)

Using host variables -- segmentation fault

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 (view raw or flat)
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/

Responses

pgsql-novice by date

Next:From: Michael FuhrDate: 2006-10-16 13:41:24
Subject: Re: Using host variables -- segmentation fault
Previous:From: Shane AmblerDate: 2006-10-16 11:30:50
Subject: Re: Question about Referential Integrity in Microsoft Access

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group