I'm trying to update a record at the same time I select it. In Oracle SQL Developer, the below query works. However, when I execute it from within a CFQUERY tag in ColdFusion, I get an error (see below). I found this stack overflow (ORA-06550 and PLS-00103) but wasn't any help.
Ideally, I'd also like to return the whole record, not just the ID of the affected record. So, I have two questions.
- Why is the below record failing from within a ColdFusion CFC's CFQUERY?
How to I rewrite the query to return the affected record rather than just that record's id?
DECLARE record_id scpricequeue.scpricequeueid%TYPE; BEGIN update scpricequeue set islocked = 1, datelocked = sysdate where scpricequeueid = ( select scpricequeueid from ( select scpricequeueid from scpricequeue where islocked = 0 and completed = 0 order by dateadded asc ) where rownum < = 1 ) RETURNING scpricequeueid INTO record_id; DBMS_OUTPUT.put_line('Locked Record: ' || record_id); END;
ERROR RECEIVED when executed as CFQUERY:
ORA-06550: line 1, column 8: PLS-00103: Encountered the symbol "" when
expecting one of the following: begin function package pragma procedure
subtype type use <an identifier> <a double-quoted delimited-identifier>
form current cursor The symbol "" was ignored.*