Thanks for the question, Naveen.
Asked: February 10, 2017 - 7:04 am UTC
Last updated: February 10, 2017 - 8:45 pm UTC
Version: 12c
Viewed 1000+ times
You Asked
I have an Account table, Address Table and Contact Table. Each Account may have multiple addresses and contacts. I am using Stored Procedures. What would be the best way to return a list of accounts with all the addresses and contacts linked with the account.?
My idea was to return a cursor which each Account as a row. The row contains extra two columns(Nested Table of Custom Data Type) along with the columns in the Account Table. Is this the right way to do it.? Or Should I return the whole thing as a Nested Table instead of a Cursor.? What would be the difference between the two.? A detailed answer would be much appreciated.
I hope there is no need for any more information.
Thanks in advance.!
and Connor said...
Either should be fine. For some client tools, the ref cursor means an extra trip to the database, ie, get the cursor, then issue another call to do the fetch. But that might be a negligible overhead.
If the resultset is of a known (manageable) size, I'd typically use a structure (eg nested table or similar) to return the data. If the resultset is or arbitrary size, then I'd use the ref cursor so I can fetch incrementally.
Is this answer out of date? If it is, please let us know via a Comment