sql server store procedure contains temp tables need to convert oracle?

alsatham hussain
alsatham hussain used Ask the Experts™
on
Hi,

I am struggling with migrating the temp tables (SQL server) to oracle. Mostly, oracle don't consider to use temporary table inside the store procedure but in sql server, they are using temp tables for  small fetching record and also manipulate same.
How to overcome  this issue.  I am also searching some online articles about migrating temp table to oracle but they are not clearly explained for my expectations.
i got information like using inline view, WITH clause, ref cursor instead of temp table. I am totally confused.
Please suggest me,  in which case may use Inline view, WITH clause, ref cursor.
This may be helpful for improve my knowledge and also doing job well.

As always thank you for your valuable time in helping out the newbies.
Thanks
Alsatham hussain
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
PortletPaulEE Topic Advisor
Most Valuable Expert 2014
Awarded 2013

Commented:
This broad question is IMPOSSIBLE to answer simply

Using WITH is probably the easiest to implement because in many cases you can simply mimic the creation of a temp table this way.

BUT having said that I often sense that T-SQL developers OVERUSE temp tables and quite often they are simply not needed in Oracle.
Most Valuable Expert 2012
Distinguished Expert 2018
Commented:
I agree.  It all depends on what is in the old temp tables and how they are using them.

You shouldn't try to do a straight port from SQL Server to Oracle.  You'll likely end up with poorly performing code.

Oracle does have Global Temporary Tables (GTT).  You don't create them dynamically like you do in SQL Server.  You create them once and use them over and over again.  That might get you what you need.

If a GTT won't work for you and you need something more dynamic for a small amount of data from a really large table, you can use collections:
http://docs.oracle.com/database/121/LNPLS/composites.htm#LNPLS005

To repeat what is said above because it is a REALLY IMPORTANT statement:
quite often they are simply not needed in Oracle.

I would NOT use collections just because you can and the SQL Server code used TEMP tables.

I use GTTs and Collections in production but they are for very specific reasons.  Most of the time, I use cursors and grab the data exactly when I need it.
alsatham hussainOracle developer

Author

Commented:
sorry for the delay

 Thank you so much for your advice and guidance

Thanks

ASH

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial