/* Creates a cursor table and leave it on the top of the stack.  */
static int create_cursor(lua_State *L, int o, conn_data *conn, const SQLHSTMT hstmt, const SQLSMALLINT numcols)
/* Creates a cursor table and leave it on the top of the stack.  */
static int create_cursor(lua_State *L, int o, conn_data *conn, const SQLHSTMT hstmt, const SQLSMALLINT numcols)
{
    cur_data *cur = (cur_data *) lua_newuserdata(L, sizeof(cur_data));
	luasql_setmeta (L, LUASQL_CURSOR_ODBC);
	conn->cur_counter++;
	cur->closed = 0;
	cur->conn = LUA_NOREF;
    cur->numcols = numcols;
	cur->colnames = LUA_NOREF;
	cur->coltypes = LUA_NOREF;
    cur->hstmt = hstmt;
	lua_pushvalue (L, o);
    cur->conn = luaL_ref (L, LUA_REGISTRYINDEX);
	create_colinfo (L, cur);
    return 1;
}