Re: [GENERAL] Problems with INSERT INTO? - Mailing list pgsql-general

From Simon Drabble
Subject Re: [GENERAL] Problems with INSERT INTO?
Date
Msg-id Pine.LNX.3.96.990524092454.17623A-100000@dragon
Whole thread Raw
In response to Problems with INSERT INTO?  ("Anna Langer" <anna_langer@hotmail.com>)
Responses Re: [GENERAL] Problems with INSERT INTO?  (Simon Drabble <simond@foxlink.net>)
List pgsql-general
On Mon, 24 May 1999, Anna Langer wrote:

> Hi!
> We are not really sure if this question is right for this mailinglist.
> We have some problem with INSERT INTO and we dont know how to solve it.We
> are writing it in a C-program. We are trying to get an integer from a file
> and put it into a database. And we are sure that we get a interger into our
> program.
>
> When we created the table in the database we set the attribut to int4.
> We get the problem when we trying to move the interger to the database.
>
> int a=500;
>
> PQexec(conn, "INSERT INTO octets VALUES(a)");
>
>
> But the program works when we do like this:
>
> PQexec(conn, "INSERT INTO octets VALUES(500)");
>
>
> It feels like we need to convert int a in some way, byt we dont know how. We
> are beginners with Postgresql.
>
> /Anna and Maria
>

Do this:

PQexec(conn, "INSERT INTO octets VALUES(%d)", a);

and read up on C's printf family of functions.


Simon.


--
  On October 7, 1998 the routine process of running anti-virus software on a
  Windows NT server at the Boeing Corporation shut the system down. Evidently,
  the software identified Windows NT itself as a virus and disabled it.
                  -- http://www.vcnet.com/bmc/departments/nt/bugs.shtml

   Simon Drabble                      Somewhere in cyberspace
   simond@foxlink.net


pgsql-general by date:

Previous
From: Andy Lewis
Date:
Subject: Re: [GENERAL] Full Text Searches
Next
From: Simon Drabble
Date:
Subject: Re: [GENERAL] Problems with INSERT INTO?