pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedlibpq/INSERT
4+ messages / 4 participants
[nested] [flat]
* libpq/INSERT
@ 2001-04-24 15:31 Andy Champion <andychampion@hotmail.com>
2001-04-24 16:13 ` Re: libpq/INSERT liam <allenwc@home.com>
2001-04-24 16:14 ` Re: libpq/INSERT Oliver Elphick <olly@lfix.co.uk>
2001-04-24 16:21 ` Re: libpq/INSERT Brett W. McCoy <bmccoy@chapelperilous.net>
0 siblings, 3 replies; 4+ messages in thread
From: Andy Champion @ 2001-04-24 15:31 UTC (permalink / raw)
To: pgsql-interfaces
<html><DIV>
<DIV>Hi, i'm trying to insert data pulled into a postgresql database but i'm having some problems with the inserts.</DIV>
<DIV> </DIV>
<DIV>i know that this:<BR>sprintf(insert_string, "INSERT INTO udpdata VALUES (1234);\n");</DIV>
<DIV> </DIV>
<DIV>is a valid statment, but how do i alter this so that instead of the 1234 i insert the value of a variable?</DIV>
<DIV> </DIV>
<DIV>thanks</DIV></DIV><br clear=all><hr>Get Your Private, Free E-mail from MSN Hotmail at <a href="http://www.hotmail.com">http://www.hotmail.com</a>.<br></p></html;
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: libpq/INSERT
2001-04-24 15:31 libpq/INSERT Andy Champion <andychampion@hotmail.com>
@ 2001-04-24 16:13 ` liam <allenwc@home.com>
2 siblings, 0 replies; 4+ messages in thread
From: liam @ 2001-04-24 16:13 UTC (permalink / raw)
To: Andy Champion <andychampion@hotmail.com>; +Cc: pgsql-interfaces
At 3:31 PM +0000 4/24/01, Andy Champion wrote:
>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");
>
i= 1234 ;
sprintf (insert_string, "INSERT INTO updata VALUES(%i);\n",i) ;
it's just plain old ordinary ansi c.
--
Later . . . 'liam
allenwc@home.com
William C Allen, BLS, EET
"It may be that your sole purpose in life is to serve as a warning to others"
At least I /have/ a purpose!
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: libpq/INSERT
2001-04-24 15:31 libpq/INSERT Andy Champion <andychampion@hotmail.com>
@ 2001-04-24 16:14 ` Oliver Elphick <olly@lfix.co.uk>
2 siblings, 0 replies; 4+ messages in thread
From: Oliver Elphick @ 2001-04-24 16:14 UTC (permalink / raw)
To: Andy Champion <andychampion@hotmail.com>; +Cc: pgsql-interfaces
"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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: libpq/INSERT
2001-04-24 15:31 libpq/INSERT Andy Champion <andychampion@hotmail.com>
@ 2001-04-24 16:21 ` Brett W. McCoy <bmccoy@chapelperilous.net>
2 siblings, 0 replies; 4+ messages in thread
From: Brett W. McCoy @ 2001-04-24 16:21 UTC (permalink / raw)
To: Andy Champion <andychampion@hotmail.com>; +Cc: pgsql-interfaces
On Tue, 24 Apr 2001, Andy Champion wrote:
> 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 1234
> i insert the value of a variable?
int value = 1234;
sprintf(insert_string, "INSERT INTO udpdata VALUES(%d);\n", value);
Check the man page or the documentation for your C run-time libraries for
the sprintf-like functions (printf, sprintf, fprintf, etc) for information
on formatting rules.
-- Brett
http://www.chapelperilous.net/btfwk/
------------------------------------------------------------------------
They are relatively good but absolutely terrible.
-- Alan Kay, commenting on Apollos
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2001-04-24 16:21 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-04-24 15:31 libpq/INSERT Andy Champion <andychampion@hotmail.com>
2001-04-24 16:13 ` liam <allenwc@home.com>
2001-04-24 16:14 ` Oliver Elphick <olly@lfix.co.uk>
2001-04-24 16:21 ` Brett W. McCoy <bmccoy@chapelperilous.net>
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