Return-Path: pg_adm@postgres.berkeley.edu
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA24287; Sun, 11 Jul 93 16:01:11 -0700
Message-Id: <9307112301.AA24287@postgres.Berkeley.EDU>
From: John Peter Lee <jlee@cs.uml.edu>
Subject: appending alphanumeric string with libPQ
To: postgres@postgres.berkeley.edu
Sender: pg_adm@postgres.berkeley.edu
To: postgres@postgres.berkeley.edu (postgres)
Date: Sun, 11 Jul 1993 19:06:00 -0400 (EDT)
X-Mailer: ELM [version 2.4 PL22]
Content-Type: text
Content-Length: 1934      


Hi -

I'm running Postgres 4.0.1 on a SPARCstation.

I'm having a problem appending an alphanumeric string (with the numeric part
first) to the backend with libPQ. Here is the scenario: I can create a class
in libPQ:

...

 query_result = PQexec ( "create y87 ( tri_id = char16, ... ); 

...

without a problem.



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 ); 

...


each item in the array "buf" is a string (character array).
the printf-ed query looks like: 

query is: 

append y87 ( tri_id = 01001HPHDN233MA, ... ) 


**************************************

The parser complains with the following:

WARN:Jul 11 18:15:48:parser: syntax error at or near "HPHDN233MA"

which is part of the first attribute. I then tried to perform a similar append
from the monitor on a test database, and succeeded, using double quotes 
around the attribute like so:

Welcome to the C POSTGRES terminal monitor

Go 
* create y87 (tri_id = char16) \g
Query sent to backend is "create y87 (tri_id = char16) "
CREATE
Go 
* append y87 (tri_id = "01001HPHDN233MA") \g

Query sent to backend is "append y87 (tri_id = "01001HPHDN233MA") "
APPEND 87051


So, I tried putting the quotes into the libPQ version:

query is:

append y87 ( tri_id = "01001HPHDN233MA", ...);

and got the following complaint:

WARN:Jul 11 18:49:41:heap_openr on H failed



********


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

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
