Retrieve table name from query result (sql)

    May 01 2015 | 4:16 pm
    I'm performing a database query via the db_query() function; I can perfectly obtain results and navigate through them, however I can't find an easy way to obtain the table name to which each result item belong. Am I overlooking something simple?
    Thanks, Daniele

    • May 04 2015 | 9:31 pm
    • May 10 2015 | 3:02 pm
      Hi Tim, thanks for answering so quickly and sorry for my huge delay. Thanks for the link. I understand that I can query the table names from the sqlite_master, however I still don't see how I can retrieve the table name from the query result. I'm probably missing something very obvious. I'm just doing
      err = db_query(x->d_db, &result, query_buffer); long numrecords = db_result_numrecords(result); for (i=0; i
      And then I would like to know which is the table whence the results come from. Is there any way I can do this, assuming I have no control on the query_buffer?
      Thanks, Daniele
    • May 11 2015 | 6:33 pm
      I see... I did not fully understand that you were wanting the table for an unknown query.
      It seems like there could be some SQLite hack, but if so I do not know it off the top of my head. Or perhaps it is possible to parse the query with a regular expression or other parser to ascertain the information from the query itself?
      Sorry to be of little help in this regard...
    • May 12 2015 | 11:28 am
      Thanks, Tim!
    • May 13 2015 | 9:11 pm
      Hi Tim,
      on the other hand maybe you can help me out with this other issue: I have my object opening an SQLite database named, say, x->d_name = "foo", via db_close(&x->d_db); db_open(x->d_name, NULL, &x->d_db);
      Then I have another copy of the object which I need to share the same database. However, the database allocated by db_open (called from my other object) is a different one, even if x->d_name is the same one. Am it correct? How can I share the database across different instances of my object? Am I supposed to put the x->d_db structure inside the l_thing field of the "foo" symbol?
      Thanks a lot, Daniele