DelphiFAQ Home Search:

Fixing a broken generator (InterBase)

 

commentsThis article has not been rated yet. After reading, feel free to leave comments and rate it.

Recently I got unique key violations during insert attempts on a piece of code that used to work (what can go bad, will go bad). I found that the offending field - was actually created by a generator. For some reason the generator returned values that where already in the database.

Question:

- how can I display the current value of the generator?
- how can I adjust the value of the generator?

Answer:

See the example (table name is SD_LOAD, generator name is GEN_SD_LOAD).

Note:

You cannot modify the value of the generator inside of a trigger or stored procedure. You only can call the gen_id() function to increment the value in a generator. The SET GENERATOR command will only work outside of a stored procedure or trigger.

SELECT DISTINCT(GEN_ID(gen_sd_load, 0)) FROM sd_load

SET GENERATOR gen_sd_load TO 2021819
You don't like the formatting? Check out SourceCoder then!
Content-type: text/html

Comments:

2012-11-12, 04:02:22
coach001 from United States  
2012-11-18, 21:27:54
nhnhnh  
2017-01-10, 14:44:45
anonymous from Indonesia  
JIKA ANDA BUTUH ANGKA TOGEL GAIB (_SGP,HKG,MLYS,SYD,THLND,TAIWAN_)
YANG DI JAMIN 100% TEMBUS SILAHKAN
Call/Sms Di No_o82_319_2o8_865_ AKI NUGROHO
Insya Allah Beliau Akan Siap Membantu Menyelesaikan Smua Masalah Anda,.
(_..KUNCI KESUKSESAN..._)
1. Pikiran Yang Positif,
2. Keyakinan Yang Bulat
3. Percaya Bahwa Kita Akan Berhasil
.

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: