Re: [GENERAL] Problems with INSERT INTO?

From: Simon Drabble <simond(at)foxlink(dot)net>
To: Anna Langer <anna_langer(at)hotmail(dot)com>
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] Problems with INSERT INTO?
Date: 1999-05-24 13:37:08
Message-ID: Pine.LNX.3.96.990524093049.17669B-100000@dragon
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-interfaces

On Mon, 24 May 1999, Simon Drabble wrote:

> On Mon, 24 May 1999, Anna Langer wrote:
>
> > 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.
>

*oops* heh-heh.

Do _this_:

char query[LOTS_OF_ROOM];
sprintf(query, "INSERT INTO octects VALUES(%d)", a);

PQexec(conn, query);

and read up etc..

-or- download my libpq wrapper, which allows you to perform queries without
using a temporary char array, in a manner similar to printf(). Available via
anon ftp from

brainkarma.dyndns.org/pub/dblib/

Note: it's very alpha right now and possibly quite messy as it's still under
development - works though :)

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(at)foxlink(dot)net

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 1999-05-24 13:45:27 Re: [GENERAL] Full Text Searches
Previous Message Simon Drabble 1999-05-24 13:25:51 Re: [GENERAL] Problems with INSERT INTO?

Browse pgsql-interfaces by date

  From Date Subject
Next Message Crispin Miller 1999-05-24 14:09:04 JDBC and insert - stack overflow
Previous Message Simon Drabble 1999-05-24 13:25:51 Re: [GENERAL] Problems with INSERT INTO?