Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 1 to 6 of 6 total |
'AutoInc' field?? |
Wed, Jun 20 2018 10:58 PM | Permanent Link |
Ian Branch | Hi Team,
OK. Caught on this one. In my conversion is and Autoinc field, JobNo, in ADS which became a Generated field in EDB. I set the seed value to 1722, the last record # in the existing DB and the Increment is 1. Imagine my surprise when 1 was the first record JobNo is 1. ?? A search in the edb help doesn't return anything for 'generated'. What have I missed please? Regards, Ian |
Wed, Jun 20 2018 11:31 PM | Permanent Link |
Raul Team Elevate | On 6/20/2018 10:58 PM, Ian Branch wrote:
> Hi Team, > OK. Caught on this one. > In my conversion is and Autoinc field, JobNo, in ADS which became a Generated field in EDB. > I set the seed value to 1722, the last record # in the existing DB and the Increment is 1. > Imagine my surprise when 1 was the first record JobNo is 1. ?? > A search in the edb help doesn't return anything for 'generated'. > What have I missed please? How is it defined exactly ? .... GENERATED ALWAYS AS IDENTITY (START WITH 1722,INCREMENT BY 1) ... or something else ? Raul |
Thu, Jun 21 2018 1:11 AM | Permanent Link |
Ian Branch | Hi Raul,
That's what I thought I had done. See attached. Regards, Ian Attachments: Screenshot_1.jpg |
Thu, Jun 21 2018 4:31 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Ian
Another old post. Might help your understanding -------------------------------------------------------------------------------------------------------------------- Lucian, << The thing is I am importing some DBISAM tables where RecRef is autoinc. It is supposed to be autoinc also in EDB, however for the import, I create the table(s) with RecRef INTEGER and only when I'm done with the import I am restructuring the tables. What exactly am I supposed to do if I want to obtain an autoinc column with a new lastautoinc value? From your answer I understand I have to call twice ALTER TABLE, once to get an autoinc column and second to reset the seed? If this is true, I understand it's a bug and it will get fixed, right? >> Yes, it is true, and no, it is not a bug, for the reasons that I've already outlined. The important thing to remember is: Seed value in the catalog <> Next seed value in the table file The first controls what seed value is used for the IDENTITY column when a new table file is created on disk, and the second controls which value is assigned next for the IDENTITY column. In the case of a newly-created table, the two are always the same. For existing tables, the two can be completely different. For example, in your case you will want to use the RESTART WITH clause to set the next IDENTITY column value for the existing table files. However, you *don't'* want EDB to create a new table file that starts with a seed value that matches that value - you would want the catalog to continue to have the seed value set to 0 for any newly-created table files. Do you see the difference ? -- Tim Young Elevate Software www.elevatesoft.com -------------------------------------------------------------------------------------------------------------------- Roy Lambert |
Thu, Jun 21 2018 4:45 AM | Permanent Link |
Ian Branch | HI Guys,
Actually found it here... "http://www.elevatesoft.com/manual?action=viewtopic&id=edb2sql&topic=ALTER_TABLE [ALTER [COLUMN] <ColumnName> <ColumnAlterOptions>|AS <ColumnDefinition> and <ColumnAlterOptions> = [SET <DefaultExpression>|DROP DEFAULT|DESCRIPTION <Description>| MOVE TO <ColumnPos>|RESTART WITH <SeedValue>]" All good now. Regards & Tks to both of you, Ian |
Thu, Jun 21 2018 7:22 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Ian
Next hint - in EDBManager click on the table and look at the bottom pane - it contains the SQL that is used to create the table you then see just what is being done. My guess is that here you're converting a table so its not new and from an old post ---------------------------------------------------------------------------------- Michael, As Uli indicated, you need to use the RESTART WITH clause to reset the *existing value*: ALTER TABLE "MyTable" ALTER COLUMN ID RESTART WITH 1 Just altering the original column definition will not do it, since that only specifies what the seed and increment values should be for a new, empty table. -- Tim Young ------------------------------------------------------------------------------------------------------------ Roy Lambert |
This web page was last updated on Tuesday, May 7, 2024 at 06:25 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |