Information générale
Titre:
Problem with RETURNING clause
Hello,
the following works ok in sql server, it gets a new ID for some table from a last ids table:
CREATE PROCEDURE NewId
@Tabla Char(15),
@ID Int output
AS
Update TBRHUIDS
Set LastID = LastID + 1
, @pnID = LastID + 1
Where Tabla = @Tabla
I need the Oracle equivalent, so I try:
CREATE OR REPLACE PROCEDURE NEWID
(PTabla in Char,
ID out Integer)
AS
begin
Update TBRHUIDS
Set LastID = LastID + 1
Where Tabla = PTabla returning LastID into ID;
commit;
end;
However, this gives a ORA-01422 error :exact fetch returns more than requested number of rows
However, there is only ONE record matching the where clause.
I know I could write a select statement after the update, but I need to guarentee that each concurrent access will get his own ID under heavy simultaneous accesses.
Oracle 8.1.7
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement