Method: OCIStmt#execute
- Defined in:
- ext/oci8/stmt.c
#execute(*args) ⇒ Object
begin
— OCIStmt#execute(svc [, iters [, mode]])
execute statement at the ((<service context handle|OCISvcCtx>)).
:svc
((<service context handle|OCISvcCtx>))
:iters
the number of iterations to execute.
For select statement, if there are columns which is not defined
by ((<OCIStmt#defineByPos>)) and this value is positive, it
raises exception. If zero, no exception. In any case you must define
all columns before you call ((<OCIStmt#fetch>)).
For non-select statement, use positive value.
Default value is 0 for select statement, 1 for non-select statement.
note: Current implemantation doesn't support array fetch and batch mode, so
valid value is 0 or 1.
:mode
((|OCI_DEFAULT|)), ((|OCI_BATCH_ERRORS|)), ((|OCI_COMMIT_ON_SUCCESS|)),
((|OCI_DESCRIBE_ONLY|)), ((|OCI_EXACT_FETCH|)), ((|OCI_PARSE_ONLY|)),
any combinations of previous values, or ((|OCI_STMT_SCROLLABLE_READONLY|)).
Default value is ((|OCI_DEFAULT|)).
((|OCI_BATCH_ERRORS|)) and ((|OCI_STMT_SCROLLABLE_READONLY|)) are not
supported by current implementation.
correspond native OCI function: ((|OCIStmtExecute|))
end
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 |
# File 'ext/oci8/stmt.c', line 492
static VALUE oci8_stmt_execute(int argc, VALUE *argv, VALUE self)
{
VALUE vsvc;
VALUE viters;
VALUE vmode;
oci8_handle_t *h;
oci8_handle_t *svch;
ub4 mode;
ub4 iters;
ub2 stmt_type;
sword rv;
rb_scan_args(argc, argv, "12", &vsvc, &viters, &vmode);
Get_Handle(self, h); /* 0 */
Check_Handle(vsvc, OCISvcCtx, svch); /* 1 */
if (argc >= 2) {
iters = NUM2UINT(viters); /* 2 */
} else {
rv = OCIAttrGet(h->hp, OCI_HTYPE_STMT, &stmt_type, 0, OCI_ATTR_STMT_TYPE, h->errhp);
if (rv != OCI_SUCCESS) {
oci8_raise(h->errhp, rv, h->hp);
}
if (stmt_type == OCI_STMT_SELECT) {
/* for select statement, default value 0. */
iters = 0;
} else {
/* for non-select statement, default value 0. */
iters = 1;
}
}
Get_Int_With_Default(argc, 3, vmode, mode, OCI_DEFAULT); /* 3 */
if (iters > 1) {
rb_raise(rb_eArgError, "current implementation doesn't support array fatch or batch mode");
}
rv = OCIStmtExecute(svch->hp, h->hp, h->errhp, iters, 0, NULL, NULL, mode);
if (rv == OCI_ERROR) {
sb4 errcode;
OCIErrorGet(h->errhp, 1, NULL, &errcode, NULL, 0, OCI_HTYPE_ERROR);
if (errcode == 1000) {
/* run GC to close unreferred cursors when ORA-01000 (maximum open cursors exceeded). */
rb_gc();
rv = OCIStmtExecute(svch->hp, h->hp, h->errhp, iters, 0, NULL, NULL, mode);
}
}
if (IS_OCI_ERROR(rv)) {
oci8_raise(h->errhp, rv, h->hp);
}
return self;
}
|