473,382 Members | 1,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Temporary Table Accessable Only In Instance of Procedure

If I have a procedure that will be run simultaneously by several people
which requires the use of a temporary table is there a way for the table
to be accessible only in the instance in which the procedure is being
run so that multiple tables can have the same name but not have
collisions? I would normally think to name the table with a random
string but apparently SQL rules do not allow dynamically generated table
names. The other thing I would try is to have a permanent memory table
with the structure I need, with an additional column that would be
populated with a random number that indicates which batch is being
processed, with the contents being deleted right before the procedure
ends. I don't know what kind of impact that would have on the server,
and am hesitant to try as my test environment has nowhere near the
capacity of the production environment, in just about every way possible.
Sep 27 '06 #1
1 2982
No bother wrote:
If I have a procedure that will be run simultaneously by several people
which requires the use of a temporary table is there a way for the table
to be accessible only in the instance in which the procedure is being
run so that multiple tables can have the same name but not have
collisions? I would normally think to name the table with a random
string but apparently SQL rules do not allow dynamically generated table
names. The other thing I would try is to have a permanent memory table
with the structure I need, with an additional column that would be
populated with a random number that indicates which batch is being
processed, with the contents being deleted right before the procedure
ends. I don't know what kind of impact that would have on the server,
and am hesitant to try as my test environment has nowhere near the
capacity of the production environment, in just about every way possible.
Creating and dropping tables is a relatively expensive operation
when compared to inserting and deleting rows in an existing
table. So the permanent table would be my choice.

I don't think random numbers to identify which batch is being
processed is a good idea because it can lead to orphaned rows in
the event the user drops out, or is dropped out, of the routine
before completion.

My personal preference is to have a permanent table with an
extra column for user id. This will allow you to reconnect
users to their batch data and resume processing while at the
same time the user id can be used to limit access to data.

Don't worry about the performance in your test environment. If
your procedure has tolerable performance in your limited
resource test environment it will be more than adequate in your
production environment. From a practical point of view MySQL is
a very fast RDBMS and properly tuned queries are amazingly
quick. Insert and delete performance tends to be subject to the
number of indexes and the number of rows being inserted or
deleted. If the number of rows is reasonable performance won't
be an issue.
HTH
Jerry
Sep 28 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: tperovic | last post by:
If a stored procedure invokes another stored procedure that creates a temporary table why can't the calling procedure see the temporary table? CREATE PROCEDURE dbo.GetTemp AS CREATE TABLE...
11
by: randi_clausen | last post by:
Using SQL against a DB2 table the 'with' key word is used to dynamically create a temporary table with an SQL statement that is retained for the duration of that SQL statement. What is the...
7
by: Mike Hubbard | last post by:
I have read many many messages about temporary tables and stored procedures. Still, I am struggling with a simple concept. I have a java program which creates a temporary table. I now want to...
4
by: Guru | last post by:
Hi All I am using a Global Temporary table in the Stored procedure and i am creating index for a column in that temporary table.When i am executing it. It is not taking that index. I checked...
7
by: Larry | last post by:
Hi, I have unbelievable problems just to save a record! I make an input to a record in a subform, which has a temporary table as its recordsource. When I am done, and want to save the...
2
by: chettiar | last post by:
I am creating a procedure A which is creating a global temporary table DECLARE GLOBAL TEMPORARY TABLE session.temp (Service CHAR(2), CustomerServiceTypeId INTEGER) WITH REPLACE ON COMMIT PRESERVE...
1
by: phil | last post by:
I have been developing some queries which will list the dependencies of Stored Procedures (this is with DB2/UDB v8). In doing so, I have noticed that dependencies are ignored if they occur in an...
1
by: Kburton | last post by:
All, I am trying to declare a cursor on global temporary table. I declared the global temporary table first and then the cursor but I got the following error: 42601(-104) SQL0104N An...
5
by: Rahul B | last post by:
Hi, I have very little knowledge about creating Procedures/functions in DB2. When i tried to create the test function like CREATE FUNCTION GET_TEST (P_TEST_ID INTEGER, P_SEL_OR_SORT...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.