proc插入数据到数据库

#include<stdio.h>
EXEC SQL INCLUDE SQLCA;

void insert (char password_[6],char id_[20],int balance_)
{       
    EXEC SQL BEGIN DECLARE SECTION;       
      VARCHAR user[20],pass[20],tnsname[20];       
      char password[6];       
      char id[20];       
      int balance;       
    EXEC SQL END DECLARE SECTION;

strcpy(user.arr,"zhangsan");       
    user.len=(unsigned short)strlen((char *)user.arr);       
    strcpy(pass.arr,"lisi");       
    pass.len=(unsigned short)strlen((char *)pass.arr);       
    strcpy(tnsname.arr,"suning");       
    tnsname.len=(unsigned short)strlen((char *)tnsname.arr);       
    strcpy(id,id_);       
    strcpy(password,password_);       
    balance = balance_;

EXEC SQL CONNECT :user IDENTIFIED BY :pass USING :tnsname;       
    EXEC SQL insert into bank_bingo values (:id , :password , :balance);       
    EXEC SQL COMMIT WORK;       
    EXEC SQL commit work release;
}
int main(int argc , char ** argv)
{       
   char id[20] = "10001";       
   char password[6] = "123";       
   int balance = 10000;       
   insert(password ,id ,balance);       
   return 0;
}

在dos环境下编译成.c文件直接执行

proc iname=i.pc oname=1.c;

上一篇:win10系统Mysql5.7服务启动报:"1053错误:服务没有及时响应启动或控制请求"


下一篇:Effective C++ -----条款44:将与参数无关的代码抽离templates