Kbase 19375: How to insert a DATE in a Date Field in ESQL/C.
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  1/3/2000 |
|
The following code gives an example how to insert a date in a date field.
It has been tested on Unix HP-UX 10.20 and Progress version 8.3B.
#include <stdio.h>
/* Add table "test", and Field "FDate" to a database */
main(argc,argv)
int argc;
char *argv[];
{
long SQLCODE;
char *msg;
char request[256];
EXEC SQL BEGIN DECLARE SECTION;
EXEC SQL END DECLARE SECTION;
EXEC SQL WHENEVER SQLERROR GOTO err;
if (sqllogin(argc-1, &argv[1], "", "") == -1) {
printf(" Could not login to Progress HLI.\n " );
exit(0);
}
/* Add the Date: 01/01/2000 */
sprintf(query,"insert into test (FDate) values (01\\/01\\/2000)");
EXEC SQL EXECUTE IMMEDIATE request;
EXEC SQL COMMIT WORK;
sqllogout(0);
return 0;
err:
printf("Error occured.\n");
while ((msg = (char *) sqlgetmsg()) != (char *) 0)
printf("%s\n",msg);
printf("\nRolling back all work...\n");
EXEC SQL ROLLBACK WORK;
sqllogout(0);
exit(0);
}
Progress Software Technical Support Note # 19375