Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 (中文) » SQL Anywhere 服务器 - 编程 » SQL Anywhere 数据访问 API » SQL Anywhere C API 参考 » sacapi.h

 

sqlany_execute 函数

执行预准备语句。

语法
sacapi_bool sqlany_execute( a_sqlany_stmt * stmt )
参数
  • stmt   使用 sqlany_prepare 成功预准备的语句。

返回值

成功则为 1,失败则为 0。

注释

可使用 sqlany_num_cols 验证语句是否返回结果集。

另请参见
示例
// This example shows how to execute a statement that does not return a result set
   a_sqlany_stmt *       stmt;
   int                   I;
   a_sqlany_bind_param   param;

   stmt = sqlany_prepare( conn, "insert into moe(id,value) values( ?,? )" );
   if( stmt ) {
       sqlany_describe_bind_param( stmt, 0, &param );
       param.value.buffer = (char *)&I;
       param.value.type   = A_VAL32;
       sqlany_bind_param( stmt, 0, &param );

       sqlany_describe_bind_param( stmt, 1, &param );
       param.value.buffer = (char *)&I;
       param.value.type   = A_VAL32;
       sqlany_bind_param( stmt, 1, &param );

       for( I = 0; I < 10; I++ ) {
           if( !sqlany_execute( stmt ) ) {
                // call sqlany_error()
           }
       }
       sqlany_free_stmt( stmt );
   }