Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Getting records from a table on FIFO basis.

DBQuestDec 11 2017 — edited Dec 14 2017

I got an requirement to write a procedure to fetch the records (which are in READY status to process) in FIFO basis from Inbound_ledger table and send to App for further processing.

RECORD_ID column is primary key.

So I am planning to put below update statement first which updates the status to IN_PROGRESS and pass those records to app.

UPDATE Inbound_ledger a

  SET status = 'IN_PROGRESS'

  binding_ID  = p_binding_id  --  Unique Parameter passed from procedure for each call.

  WHERE a.record_id IN (SELECT record_id FROM

                        (SELECT record_id,rownum sort_order

                         FROM Inbound_ledger

                         WHERE status = 'READY'

                         ORDER BY updated_on)

                         WHERE sort_order <= 5000);

-- Returning the records for futher processing.

OPEN C1 FOR

SELECT * FROM Inbound_ledger

where binding_id = p_binding_id and status = 'IN_PROGRESS';

Please advise alternate to above update statement to get records of FIFO.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 11 2018
Added on Dec 11 2017
17 comments
1,724 views