I have a table with columns RECID,regionID, areaID ,UserID ,AppNo, NextAppNo(Accepts null)
and data is as follows (NextApp
is not null in the first row only):
1,102,Ar-1,xyz,1,1
2,102,Ar-1,qwe,2
3,102,Ar-1,rtr,3
4,102,Ar-1,cvcv,4
Now i want to update and select in same query e.g Now i am doing this
update tbl set NextAppNo = randomnum
select UserID, AppNo from tbl where AppNo =(select NextAppNo from tbl where AppNo = 1)
Can this be done in one query?
P.S
i tried this
SELECT NextApproverNo FROM FINAL TABLE (update tbl set NextApproverNo = '2' where appNO=1)
and getting the result but when i do this
Select userName from tbl where appNO = (SELECT NextApproverNo FROM FINAL TABLE (update tbl set NextApproverNo = '2' where appNO=1) FETCH FIRST 1 ROW ONLY)
i got error
i get following error when i used join on this error as AN SQL DATA CHANGE STATEMENT WITHIN A FROM CLAUSE IS NOT ALLOWED IN THE CONTEXT IN WHICH IT WAS SPECIFIED