plsql - How to run oracle PL/SQL in C++? -


i want run sql script c++ program. code goes this:

int main() {      //.....      sql_stmt = "insert t1 values ('qwerty');\ninsert t1 values ('dothar');";      sql_stmt = "declare\nrollback_check_counter number;\n"     "begin\n"     "rollback_check_counter :=1;\n"     "savepoint sp_1;\nif rollback_check_counter = 1 then\n"     "begin\n"+sql_stmt+"exception\n"     "when program_error then\n"     "rollback_check_counter :=0;\n"     "rollback sp_1\n"     "when others then\n"     "rollback_check_counter :=0;\n"     "rollback sp_1\n"     "end;\n"     "end if;\n"     "commit;\n"     "end;";       try      {         connection *conn = env->createconnection(user,passwd); //error prone         statement *stmt = conn->createstatement();         stmt->setsql(sql_stmt);         row_count = stmt->execute(); //stmt->execute(sql_stmt);          connection::conn->terminatestatement(statement *stmt);         //con->terminatestatement(stmt);         env->terminateconnection(conn);         environment::terminateenvironment(env);     }     catch(sqlexception& ex)     {} //..... return 0; } 

when run insert statement only, runs well. when form sql script structure seems fail. want because want implement rollback. missing? suggest alternative implement it?

create stored procedure.
use pro*c can used embedded sql programming.
documentation refer here basic tutorials here


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -