1 Reply Latest reply on Dec 17, 2011 10:31 AM by Sorbsbuster

    Script to reset primary key Next Value number?

    MikeF

      Title

      Script to reset primary key Next Value number?

      Post

       

      Is there a script that will reset the Primary Key in a table?

      Example ...

      Have a delete button on a layout, which will delete an unused record from its source table.  Once that's done, would like a script that looks at the maximum __kp_MyPrimaryKeyField number and adds 1 to its Serial Number | Next Value in the Auto Enter section.

      Can this be done?

      Thanks,

        Mike

        • 1. Re: Script to reset primary key Next Value number?
          Sorbsbuster

          You can link the table to itself with a Cartesina self-join, and then use the script step Set Next Serial Value to update the serial number to the current Max + 1.

          However: numbers are cheap.  FM can look after all the serials and ID links they are used for.  And it doesn't get upset about series not being complete.  Why would you want to re-use the number and run the risk that somewhere in the child records that were created, that Parent ID was used, and now when you create that ID again the new record will have instant children that are NOT connected to it.  Or 'are, but shouldn't be'.