On Tue, 1 Jan 2008 18:56:25 -0600, "Jay Sprenkle"
<[EMAIL PROTECTED]> wrote:

>> I fail to see why you can't simply include the PRIMARY KEY
>> (portable) or ROWID (not portable) in your SELECT statement if
>> you apparently need them later.
>
>I could, but that would involve changing a lot of existing code.
>If there was a way to get the row id of each column in the result set
>then it would be simple.
>I could extract the database,table,column, and row id of the changed
>column and do the update
>with a single line of sql.

I think I understand your original problem now.
SQLite (and every other engine I know of) assumes the
application knows the schema and the query, so it can act
accordingly.

Your solution would only work for non-aggregate queries.

>If I include the key of the row in my select(s) how does 
>the program determine which column was the key?
>I could always make it the first column, but that breaks down for joins.

Yes, it would also break for multi-column primary keys.
ROWID is more feasable in that respect.

>I would have to iterate through the columns in the result set and find
>what table each came from.

Yes.

>Then run a pragma or a select from sqlite_master table 
>to find the index column. That's going to be very slow.
>It's going to add an extra database operation for every 
>table in the query. This would more than double the 
>time required for each query.

PRAGMA table_info(); is not very expensive.
You only have to execute it after open and schema changes.

>If the engine within sqlite recorded the row id as it 
>fetched each column it would be trivial and would 
>prevent me from having to query the database again. 
>If it's not present in the current code 

I know what the answer will be: "This is not a planned feature.
Adding this would slow down the code for vast majority of people
who do not need it." 

Ref: 
Date: Sat, 14 Apr 2007 12:24:50 +0000
From: [EMAIL PROTECTED]
Message-ID:
<[EMAIL PROTECTED]>
In-Reply-To: <[EMAIL PROTECTED]>
References: <[EMAIL PROTECTED]>
Subject: Re: [sqlite] sqlite3_rowid

>I will probably just do it myself. I try not to reinvent 
>the wheel where possible. ;)

Good luck then ;)
-- 
  (  Kees Nuyt
  )
c[_]

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to