Key statement:
char *stmt=
"alter session set nls_date_format='yyyy-mm-dd HH24:MI:SS'";
if ( 0 > (stat = sqlo_exec(dbh, stmt)))
printf("sqlo_exec error!");
char * insert_stmt =
"INSERT INTO table_test (ID, Name, IP, ACCESSTIME) VALUES (:id, :name, :ip, :accesstime)";
edit time format:
strftime
1 #include <stdio.h>
2 #include <string.h>
3 #include <time.h>
4 #include <sys/time.h>
5
6 int main()
7 {
8 time_t t;
9 struct tm *area;
10 char tmpbuf[128];
11
12 t = time(NULL);
13 area = localtime(&t);
14 strftime(tmpbuf, sizeof(tmpbuf), "%Y-%m-%d %H:%M:%S",area);
15 printf("DT=%s/n",tmpbuf);
16
17 return (0);
18 }