First, call OCI_StatementCreate() to allocate a statement handle. Then :
- Prepare the SQL with OCI_Prepare()
- Parse and execute it with OCI_Execute()
These two steps can be done together by calling OCI_ExecuteStmt() that prepares and executes in one go.
- Example
#include "ocilib.h" int main(void) { OCI_Connection *cn; OCI_Statement *st; if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT)) return EXIT_FAILURE; cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT); st = OCI_StatementCreate(cn); /* prepare and execute in 2 steps */ OCI_Prepare(st, "delete from test_fetch where code > 10"); OCI_Execute(st); /* prepare/execute in 1 step */ OCI_ExecuteStmt(st, "delete from test_fetch where code > 1"); printf("%d row deleted", OCI_GetAffectedRows(st)); OCI_Commit(cn); OCI_Cleanup(); return EXIT_SUCCESS; }
댓글 없음:
댓글 쓰기