Re: [sqlite] can column name come from a table?

2013-07-29 Thread Darren Duncan
On 2013.07.29 6:08 PM, Roman Fleysher wrote: Thank you, SQLiters, for confirmation. Yes, the set up is unusual. I have a table which essentially maps existing column names to the names the users want to see. columnRenameTable(table, column, showAS) The goal was to use this mapping for

Re: [sqlite] Integrity Check Failure Handling

2013-07-29 Thread techi eth
Many Thanks for comment. I shall agree with your view. >Could be many rows in many tables were corrupted. If SQLite3 knew exactly what had >been corrupted it could just go and fix it without even needing your help. Here i am thinking of getting details about table & infected row,SQLite3

Re: [sqlite] can column name come from a table?

2013-07-29 Thread Jay A. Kreibich
> I was going to say, try using a SQL prepared statement. > > For example, in Postgres you can write something like this: > > execute format( 'SELECT %I FROM table that has that columnName', >(SELECT columnName FROM columnNameTable WHERE condition how to > select limit 1) ); > > But I

Re: [sqlite] can column name come from a table?

2013-07-29 Thread Roman Fleysher
Thank you, SQLiters, for confirmation. Yes, the set up is unusual. I have a table which essentially maps existing column names to the names the users want to see. columnRenameTable(table, column, showAS) The goal was to use this mapping for SELECT table.column AS showAS FROM table; when

Re: [sqlite] can column name come from a table?

2013-07-29 Thread Darren Duncan
On 2013.07.29 5:32 PM, Roman Fleysher wrote: Dear SQLiters, I think the answer to my question is "NO", but may be I missed something... Can column name come from a table, i.e. from another select? Example: SELECT (SELECT columnName FROM columnNameTable WHERE condition how to select limit 1)

Re: [sqlite] can column name come from a table?

2013-07-29 Thread Greg Jarzab
You should be able to craft the query outside of the database and then treat it like a normal query. You have to be very careful about doing this, and it generally isn't a good idea. If you do take this approach, make sure that you properly sanitize the column names, especially if they are

Re: [sqlite] can column name come from a table?

2013-07-29 Thread Igor Tandetnik
On 7/29/2013 8:32 PM, Roman Fleysher wrote: I think the answer to my question is "NO", but may be I missed something... Can column name come from a table, i.e. from another select? Example: SELECT (SELECT columnName FROM columnNameTable WHERE condition how to select limit 1) FROM table which

[sqlite] can column name come from a table?

2013-07-29 Thread Roman Fleysher
Dear SQLiters, I think the answer to my question is "NO", but may be I missed something... Can column name come from a table, i.e. from another select? Example: SELECT (SELECT columnName FROM columnNameTable WHERE condition how to select limit 1) FROM table which has that columnName; Or this

Re: [sqlite] Comparing two tables column by column

