How could I emulate the following SQL Server query in Oracle?
declare @index = 4
update tablex set
id_product = @index
, @index = @index 1
where Id_Person = 4037
In SQL Server it works.
CodePudding user response:
If you are asking what would be the equivalent of the SQL Server code:
DECLARE @index INT = 4
UPDATE tablex SET id_product = @index, @index = @index 1 where Id_Person = 4037
Then you can use a sequence:
CREATE SEQUENCE tablex__id_product__seq START WITH 5;
UPDATE tablex
SET id_product = tablex__id_product__seq.NEXTVAL
WHERE Id_Person = 4037
or could use ROWNUM
:
UPDATE tablex
SET id_product = 4 ROWNUM
WHERE Id_Person = 4037