- 在esql中使用的变量声明
这些变量在使用时前面要加上:
- execsqlbegindeclaresection;
- char_id[10];
- char_name[20];
- char_password[18];
- char_branchid[9];
- char_roleid[2];
- chardb_name[128+1];
- char_sql[]="updateuserinfosetpassword=?whereuserid=?";
- execsqlenddeclaresection;
动态SQL操作例1
- EXECSQLDECLAREcursor1CURSORFOR\
- selectuseridfromuserinfo;
- EXECSQLOPENcursor1;
- do
- {
- EXECSQLFETCHcursor1INTO:_id;
- if(sqlca.sqlcode==100)break;
- printf("%10s\n",_id);
- }while(1);
动态SQL操作例2
- execsqlbegindeclaresection;
- char_id[10];
- char_name[20];
- char_password[18];
- char_sql[]="updateuserinfosetpassword=?whereuserid=?";
- execsqlenddeclaresection;
- memset(_id,0x00,sizeof(_id));
- memset(_password,0x00,sizeof(_password));
- sprintf(_id,"%s","001");
- sprintf(_password,"%s","haha");
- EXECSQLPREPAREprep_statFROM:_sql;
- EXECSQLEXECUTEprep_statUSING:_password,:_id;