[Kexi-devel] drv_lastInsertRowID()
Jaroslaw Staniek
js at iidea.pl
Fri Aug 8 20:58:54 CEST 2008
Hîthwen Fëadûr said the following, On 2008-08-08 20:27:
> On Fri, Aug 8, 2008 at 5:03 PM, Jaroslaw Staniek <js at iidea.pl> wrote:
>
>> Hîthwen Fëadûr said the following, On 2008-08-08 16:01:
>>
>>> We need to be able to accurately identify the row we've just inserted. How
>>>> does Oracle solve this? If we know, we can add appropriate support.
>>>>
>>>>
>>> Here is an extract from oracle website:
>>>
>>> "What is your definition of the "last record"? If it is the last record
>>> inserted, there is no way to get that unless you have some field you
>>> maintain to allow you to find the last record inserted."
>>>
>>>
>>> So Oracle doesnt solve this, Oracle thinks you are supposed to know what
>>> have just inserted.
>>> My partner, Migue has been experimenting with timestamps. When you insert
>>> something on a table a trigger he'd created saves on an auxiliary table
>>> its
>>> rowid and the timestamp, then you can ask for the newest timestamp to get
>>> the corresponding rowid (which can be put into a QVariant) the problem is
>>> we
>>> would need to create a trigger like this for every single table you
>>> create.
>>>
>>> Other option could be adding a timestamp column to every table.
>>>
>> Rowid usage in Kexi is about using autonumbers.
>> So couldn't you look at sequences? Set up a sequence and get it's value,
>> then insert the new row. This is atomic, and of course is already done e.g.
>> in sqlite, just implicitly.
>>
>
> In a new column?
> timestamps are atomic too "systimestamp" and can be cosidered as a numeric
> value.
> Now I have a sequence for every kexi__% table primary key but I can use the
> same for all, the problem is wich field use in beh->ROW_ID_FIELD_NAME .
[Let's use (obsolete but working for now) kexi-devel at kde.org list. I am
responding there.]
How about using one sequence per table? (otherwise, one commos sequence would
not create values starting from 1, what's exactly what users expect sometimes.
beh->ROW_ID_FIELD_NAME logic is not compatible with our case, I am afraid, so
unless I have missed something, KexiDB has to be altered: we need special case
in the code where sequence is used. If you can provide one, we could refactor
it later using new DriverBehaviour flag.
How do you like this?
--
regards / pozdrawiam, Jaroslaw Staniek
Sponsored by OpenOffice Polska (http://www.openoffice.com.pl/en) to work on
Kexi & KOffice (http://www.kexi.pl/en, http://www.koffice.org/kexi)
KDE Libraries for MS Windows (http://windows.kde.org)
More information about the Kexi-devel
mailing list