libsqlora8:(insert system time as an appointed format)

来源:互联网 发布:哈尔滨软件培训机构 编辑:程序博客网 时间:2024/05/20 06:52

 
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 }

原创粉丝点击