2013-07-29 Thread Fehmi Noyan ISI
The approach I am using to compare tableA_old and tableA_new is; typedef struct container_t { // a structure to pass parameters into callbacks } container; static int callback_2(){     // compare two values in the resulting table if they are different     // write them into a resulting file }

Re: [sqlite] Comparing two tables column by column

2013-07-29 Thread Stadin, Benjamin
If you like ruby, I have another idea to get you going (maybe without needing to write much code): - Use a registered function to SQLite to create MD5 or SHA1 keys for rows in the table. Here is a ruby snippet that registers a SHA1 function:

Re: [sqlite] Comparing two tables column by column

2013-07-29 Thread Fehmi Noyan ISI
EXCEPT query gave the different rows in tables, but what I am after is the different values for existing records. The column names are exactly the same, however the number of rows may differ (with most of the records are the same). From: Simon Slavin

Re: [sqlite] Query optimization: Checking for existence before performing action

2013-07-29 Thread Keith Medcalf
INSERT OR IGNORE INTO table (word, confidence) VALUES (:word, :initialconfidence - :confidenceincrement); UPDATE table SET confidence=confidence+:confidenceincrement WHERE word=:word; Still two statements but does not require application "help" and the rowid is stable ... Assuming that

Re: [sqlite] Query optimization: Checking for existence before performing action

2013-07-29 Thread Simon Davies
On 29 July 2013 12:57, Navaneeth.K.N wrote: > Hello, > > I am trying to optimize the SQL calls that my application makes. I > have a scenario where words are inserted into a table. Now each word > will have a column called "confidence". There is a unique primary key > on

Re: [sqlite] Query optimization: Checking for existence before performing action

2013-07-29 Thread Simon Slavin
On 29 Jul 2013, at 12:57pm, Navaneeth.K.N wrote: > When inserting a word, first I check if the words exists by performing > a "select" query. If it exists, I fire an update query to increment > the confidence for that word. If word is not available, I fire an > insert

[sqlite] Database Locked Error

2013-07-29 Thread Ajazur Rahaman
Dear All, Can you please help me in solving below error.When I am compiling sqlite 3.6.12 on UCLINUX. Error : database locked or Can you please assist me in executing sqlite 3.6.12 on UCLINUX. -- Thanks & Regards, Mohammed Aijas +91-9642933393 ___

[sqlite] Query optimization: Checking for existence before performing action

2013-07-29 Thread Navaneeth.K.N
Hello, I am trying to optimize the SQL calls that my application makes. I have a scenario where words are inserted into a table. Now each word will have a column called "confidence". There is a unique primary key on "word". When inserting a word, first I check if the words exists by performing a

Re: [sqlite] Comparing two tables column by column

2013-07-29 Thread Simon Slavin
On 29 Jul 2013, at 12:36pm, Fabian Klebert wrote: > Wouldn't > > SELECT * FROM table1 > EXCEPT > SELECT * FROM table2 > > solve this problem? > I think it does for the example provided. Not sure if it would work in > real-world environment. There are two

Re: [sqlite] Comparing two tables column by column

2013-07-29 Thread Fabian Klebert
Wouldn't SELECT * FROM table1 EXCEPT SELECT * FROM table2 solve this problem? I think it does for the example provided. Not sure if it would work in real-world environment. -Ursprüngliche Nachricht- Von: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] Im

Re: [sqlite] Comparing two tables column by column

2013-07-29 Thread Stephen Chrzanowski
To be fair to me, the example had the same column names. If the two tables have the same column names, then having a bit of extra code to tag on the column name + "_1" might have worked. As my first reply answered, untested. ;) On Mon, Jul 29, 2013 at 6:46 AM, Clemens Ladisch

Re: [sqlite] Integrity Check Failure Handling

2013-07-29 Thread Simon Slavin
On 29 Jul 2013, at 10:21am, techi eth wrote: > Reference from below link gave me hint about integrity check failure case > recovery by Export/Import of database. > > Please let me know is this is correct & way to handle integrity failure > check. This is not the correct

Re: [sqlite] Comparing two tables column by column

2013-07-29 Thread Clemens Ladisch
Simon Slavin wrote: > On 29 Jul 2013, at 4:03am, Fehmi Noyan ISI wrote: >> One point I forgot to mention; the number of columns is unknown. > > There is no way in SQL to say "Give me the contents of all the columns of a > row of table in an unambiguous format.". Well, just

Re: [sqlite] Comparing two tables column by column

2013-07-29 Thread fnoyanisi
Yes, it turned out that achieving the goal with C code is much simpler than using SQL statements (I also take my limited sql knowledge into account) Now, I'll have two sqlite3_exec() calls, one of which is invoked by first call's callback function. This led having some natsy C structs around to

Re: [sqlite] Comparing two tables column by column

2013-07-29 Thread Simon Slavin
On 29 Jul 2013, at 4:03am, Fehmi Noyan ISI wrote: > One point I forgot to mention; the number of columns is unknown. There is no way in SQL to say "Give me the contents of all the columns of a row of table in an unambiguous format.". It would be possible to write the

[sqlite] Integrity Check Failure Handling

2013-07-29 Thread techi eth
Reference from below link gave me hint about integrity check failure case recovery by Export/Import of database. Please let me know is this is correct & way to handle integrity failure check. http://blog.niklasottosson.com/?p=852