lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Please help,

I'm tryng  to write simple Oracle (OCI8) API for Lua ...
I have to collect keys and values run query and then
put result back to the table.

I can add new value to table before iterate it,
but code below doesn't work where is my mistake ?

Thank you!


 /* table is in the stack at index `t' */
    lua_pushnil(L);  /* first key */
    while (lua_next(L, t) != 0)
    {
         /* `key' is at index -2 and `value' at index -1 */
        const char *key = lua_tostring(L, -2);
        const char *val = lua_tostring(L, -1);
        cerr << "Key: " << key << " Val:" << val << endl;
        lua_pushstring(L,key);
    }

    loa_settop(L,t); 	
    lua_pushstring(L, "RRN");
    lua_pushstring(L, "abcd");
    lua_settable(L,-3);


--
Dmitry Samersoff
dms@samersoff.net, http://devnull.wplus.net
ICQ: 3161705
* There will come soft rains ...