Return REF CURSOR to procedure generated data

Posted by ThaDon on Stack Overflow See other posts from Stack Overflow or by ThaDon
Published on 2011-01-03T21:45:14Z Indexed on 2011/01/03 21:54 UTC
Read the original article Hit count: 192

Filed under:
|
|

I need to write a sproc which performs some INSERTs on a table, and compile a list of "statuses" for each row based on how well the INSERT went. Each row will be inserted within a loop, the loop iterates over a cursor that supplies some values for the INSERT statement. What I need to return is a resultset which looks like this:

FIELDS_FROM_ROW_BEING_INSERTED.., STATUS VARCHAR2

The STATUS is determined by how the INSERT went. For instance, if the INSERT caused a DUP_VAL_ON_INDEX exception indicating there was a duplicate row, I'd set the STATUS to "Dupe". If all went well, I'd set it to "SUCCESS" and proceed to the next row.

By the end of it all, I'd have a resultset of N rows, where N is the number of insert statements performed and each row contains some identifying info for the row being inserted, along with the "STATUS" of the insertion

Since there is no table in my DB to store the values I'd like to pass back to the user, I'm wondering how I can return the info back? Temporary table? Seems in Oracle temporary tables are "global", not sure I would want a global table, are there any temporary tables that get dropped after a session is done?

© Stack Overflow or respective owner

Related posts about Oracle

Related posts about stored-procedures