I have two tables, the Impressoras
table is where the equipment data, such as model, assets, etc., is stored. And I have the Impressora Local
table where the location where the printer is located is stored, the client where it is currently allocated.
My Impressoras
table has a codigoempresa
column where when the printer is registered the initial company is placed where it goes, and in that table Impressora Local
a history is stored from where the printer passed, so in that table Impressora Local
the company (company code) is always updated, but in the Impressoras
table.
I was able to resolve this issue by keeping this data updated in the Impressora
table also by creating a Funtion in the database that whenever a record is changed or added to the% updated automatically. This works normally.
But the first time, I will have to update this data in the arm, so I tried to do an Update command as follows:
UPDATE public.impressoras
SET codigoempresa=(select codigoempresa from public.impressoralocal)
WHERE public.impressoras.codigo = (select codigoimpressora from public.impressoralocal);
But the following error is returned to me:
ERROR: more than one row returned by a subquery used as an expression
********** Error **********
ERROR: more than one row returned by a subquery used as an expression
SQL state: 21000
My question is, is it possible to update this table Impressora Local
, or will I be forced to update row by line
Note: This bank is a legacy for this reason I am having to adopt such a measure
Printers table:
LocaPrinterTable: