Subject: time types

From: John Peter Lee <[email-masked]>
Date: Thu, 11 Nov 1993 13:57:34 -0500 (EST)

Hi:

   I am wondering about how to specify the built-in time types
   in Postgres. Page 23 of my manual gives their syntax, and
   I want to know if when I specify time in libPQ (by building a
   character buffer), do the times have to be double-quoted, like so:

    sprintf (buf, "append db_meta_data ( ... 
	date_created = %s, \			/* <- abstime type */
	...
	range = %s }				/* <- tinterval type */
	)",

	...

	"Nov 12 1993",				/8 date_created */
	
	...

	"[Jan 01 1974, Dec 31 1992]"		/* range */
	);

	query_result = (char *) PQexec ( buf );

	pointers would be appreciated.

	thanks.

	jp

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
JP Lee               Institute for Visualization and Perception Research	
[email-masked]                    University of Massachusetts at Lowell 
(508) 934-3384			      1 University Ave. Lowell, MA 01854

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

---

From: [email-masked] (Paul M. Aoki)
Date: Fri, 12 Nov 93 01:34:46 -0800

John Peter Lee <[email-masked]> writes:
> 	range = %s \				/* <- tinterval type */
> 	)",
> 	...
> 

you need actual double-quotes *in the query* here.  so you need
	date_created = \"%s\"
in your sprintf control string.

> 	"[Jan 01 1974, Dec 31 1992]"		/* range */

the tinterval code likes single-quotes around each time.  confusingly,
time range expressions (time travel) use commas, but i don't think
the tinterval ADT code likes commas.  i think 
	range = \"%s\"
	"['Jan 01 1974' 'Dec 31 1992']"
works better.  (at least, it does on our development system.)  this
should probably be made consistent.
--
  Paul M. Aoki  |  CS Div., Dept. of EECS, UCB  |  [email-masked]
                |  Berkeley, CA 94720           |  ...!uunet!ucbvax!aoki