Subject | Re: [firebird-support] Use generators instead of a next ID table. |
---|---|
Author | Martijn Tonies |
Post date | 2008-04-04T16:08:58Z |
Jonas,
AND ID = <old-id-value>
If this results in 0 records updated, it means someone else updated the
record, this will make sure that concurrent updates know of eachother.
instead of doing direct updates? This way, you can easily switch to a
Generator instead of a table. There's no way of knowing a Generator
is used (like a table trigger), so they'll never be update to date unless
you create a trigger on each table that will automatically update your
NEXTIDs table with the last number inserted.
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com
> I am currently working on a Java application that uses a Interbase6I would add this to the UPDATE statement:
> database via Firebird 2.0. Legacy applications in Delphi are still
> using the same database via Interbase
>
> The old applications used a table for getting the next id for other
> tables i.e
>
> SELECT ID FROM NEXTIDS WHERE TABLENAME = 'xyz'
> UPDATE NEXTIDS SET ID = ID+1 WHERE TABLENAME = 'xyz'
AND ID = <old-id-value>
If this results in 0 records updated, it means someone else updated the
record, this will make sure that concurrent updates know of eachother.
>Have you thought of wrapping the getting of IDs into a Stored Procedure
> TABLE NEXTIDS(
> ID Integer NOT NULL,
> TABLENAME Varchar(31) CHARACTER SET NONE NOT NULL,
> ROW_FLAG Integer DEFAULT 0 NOT NULL
> )
>
> Is it somehow possible for me to use generators for the new
> application but still keep the nextids table up-to-date. This so
> legacy applications still can use the same database without need to
> change any code?
instead of doing direct updates? This way, you can easily switch to a
Generator instead of a table. There's no way of knowing a Generator
is used (like a table trigger), so they'll never be update to date unless
you create a trigger on each table that will automatically update your
NEXTIDs table with the last number inserted.
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com