Return-Path: pg_adm@postgres.berkeley.edu
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA26426; Mon, 12 Jul 93 05:09:54 -0700
Message-Id: <9307121209.AA26426@postgres.Berkeley.EDU>
From: Kai Petzke <wpp@marie.physik.tu-berlin.de>
Subject: Re: appending alphanumeric string with libPQ
To: postgres@postgres.berkeley.edu
Sender: pg_adm@postgres.berkeley.edu
To: postgres@postgres.Berkeley.EDU
Date: Mon, 12 Jul 1993 14:10:41 +0200 (MET DST)
In-Reply-To: <9307112301.AA24287@postgres.Berkeley.EDU> from "John Peter Lee" at Jul 11, 93 07:06:00 pm
X-Mailer: ELM [version 2.4 PL22]
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Length: 1808      

	Dear,

[some deleted]

> I'm now building an append query in libPQ like so:
> 
> ...
> 
>  sprintf (buf87, "append y87 ( tri_id = %s, ... )", buf[0], ... ); 
>  printf ("\n\nquery is: \n\n%s\n\n", buf87);
>  PQexec ( buf87 ); 

I believe, your problem lies here:

	sprintf (buf87, "append y87 ( tri_id = \"%s\", ... )", buf[0], ... ); 

would be correct.  You have to put quotes around a string argument in 
a query.  To put the quotes into the C-string, you have to escape them
with a backslash \.  If the inserted string (your variable buf[0] could
contain quotes, too, you have to write a more sophisticated C programme,
to escape these in the inserted string.

Inserting values like "id233" will work, as far as I know, because the
parser reads them first as a symbol (like class name, field name, etc.),
then converts it to a string, as it sees, it needs a string.

However, the parser will read 233id as a number (233), then a symbol (id),
will convert the number to a string, but what to do with the symbod id?
This is the error message you got.

[some more deleted]

> So, can anyone tell me why this happens, and how can I make it work ???
> 
> 
> Thank You,
> 
> jp
>  
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> JP Lee               Institute for Visualization and Perception Research	
> jlee@cs.uml.edu                    University of Massachusetts at Lowell 
> (508) 934-3384			      1 University Ave. Lowell, MA 01854
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> 
--
Kai
wpp@marie.physik.tu-berlin.de
An uncarable Linux hacker.

Advertisement by Microsoft in a well-known German magazine:
	If you don't like our programmes, than make your own ones.
However, they expect you to use Microsoft products for this -:)
