MySQL Forums
Forum List  »  Stored Procedures

Re: Temporary Tables Aliasing in Stored Procedure
Posted by: Andrew Gilfrin
Date: September 30, 2005 03:09AM

Yes your summary is correct.

As for typical uses.... I've only ever used them in Oracle where they are a permanent fixture in the database in terms of structure at least. Noramlly I'd use them to hold data during the duration of a procedure or as a temporary store, this isn't such a problem in Oracle because there are other complex datatypes (record and PL/SQL table types) which can do that anyway.

So the obvious use for them is to imitate arrays or complex data structures in a store procedure. A question thats asked a lot here is can a procedure return a cursor, they can't but you could use a temporay table to do that.

As far as when they are created, you need to create them as and when you need them. The obvious choice for this would be to create a procedure to do this, you can then simply call the procedure.

mysql> delimiter //
mysql> create procedure load_temp()
-> begin
-> create temporary table temp1 (name varchar(10),age int);
-> end//
Query OK, 0 rows affected (0.16 sec)

mysql> call load_temp()//
Query OK, 0 rows affected (0.06 sec)

mysql> select * from temp1//
Empty set (0.00 sec)

Equally you could define them in a file and load them when needed that way

Andrew Gilfrin
------------------
http://gilfster.blogspot.com
My MySQL related Blog

http://www.mysqldevelopment.com
MySQL Stored Procedure,Trigger, View.... (Just about most things these days) Information

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Temporary Tables Aliasing in Stored Procedure
2348
September 30, 2005 03:09AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.