0
Good morning guys. Can you help me? I have previously researched elsewhere but could not find a viable solution.
I need to change the data in the table below according to the new information.
Data imported to the bank:
TABLE 1
COD | NOMEFUN | FUNCAO | SALARIO | DEPARTAMENTO | CENTRODECUSTO
-----+------------+-----------+-----------+--------------+----------
001 | THIAGO | AUXILIAR | 2.000 | SOCIETARIO | 09589
002 | LARISSA | ASSISTENTE| 1.500 | CONTABIL | 02222
How should it come out:
TABLE 1
COD | NOMEFUNC | FUNCAO | SALARIO | DEPARTAMENTO | CENTRODECUSTO
-----+------------+-----------+-----------+---------------+----------
001 | THIAGO | AUXILIAR | 2.000 | SOCIETARIO | 20.000.002
002 | LARISSA | ASSISTENTE| 1.500 | CONTABIL | 30.000.001
I have a spreadsheet referencing the cost centers for the new cost centers. I created another table with this information in the database:
Table 2
ID | OLD.CENTRODECUSTO | NEW.CENTRODECUSTO
---+-------------------+-------------------
1 | 09589 | 20.000.002
2 | 02222 | 30.000.001
How could I create a rule in the database that changes the value of CENTRODECOST in Table 1 by the column values NEW.CENTRODECOST of Table 2?
I believe I am going the wrong way and there must be a simpler way to update these values with a DE_PARA. But I can’t find that way.
I believe that instead of a rule (Rule) you should create a trigger (Trigger) that is triggered before an INSERT or UPDATE.
– anonimo
If you want to run an update just run an UPDATE with an INNER JOIN between the two tables and modifying the field for the contents of the table2.
– anonimo