pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Embedded SQL timestamp Question (ECPG)
2+ messages / 2 participants
[nested] [flat]

* Embedded SQL timestamp Question (ECPG)
@ 2004-06-30 00:04 Greg Markham <gmarkham@markhamdirect.com>
  2004-06-30 11:30 ` Embedded SQL timestamp Question (ECPG) Lee Kindness <lkindness@csl.co.uk>
  0 siblings, 1 reply; 2+ messages in thread

From: Greg Markham @ 2004-06-30 00:04 UTC (permalink / raw)
  To: pgsql-interfaces

I'm trying to use embedded SQL to load some tables and I'm having some 
trouble being able to create timestamps using PGTYPEStimestamp_current 
routine to create a timestamp before using it in a insert statement.  
The issue is that the timestamp that gets created is only to the 
second.  I need it to the microsecond.  I will use this timestamp as 
part of the primary key of two tables.  Does anyone know how to create a 
timestamp object (using PGTYPEStimestamp_current or not) that when 
insert via embedded SQL will create a timestamp out to at least 6 
milliseconds (i.e. 2004-06-29 12:59:59.999999)?

Thank you in advance for any help,

- Greg Markham
gmarkham@markhamdirect.com



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Embedded SQL timestamp Question (ECPG)
  2004-06-30 00:04 Embedded SQL timestamp Question (ECPG) Greg Markham <gmarkham@markhamdirect.com>
@ 2004-06-30 11:30 ` Lee Kindness <lkindness@csl.co.uk>
  0 siblings, 0 replies; 2+ messages in thread

From: Lee Kindness @ 2004-06-30 11:30 UTC (permalink / raw)
  To: Greg Markham <gmarkham@markhamdirect.com>; +Cc: pgsql-interfaces

Just use a double, e.g. something along the lines of:

 EXEC SQL BEGIN DECLARE SECTION;
 double l_tstamp;
 EXEC SQL END DECLARE SECTION;

 l_tstamp =  (double)seconds;
 l_tstamp += (double)microsecs / 1000000.0;

 EXEC SQL INSERT INTO table(column) VALUES(:l_tstamp);

Watch out for timezones...

Greg Markham writes:
 > I'm trying to use embedded SQL to load some tables and I'm having some 
 > trouble being able to create timestamps using PGTYPEStimestamp_current 
 > routine to create a timestamp before using it in a insert statement.  
 > The issue is that the timestamp that gets created is only to the 
 > second.  I need it to the microsecond.  I will use this timestamp as 
 > part of the primary key of two tables.  Does anyone know how to create a 
 > timestamp object (using PGTYPEStimestamp_current or not) that when 
 > insert via embedded SQL will create a timestamp out to at least 6 
 > milliseconds (i.e. 2004-06-29 12:59:59.999999)?
 > 
 > Thank you in advance for any help,
 > 
 > - Greg Markham
 > gmarkham@markhamdirect.com



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2004-06-30 11:30 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-06-30 00:04 Embedded SQL timestamp Question (ECPG) Greg Markham <gmarkham@markhamdirect.com>
2004-06-30 11:30 ` Lee Kindness <lkindness@csl.co.uk>

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