This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Unique progressive autoincrement column

Hi,

there is any way to create an autoincrement and unique value column on  a table that is not an UID?

I need a unique progressive autoincrement number on the PersonWantsOrgTable.

 I thought to create it from script but I don’t know how to access synchronously to  value of a table to not to get duplicate values.

 

Thanks Michele

  • Hi,

    This can be achieved using DialogNextID.

    Take a look at the table in ObjectBrowser ..... you will see that it is used to allocate numbers to shopping cart orders.

    You can add your own custom object with a relevant Ident_DialogNextID and then use a code snippet like this to get the next value:

    '~~> Calculation of a unique auto incremented number
    Dim nextid As ISingleDbObject
    Dim intOrderNumber As Integer = 0

    nextid = Connection.CreateSingle("DialogNextID")
    ' we can have more than one of such counters
    ' define the identifier of your counter here
    nextid("Ident_DialogNextID").NewValue = "<your Ident_DialogNextID>"

    intOrderNumber = CInt(nextid.Custom.CallMethod("GetNextID"))

    Value = intOrderNumber

    You could also place the call to GetNextID in a script so that it can be called from anywhere.

    By default, NextNumber, will start at 0. If you need it to start from some other value use pure SQL to update it.

    HTH, Barry.