64 int rc; |
64 int rc; |
65 |
65 |
66 rc = OCIHandleFree((dvoid *)statement->stmt, OCI_HTYPE_STMT); /* Free handles */ |
66 rc = OCIHandleFree((dvoid *)statement->stmt, OCI_HTYPE_STMT); /* Free handles */ |
67 |
67 |
68 statement->stmt = NULL; |
68 statement->stmt = NULL; |
|
69 } |
|
70 |
|
71 if (statement->bind) { |
|
72 free(statement->bind); |
|
73 statement->bind = NULL; |
69 } |
74 } |
70 |
75 |
71 lua_pushboolean(L, ok); |
76 lua_pushboolean(L, ok); |
72 return 1; |
77 return 1; |
73 } |
78 } |
252 if (!statement->stmt) { |
257 if (!statement->stmt) { |
253 luaL_error(L, DBI_ERR_FETCH_INVALID); |
258 luaL_error(L, DBI_ERR_FETCH_INVALID); |
254 return 0; |
259 return 0; |
255 } |
260 } |
256 |
261 |
257 bind = (bindparams_t *)malloc(sizeof(bindparams_t) * statement->num_columns); |
262 statement->bind = (bindparams_t *)malloc(sizeof(bindparams_t) * statement->num_columns); |
258 memset(bind, 0, sizeof(bindparams_t) * statement->num_columns); |
263 memset(statement->bind, 0, sizeof(bindparams_t) * statement->num_columns); |
|
264 bind = statement->bind; |
259 |
265 |
260 for (i = 0; i < statement->num_columns; i++) { |
266 for (i = 0; i < statement->num_columns; i++) { |
261 rc = OCIParamGet(statement->stmt, OCI_HTYPE_STMT, statement->conn->err, (dvoid **)&bind[i].param, i+1); |
267 rc = OCIParamGet(statement->stmt, OCI_HTYPE_STMT, statement->conn->err, (dvoid **)&bind[i].param, i+1); |
262 if (rc) { |
268 if (rc) { |
263 OCIErrorGet((dvoid *)statement->conn->err, (ub4) 1, (text *) NULL, &errcode, errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR); |
269 OCIErrorGet((dvoid *)statement->conn->err, (ub4) 1, (text *) NULL, &errcode, errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR); |
432 |
438 |
433 statement = (statement_t *)lua_newuserdata(L, sizeof(statement_t)); |
439 statement = (statement_t *)lua_newuserdata(L, sizeof(statement_t)); |
434 statement->conn = conn; |
440 statement->conn = conn; |
435 statement->stmt = stmt; |
441 statement->stmt = stmt; |
436 statement->num_columns = 0; |
442 statement->num_columns = 0; |
|
443 statement->bind = NULL; |
437 |
444 |
438 luaL_getmetatable(L, DBD_ORACLE_STATEMENT); |
445 luaL_getmetatable(L, DBD_ORACLE_STATEMENT); |
439 lua_setmetatable(L, -2); |
446 lua_setmetatable(L, -2); |
440 |
447 |
441 return 1; |
448 return 1; |