pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Elphick <olly@lfix.co.uk>
To: Andy Champion <andychampion@hotmail.com>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: libpq/INSERT
Date: Tue, 24 Apr 2001 17:14:33 +0100
Message-ID: <200104241614.f3OGEXU02899@linda.lfix.co.uk> (raw)
In-Reply-To: <andychampion@hotmail.com> <F124n1xxWn9R6mJB5260000bd17@hotmail.com>

"Andy Champion" wrote:
  ><html><DIV>

Please turn off html mode in your mailer.

  >Hi, i'm trying to insert data pulled into a postgresql database but i'm
      > having some problems with the inserts.
  >
  >i know that this:
  >  sprintf(insert_string, "INSERT INTO udpdata VALUES (1234);\n");
  >
  >is a valid statment, but how do i alter this so that instead of the 123
      >4 i insert the value of a variable?
  
It sounds as though you need a basic course in C programming.

sprintf(insert_string, "INSERT INTO udpdata VALUES (%s);\n", string_variable);
sprintf(insert_string, "INSERT INTO udpdata VALUES (%d);\n", integer_variable);

You could find this out by reading the manual for sprintf...

-- 
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47  6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "Now unto him that is able to do exceeding abundantly 
      above all that we ask or think, according to the power
      that worketh in us, Unto him be glory in the church by
      Christ Jesus throughout all ages, world without end. 
      Amen."          Ephesians 3:20,21 





view thread (4+ messages)  latest in thread

Message-ID: <200104241614.f3OGEXU02899@linda.lfix.co.uk>
Permalink:  ../200104241614.f3OGEXU02899@linda.lfix.co.uk/
Also on:    postgresql.org/message-id/200104241614.f3OGEXU02899@linda.lfix.co.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: olly@lfix.co.uk, andychampion@hotmail.com
  Subject: Re: libpq/INSERT
  In-Reply-To: <200104241614.f3OGEXU02899@linda.lfix.co.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox