Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE
Sergeevich Absent Member.
Absent Member.
369 views

Unique id by insert

Jump to solution

Hello again.

I create new table (testtable2) with Unique id field.

Expecting insert in this field unique value by doind doInsert().

 

But problem is when I try 

 

 

var nRtn = new SCDatum;
var nNumber = new SCDatum;
system.functions.rtecall("getnumber", nRtn, nNumber, "testtable2");
var nextNumber = nNumber.getText();

 

I achieve empty string.

Is there any other method to write unique id in this field, like autoincrement ?

0 Likes
1 Solution

Accepted Solutions
Highlighted
Absent Member.. John Stagaman Absent Member..
Absent Member..

Re: Unique id by insert

Jump to solution
Database Manager.
Table name: counters
They're pretty self-explanatory. As each new record is added, they increment by one.

For efficiency, you can also issue counters in batches (e.g. 20 at a time) so that the program call less frequent. This is especially advised in a horizontally-scaled environment. Each app server will get its own batch and run through them, note that this means that the numbers will not be sequential as re ores are added.
--app server one gets counter batch 101-120
--app server two gets counter batch 121-140
--app server three gets counter batch 141-160.
Records created one after the other could be numbered as 121, 101, 102, 141, 103, 122, etc. as each app server consumes the numbers allocated.
Batching is also available for the sequential number records and is also recommended, especially in a horizontally scaled system.
Additional information is available in the SM Help. Some out of box tables that use counter records to generate their ID are: macros, AlertLog, ApprovalLog, dataModEvent, SLA, slo, etc.
----------------------------------------------------
Kudos - what, where, how, and why
Want Good Answers? Ask Good Questions...
3 Replies
Absent Member.. John Stagaman Absent Member..
Absent Member..

Re: Unique id by insert

Jump to solution

You could use a counter record instead of a sequential number record to set the ID on add.

 

Once you configure the counter (specifying the table and ID field), the counter will increment automatically at record add and populate the field.

----------------------------------------------------
Kudos - what, where, how, and why
Want Good Answers? Ask Good Questions...
0 Likes
Sergeevich Absent Member.
Absent Member.

Re: Unique id by insert

Jump to solution

Can you please explain more about what counter record? I have sm9.34.

0 Likes
Highlighted
Absent Member.. John Stagaman Absent Member..
Absent Member..

Re: Unique id by insert

Jump to solution
Database Manager.
Table name: counters
They're pretty self-explanatory. As each new record is added, they increment by one.

For efficiency, you can also issue counters in batches (e.g. 20 at a time) so that the program call less frequent. This is especially advised in a horizontally-scaled environment. Each app server will get its own batch and run through them, note that this means that the numbers will not be sequential as re ores are added.
--app server one gets counter batch 101-120
--app server two gets counter batch 121-140
--app server three gets counter batch 141-160.
Records created one after the other could be numbered as 121, 101, 102, 141, 103, 122, etc. as each app server consumes the numbers allocated.
Batching is also available for the sequential number records and is also recommended, especially in a horizontally scaled system.
Additional information is available in the SM Help. Some out of box tables that use counter records to generate their ID are: macros, AlertLog, ApprovalLog, dataModEvent, SLA, slo, etc.
----------------------------------------------------
Kudos - what, where, how, and why
Want Good Answers? Ask Good Questions...
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.