Tuesday, February 1, 2011

Looping through REF CURSOR


inside a LOOP you need to FETCH from the REF CURSOR to a RECORD (with matching field declarations). Then from the RECORD you could access the field values. Terminate the LOOP via EXIT command (syntax: EXIT WHEN [condition]) - usually [cursor_name]%NOTFOUND condition is used.
  • RECORD must match the REF CURSOR's order/number of attributes
  • in case the REF CURSOR is opened to a [SELECT *] on a table, use the table's %ROWTYPE (e.g. syntax PAYMENTS%ROWTYPE)

No comments:

Post a Comment