Support Topics Documentation Slack YouTube Blog

How to write stored procedure to insert data from one table to another?


(ramesh bs) #1

Hi,
How to insert data from one table to another table?. Lets take i have table A & table B.
A table has column ID, Name, title, Age, Description. B table has column called ID, Name.
If i insert data to table A column Name, the Name field should get automatically insert to Table B. How to achieve?
Thanks


(Mark Piller) #2
  1. use API to load data from table A

  2. use API to write data to table B


(Vitaly Vengrov) #3

Hi.

It’s called Custom Business Logic.
You need to write a custom event handler for the afterCreate event.

Backendless.enablePromises();
Backendless.ServerCode.Persistence.afterCreate('TableA', function(req, res) {
    return Backendless.Data.of('TableB').save({ name: req.item.name });
}, true);

(ramesh bs) #4

Thank you, i will check and let you know. Thanks for the support