lua-users home
lua-l archive

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


I’m trying to dynamically bind parameters based on a table being passed to my C function.
 
The Lua side looks like
 
query = “select * from foo where key = :key and foo between :lbound and :ubound”
parms = { key = ‘JAN03’, lbound = 0, ubound = 30}
 
exec(query, parms);
 
And the library function looks something like
 
// C library
nParms = lua_istable(L,2) ? lua_objlen(L,2) : 0;
 
for (idx = 1; idx <= nParms; ++idx) {
  int type = // how do I get the type of the parameter?
 
  switch (type) {
  case LUA_TNUMBER:
     bindNumber(nameOfParameter, valueOfParameter);
       // how do I get the name of the parameter?
       // how do I get the value of the parameter?
 
I’ve been going through the PIL and looking at the source of luasql and luasqlite, but I don’t see anything like what I’m trying to. I’d appreciate being pointed in the right direction.
 
Thanks,
Mike