Skip to content
Advertisement

How to create a trigger which will auto create sequence ID

I have been trying to implement the logic. But as only basic knowledge on SQL.

I have a below following table

I have following data in it

I need to write some trigger as soon as the insert is performed depending upon createddate a sequence should be automatically inserted to sequence column for respective record.

Expected output :

The sequence will be like YYYYMMDD_HHMMSS it comes from createddate as it is set to date. I will insert first 4 columns and last column data should be inserted base on createddate column by trigger itself.

This 4 column data is populated from my Oracle APEX web application using form

Advertisement

Answer

You don’t have a sequence column as you can still have non-unique values if two rows have the same createddate. Instead, you just have a formatted date. In this case, just convert the column to a virtual column:

If you do want a sequence value (where all the values are unique) then, from Oracle 12, you can use an identity column:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement