convert a temp table in oracle to global temporary table

Hi
I have a temp table created in my oracle package (version 11) that takes the date parameter and then I delete some tables in my schema based on those dates from temp table and also do a immediate insert records the same tables with new set of data, it is always fine in a single user session running the process but I find it is a problem when 2 users try use this process to run a request, the temp table does not work in  that scenario, how woulod I convert my temp table to global temp table, it is a oracle pacakge code with procedues and functions for insert and delete data.
mahjagAsked:
Who is Participating?
 
sdstuberConnect With a Mentor Commented:
simply drop your old table and then recreate it as a global temp with the same columns, triggers, contstraints, etc.

0
 
slightwv (䄆 Netminder)Connect With a Mentor Commented:
Take the create table syntax out of the pacakge and from a sql prompt add create gloobal temporary table syntax to it.

Then it's just like any other table.  Only choice is on commit to preserve rows or not.

Syntax is in the online docs.
0
 
mahjagAuthor Commented:
Thanks for the postings - does it work for multiple sessions of user accsessing same data - currently I get unique constraint error on a table that boith users tyring to insert same data, how is that will work for global temp table -  I want to understand genreally how gt table works on multi user application and each user can submit same request to delete and insert recrods to same table.
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
slightwv (䄆 Netminder) Commented:
Yes.  Only the person inserting the data can see it.  When the session ends, the data is deleted.
0
 
ajexpertConnect With a Mentor Commented:
temp table is user and session specific.

We make use of global temporary table when the process populates and do some operations within same session.

Make sure you are aware of the global tempoary table concepts before you proceed
0
 
mahjagAuthor Commented:
hi alexpert

We make use of global temporary table when the process populates and do some operations within same session.

can you elaborate
0
 
ajexpertConnect With a Mentor Commented:
You can make use of global temporaray table within same session for the logged on user.

But you cannot make use of global temporaty table when

 "2 users try use this process to run a request, the temp table does not work in  that scenario"

HTH
0
 
sdstuberCommented:
2 uses can use a  global temp table at the same time
0
 
mahjagAuthor Commented:
Hi Akexpert - I awarded points for the response - I wanted to find more details as to why we cannot use gloabl temp table for above case - I want to understand what I can use so that one process cannot insert the data without delete happen to the same session or diff session by actually locking the transaction - let me know..
0
 
mahjagAuthor Commented:
how to control transaction of not deleting one user session data with another?
0
 
ajexpertCommented:
This is separate question.  You may ask new question.
0
 
slightwv (䄆 Netminder) Commented:
Might be seperate but close enough.

You don't need to delete from a GTT.  Once the session ends, Oracle does it for you.

I suggest the online docs for how they work.
0
 
ajexpertCommented:
Hi Sean,

Could you please explain with example?

"2 uses can use a  global temp table at the same time"

Since 2 users will have separate sessions how is it possible?

0
 
ajexpertCommented:
0
 
sdstuberCommented:
"Since 2 users will have separate sessions how is it possible?"

That's exactly how it's possible.

each session has its own version of the table.

If you and I are both logged in to the same database we can both insert/update/delete/select from our own temp table.  We can't share data from our respective temp tables, but that's the whole point.  We each get our own private workspace that lasts only for the duration of our session or transaction if configured to "ON COMMIT DELETE ROWS" instead of PRESERVE ROWS
0
 
ajexpertCommented:


Yes Sean, I concur with you.

I some how got confused and thought your reply may be pointing to sharing of data between two users in GTT

Thanks Sean
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.