I am trying to write procedure without using directly lock statements.
SET TERM ^ ;
ALTER PROCEDURE PROC_GETSTATUS (
IDTBL1 Integer )
RETURNS (
STATUS Varchar(255) )
AS
declare variable t int;
BEGIN
t=gen_id(RPUSING,1);
update TBL1 a set a.STATUS=cast('USINGBY' as varchar(255))||cast(:t as varchar(255)) where a.STATUS='free' and a.ID=:IDTBL1 order by a.LASTUPDATED rows 1 to 1;
STATUS=cast('USINGBY' as varchar(255))||cast(:t as varchar(255));
SUSPEND;
END^
SET TERM ; ^
GRANT EXECUTE
ON PROCEDURE PROC_GETSTATUS TO SYSDBA;
When I'm selecting data from this by query like:
select * from TBL1 a where a.STATUS in (select b.STATUS from PROC_GETSTATUS(1));
It returns null. But this select
select * from TBL1 a where a.STATUS like '%USINGBY%'
in current transaction returns updated data. How to rewrite this query by one select to procedure in current transaction?