75 } |
75 } |
76 |
76 |
77 /* |
77 /* |
78 * column_names = statement:columns() |
78 * column_names = statement:columns() |
79 */ |
79 */ |
80 static int statement_rowcount(lua_State *L) { |
80 static int statement_columns(lua_State *L) { |
81 luaL_error(L, DBI_ERR_NOT_IMPLEMENTED, DBD_DB2_STATEMENT, "columns"); |
81 statement_t *statement = (statement_t *)luaL_checkudata(L, 1, DBD_DB2_STATEMENT); |
82 |
82 |
83 return 0; |
83 int i; |
|
84 int d; |
|
85 |
|
86 SQLCHAR message[SQL_MAX_MESSAGE_LENGTH + 1]; |
|
87 SQLCHAR sqlstate[SQL_SQLSTATE_SIZE + 1]; |
|
88 SQLINTEGER sqlcode; |
|
89 SQLSMALLINT length; |
|
90 |
|
91 SQLRETURN rc = SQL_SUCCESS; |
|
92 |
|
93 if (!statement->resultset || !statement->bind) { |
|
94 lua_pushnil(L); |
|
95 return 1; |
|
96 } |
|
97 |
|
98 d = 1; |
|
99 lua_newtable(L); |
|
100 for (i = 0; i < statement->num_result_columns; i++) { |
|
101 const char *name = strlower(statement->resultset[i].name); |
|
102 LUA_PUSH_ARRAY_STRING(d, name); |
|
103 } |
|
104 |
|
105 return 1; |
84 } |
106 } |
85 |
107 |
86 /* |
108 /* |
87 * success = statement:execute(...) |
109 * success = statement:execute(...) |
88 */ |
110 */ |