I use sequences to generate keys for my tables. I am trying to use the reset_by clause in my hdbsequence file. It is my understanding that if you use the reset_by clause, it will reset the sequence using the SQL embedded in the hdbsequence file when the system restarts. In order to keep my seqeuences in line with the actual data already stored in my ID field(s), I need to make sure that the sequences do not reset to the starting point after a system restart. It appears that I might have a syntax issue or a permission issue on my SQL used in the hdbsequece reset_by because my sequences are all reset to the start_with number on system restart.
Here's the code for my hdbsequence file.
// Obs_Data_ID sequence
schema="MEDPORTAL";
start_with=200;
reset_by="SELECT IFNULL(MAX(\"ID\"), 0) + 200 FROM \"MEDPORTAL\".\"adsm.data::OBS_DATA\"";
depends_on_table="adsm.data::OBS_DATA";
If I run the clause in the SQL console (SELECT IFNULL(MAX(ID), 0) + 200 FROM "MEDPORTAL"."adsm.data::OBS_DATA";) , I get the 33,565 as the result,
But if I run the SQL to provide the next number in the sequence (select "MEDPORTAL"."adsm.data::Obs_Data_ID".NEXTVAL from dummy;) I get 201 as the result, indicating that the sequence has been reset to 200.
I am running the CAL version of Rev 80 on AWS (1.00.80.00.391861 (NewDB100_REL))
Did I do something wrong in the SQL in the reset_by clause or do I need to grant schema permissions to a user other than the SYSTEM user to get this to work?
Thank you,
Jim Giffin