Re: [sqlite] Possible to use field names instead of index offsets in queries?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 danjenkins wrote: > Hi, > Without using a wrapper, is there a simple way of accessing a query's > results using field/column names instead of index offsets? You are already using a wrapper - sqlite3_get_table. To solve this problem you will need to use the "normal" SQLite api which involves calling sqlite3_prepare, sqlite3_step, sqlite3_column_XXX etc (Alternatively copy the code for sqlite3_get_table and make it return one more parameter - a column name list). You can find out the column name using http://sqlite.org/c3ref/column_name.html and how many columns there are using http://sqlite.org/c3ref/column_count.html You'll need to use the routines as appropriate to your situation. For example if you are only looking at one row then you can have a helper routine that just calls column_name on each column until the match is found. If your result set is many rows then you'll want to build some sort of lookup table to cache the answers. You may find that most convenient to do after calling prepare. Roger -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFIOgPFmOOfHg372QQRAtgRAKDJPfS4Js1uchPEWUASQ2HpE4+0LwCgn8PA WhgrvaDj1Uexxtz2EpWhIbo= =2PRC -END PGP SIGNATURE- ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Checking for open transactions attach/detach database and Trigger behaviour with attached databases
What is the appropriate etiquette if I don't receive a solution/answer in ?? days -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of MoDementia Sent: Friday, 23 May 2008 12:32 PM To: sqlite-users@sqlite.org Subject: [sqlite] Checking for open transactions attach/detach database and Trigger behaviour with attached databases Hi, My first submission 1 Problem and 1 question J My problem I have 2 processes that are causing problems after commits/locks 1. Copy main database to copydatabase using filesystem object How to determine when copydatabase is ready for attach? Attach copydatabase <-- need to retry a few times Delete some rows Detach copydatabase 2. Attach copydatabase Begin transaction Update main database from data in copydatabase Commit How to determine when copydatabase is ready for detach? Detach copydatabase <-- Need to retry many times The main application traps the errors before my MS VBScript can use ON ERROR so I need to test for the error before it occurs. Hope There is an easy solution My question (This seems to be answered as I didn't lose all the rows in the main database) Are triggers restricted to their respective databases? Main Database Table Name = Songs Attached Database Table Name = Songs Both have triggers CREATE TRIGGER delete_songs DELETE ON Songs BEGIN ... END Will these act only their respective tables or will they both act on the main database? Regards Terry Ganly __ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] Possible to use field names instead of index offsets in queries?
Hi, Without using a wrapper, is there a simple way of accessing a query's results using field/column names instead of index offsets? For example, instead of: strcpy(DeptCodeStructure[i-1].DeptName, result[i*ncols+1]); Something more like: strcpy(DeptCodeStructure[i-1].DeptName, fieldname("DeptName",result,i,ncols); How does everyone else handle this kind of thing? Many thanks! Dan For context, below I've included my typical routine. sqlite3 *pDB = NULL; // database pointer FILE* fp = fopen("dept.sql","a+"); sqlite3_open("dept.sql",); char* sql = "SELECT * FROM Dept;"; char **result = 0; int nrows, ncols; if(pDB != NULL){ sqlite3_get_table(pDB,sqlNULL); for(i = 1; i <= nrowss;i++){ strcpy(DeptCodeStructure[i-1].DeptName, result[i*ncols+1]); DeptCodeStructure[i-1].RateCodeToUse = atoi(result[i*ncols+2]); } sqlite3_free_table(result); } sqlite3_close(pDB); fclose(fp); -- View this message in context: http://www.nabble.com/Possible-to-use-field-names-instead-of-index-offsets-in-queries--tp17461475p17461475.html Sent from the SQLite mailing list archive at Nabble.com. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] Where I can get sqlite 3.2.2 ?
Hi, all. I trying to get sqlite 3.2.2 source code these days. I've searched web site But, I cann't get. Is there any web site I can get sqlite 3.2.2? -hyun- ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users