dbd/oracle/statement.c

changeset 21
7956401a0c5e
parent 19
b5ec612be4da
child 27
1d2369ebee21
equal deleted inserted replaced
20:5ab0b30f8fbd 21:7956401a0c5e
20 default: 20 default:
21 lua_type = LUA_PUSH_STRING; 21 lua_type = LUA_PUSH_STRING;
22 } 22 }
23 23
24 return lua_type; 24 return lua_type;
25 }
26
27 /*
28 * num_affected_rows = statement:affected()
29 */
30 static int statement_affected(lua_State *L) {
31 statement_t *statement = (statement_t *)luaL_checkudata(L, 1, DBD_ORACLE_STATEMENT);
32 int affected;
33 int rc;
34
35 if (!statement->stmt) {
36 luaL_error(L, DBI_ERR_INVALID_STATEMENT);
37 }
38
39 /*
40 * get number of affected rows
41 */
42 rc = OCIAttrGet(
43 (dvoid *)statement->stmt,
44 (ub4)OCI_HTYPE_STMT,
45 (dvoid *)&affected,
46 (ub4 *)0,
47 (ub4)OCI_ATTR_ROW_COUNT,
48 statement->conn->err
49 );
50
51 lua_pushinteger(L, affected);
52
53 return 1;
25 } 54 }
26 55
27 /* 56 /*
28 * success = statement:close() 57 * success = statement:close()
29 */ 58 */
349 378
350 return statement_fetch_impl(L, statement, named_columns); 379 return statement_fetch_impl(L, statement, named_columns);
351 } 380 }
352 381
353 /* 382 /*
383 * num_rows = statement:rowcount()
384 */
385 static int statement_rowcount(lua_State *L) {
386 luaL_error(L, DBI_ERR_NOT_IMPLEMENTED, DBD_ORACLE_STATEMENT, "rowcount");
387
388 return 0;
389 }
390
391 /*
354 * iterfunc = statement:rows(named_indexes) 392 * iterfunc = statement:rows(named_indexes)
355 */ 393 */
356 static int statement_rows(lua_State *L) { 394 static int statement_rows(lua_State *L) {
357 if (lua_gettop(L) == 1) { 395 if (lua_gettop(L) == 1) {
358 lua_pushvalue(L, 1); 396 lua_pushvalue(L, 1);
403 return 1; 441 return 1;
404 } 442 }
405 443
406 int dbd_oracle_statement(lua_State *L) { 444 int dbd_oracle_statement(lua_State *L) {
407 static const luaL_Reg statement_methods[] = { 445 static const luaL_Reg statement_methods[] = {
446 {"affected", statement_affected},
408 {"close", statement_close}, 447 {"close", statement_close},
409 {"execute", statement_execute}, 448 {"execute", statement_execute},
410 {"fetch", statement_fetch}, 449 {"fetch", statement_fetch},
450 {"rowcount", statement_rowcount},
411 {"rows", statement_rows}, 451 {"rows", statement_rows},
412 {NULL, NULL} 452 {NULL, NULL}
413 }; 453 };
414 454
415 static const luaL_Reg statement_class_methods[] = { 455 static const luaL_Reg statement_class_methods[] = {

mercurial