KB-38947: Creating a Historic field that automatically increments its value

Question:

How can I create a Historic field that automatically increments its value, so that when there is a new record, it receives a sequential value?

Solution:

It is not possible to create this type of field in E3 Historics. However, you can create this field directly in the Database.

 

ACCESS
 
When using Access, you can add a field to the current table, as in the example below:

 

 

 

SQL SERVER

When using SQL Server, you can choose between two possibilities.

Via SQL Manager, create a field, access its properties, and set them up as Identity Column.

 

 

NOTE: this new field must necessarily be an Integer.

The other possibility, which also happens via SQL Manager, is to create the whole table via a Query, as seen in the example below:

 

ORACLE:

When using Oracle, you must create a trigger that increments the desired column at every new record.

In the example below, a new column called Column_ID is inserted into TestTable, and then the trigger is created:


ALTER TABLE
TESTTABLE
ADD
Column_ID number primary key;

create sequence seq_autonumber;

create trigger trg_autonumber
before insert on TESTTABLE
for each row
begin
select seq_autonumber.nextval into :new.Column_ID from dual;
end;

Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Leave a Reply

Your email address will not be published.Required fields are marked *