I need to change 1200 records only from one column in the table, generated the data in the generatedata, the rest of the columns should remain with the data, does anyone know a quick way to do this?
I need to change 1200 records only from one column in the table, generated the data in the generatedata, the rest of the columns should remain with the data, does anyone know a quick way to do this?
Where I work I already had situations like these and I resolved as follows:
BEGIN
--cursor com o select dos dados que irei realizar o update
for c_prod in (select a.id, a.produto FROM produtos a WHERE a.id IN (1,
23, 45, 46, 47, 49, 55 ...));
LOOP
--inserir todos os dados do cursor em uma tabela auxiliar
INSERT INTO produtos_temp VALUES (c_prod.id, c_prod.produto);
end loop;
--executando o update desejado
UPDATE produtos a SET a.status = 'atualizado'
SELECT b.* FROM produtos_temp b
WHERE a.id = b.id;
END;
In this way you capture the data you want to update inside a cursor, then in the implicit loop you insert the data of the retrieved id into the auxiliary table so you can keep a sort of backup of them, and then perform the data update whose id is in this auxiliary table. Remember that this requires some knowledge in PL / SQL.