A
A
Akakiy18802021-05-25 08:56:41
PostgreSQL
Akakiy1880, 2021-05-25 08:56:41

How to create a trigger that after adding a record to 1 table will create n number of records in another table?

The trigger should work as follows:
1) A record is made to a table (table1) of this type:
SerialNumber: 123456, DeviceCount: N(n ≥ 1);
2) Should work AFTER TRIGGER which in the table (table2) will create N-number of records specified in DeviceCount. Example:
-------------- INSERT Table1 --------------
SerialNumber: 123456, DeviceCount: 3;
---------- Trigger INSERT Table2 --------
SerialNumber: 123456, DeviceNumber: 1;
SerialNumber: 123456, DeviceNumber: 2;
SerialNumber: 123456, DeviceNumber: 3;
------------END---------------------

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question