Re: [NOVICE] DB insert Error - Mailing list pgsql-general

From Michael Fuhr
Subject Re: [NOVICE] DB insert Error
Date
Msg-id 20060817200713.GA92094@winnie.fuhr.org
Whole thread Raw
In response to Re: [NOVICE] DB insert Error  ("Jasbinder Bali" <jsbali@gmail.com>)
Responses Re: [NOVICE] DB insert Error  ("Jasbinder Bali" <jsbali@gmail.com>)
List pgsql-general
On Thu, Aug 17, 2006 at 10:19:57AM -0400, Jasbinder Bali wrote:
> but i don't see any record getting inserted in the table..
> Why is that happenening.

How exactly are you determining that the record isn't being inserted?
Are you sure you're connected to the right database and querying
tables in the right schema?

Here's a complete example for you to try:

1. Create the following table:

CREATE TABLE public.foo (
    id   integer PRIMARY KEY,
    msg  text NOT NULL
);

2. Compile the following program:

int main(void)
{
    EXEC SQL BEGIN DECLARE SECTION;
    char  msg[] = "This is a test.";
    EXEC SQL END DECLARE SECTION;

    ECPGdebug(1, stderr);

    /* Adjust the next line as necessary. */
    EXEC SQL CONNECT TO tcp:postgresql://192.168.0.110/xyz USER jsbali;
    EXEC SQL INSERT INTO public.foo (id, msg) VALUES (1, :msg);
    EXEC SQL COMMIT;
    EXEC SQL DISCONNECT;

    return 0;
}

3. Run the above program and post all output it generates.

4. Connect to the database with psql or whatever client you use,
execute the following query, and post the output:

SELECT * FROM public.foo;

Also, what version of PostgreSQL are you using and what platforms
are the server and client?  I don't recall if you've said.

--
Michael Fuhr

pgsql-general by date:

Previous
From: Walter Vaughan
Date:
Subject: Newbie "Copy From" not working
Next
From: "Merlin Moncure"
Date:
Subject: Re: Best approach for a "gap-less" sequence