#include #include #include int main() { exec sql begin declare section; date date1; timestamp ts1; char *text; exec sql end declare section; #if 0 Date date2; short int mdy[3] = { 4, 19, 1998 }; #endif FILE *dbgs; if ((dbgs = fopen("log", "w")) != NULL) ECPGdebug(1, dbgs); exec sql whenever sqlerror do sqlprint(); exec sql connect to mm; exec sql create table date_test (d date, ts timestamp); exec sql insert into date_test(d, ts) values ('Mon Jan 17 1966', '2000-7-12 17:34:29'); exec sql select * into :date1, :ts1 from date_test; text = PGTYPESdate_dtoa(date1); printf ("Date: %s\n", text); ts1 = PGTYPEStimestamp_atot("2000-7-12 17:34:29", NULL); text = PGTYPEStimestamp_ttoa(ts1); printf ("timestamp: %s\n", text); #if 0 PGTYPESdate_mdyjul(mdy, &date2); printf("m: %d, d: %d, y: %d\n", mdy[0], mdy[1], mdy[2]); /* reset */ mdy[0] = mdy[1] = mdy[2] = 0; PGTYPESdate_julmdy(date2, mdy); printf("m: %d, d: %d, y: %d\n", mdy[0], mdy[1], mdy[2]); #endif exec sql rollback; exec sql disconnect; if (dbgs != NULL) fclose(dbgs); return (0); }