dbTalk Databases Forums  

Issue with creating tables

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Issue with creating tables in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
laszlo_spamhole@freemail.hu
 
Posts: n/a

Default Issue with creating tables - 05-24-2005 , 07:04 AM






Hi. I'm relatively new to plSQL, and I have a bit of a problem. I'd
like to make a package with one procedure creating some tables, and
another procedure SELECTing from them.

Is this even possible? My problem is that (as far as I know), plSQL
only allows creating tables through EXECUTE IMMEDIATE. And if the table
creator procedure uses EXECUTE IMMEDIATE to create the tables, the
other procedures can't see that the tables exist, and the whole thing
refuses to compile, giving a "Table or view does not exist" error.

Any help with this one?

Thanks,

Laszlo


Reply With Quote
  #2  
Old   
andrewst@onetel.com
 
Posts: n/a

Default Re: Issue with creating tables - 05-24-2005 , 07:14 AM






laszlo_spamhole (AT) freemail (DOT) hu wrote:
Quote:
Hi. I'm relatively new to plSQL, and I have a bit of a problem. I'd
like to make a package with one procedure creating some tables, and
another procedure SELECTing from them.

Is this even possible? My problem is that (as far as I know), plSQL
only allows creating tables through EXECUTE IMMEDIATE. And if the
table
creator procedure uses EXECUTE IMMEDIATE to create the tables, the
other procedures can't see that the tables exist, and the whole thing
refuses to compile, giving a "Table or view does not exist" error.

Any help with this one?
What is it you are trying to achieve, really? In all probability,
creating tables via EXECUTE IMMEDIATE is not the correct solution.
Mayeb you want a GLOBAL TEMPORARY table?



Reply With Quote
  #3  
Old   
Carlos
 
Posts: n/a

Default Re: Issue with creating tables - 05-24-2005 , 07:15 AM



You can SELECT FROM the tables created on the fly with another EXECUTE
IMMEDIATE 'SELECT...'. (They must exist when the select is executed).

hth.

Carlos.


Reply With Quote
  #4  
Old   
laszlo_spamhole@freemail.hu
 
Posts: n/a

Default Re: Issue with creating tables - 05-24-2005 , 07:39 AM




andrewst (AT) onetel (DOT) com wrote:
Quote:
laszlo_spamhole (AT) freemail (DOT) hu wrote:
Hi. I'm relatively new to plSQL, and I have a bit of a problem. I'd
like to make a package with one procedure creating some tables, and
another procedure SELECTing from them.

Is this even possible? My problem is that (as far as I know), plSQL
only allows creating tables through EXECUTE IMMEDIATE. And if the
table
creator procedure uses EXECUTE IMMEDIATE to create the tables, the
other procedures can't see that the tables exist, and the whole
thing
refuses to compile, giving a "Table or view does not exist" error.

Any help with this one?

What is it you are trying to achieve, really? In all probability,
creating tables via EXECUTE IMMEDIATE is not the correct solution.
Well, I have a graph, defined on two tables (one holds the graph nodes,
the other holds the edges). I'm writing a fairly complex search
algorithm. The two tables I have to work with are pretty horrible from
a heuristics POV, so I want to make new tables into which I can pull
the data and organize it better, search-wise.

Basically, I have a procedure that creates the search tables and fills
them with data, and a bunch of procedures that work with those tables.

Quote:
Mayeb you want a GLOBAL TEMPORARY table?
Since creating the search tables takes a fair amount of time and the
graph is fairly non-volatile, I don't want to have to re-generate the
search tables every session.

I actually (kind of) solved the problem by generating dummy search
tables manually... this allowed my package to compile, and the creator
procedure then did what it was supposed to (find the table, drop it,
and re-create it with all the necessary data). But while this _does_
work (as long as nobody drops my tables), it's not exactly the most
elegant solution.

Laszlo



Reply With Quote
  #5  
Old   
laszlo_spamhole@freemail.hu
 
Posts: n/a

Default Re: Issue with creating tables - 05-24-2005 , 07:41 AM




Carlos wrote:
Quote:
You can SELECT FROM the tables created on the fly with another
EXECUTE
IMMEDIATE 'SELECT...'. (They must exist when the select is executed).

hth.
Thanks... I figured this would work, but since I need to do a lot of
stuff with the selected data (and don't really feel like funneling my
entire code through EXECUTE IMMEDIATE), this probably isn't the best
solution.

Quote:
Carlos.
Laszlo



Reply With Quote
  #6  
Old   
andrewst@onetel.com
 
Posts: n/a

Default Re: Issue with creating tables - 05-24-2005 , 07:45 AM



laszlo_spamh... (AT) freemail (DOT) hu wrote:
Quote:
andrewst (AT) onetel (DOT) com wrote:
Mayeb you want a GLOBAL TEMPORARY table?

Since creating the search tables takes a fair amount of time and the
graph is fairly non-volatile, I don't want to have to re-generate the
search tables every session.

I actually (kind of) solved the problem by generating dummy search
tables manually... this allowed my package to compile, and the
creator
procedure then did what it was supposed to (find the table, drop it,
and re-create it with all the necessary data). But while this _does_
work (as long as nobody drops my tables), it's not exactly the most
elegant solution.
So why do you need to drop and re-create the tables each time? Do you
generate a different set of columns each time?



Reply With Quote
  #7  
Old   
laszlo_spamhole@freemail.hu
 
Posts: n/a

Default Re: Issue with creating tables - 05-24-2005 , 07:54 AM




andre... (AT) onetel (DOT) com wrote:
Quote:
laszlo_spamh... (AT) freemail (DOT) hu wrote:
andrewst (AT) onetel (DOT) com wrote:
Mayeb you want a GLOBAL TEMPORARY table?

Since creating the search tables takes a fair amount of time and
the
graph is fairly non-volatile, I don't want to have to re-generate
the
search tables every session.

I actually (kind of) solved the problem by generating dummy search
tables manually... this allowed my package to compile, and the
creator
procedure then did what it was supposed to (find the table, drop
it,
and re-create it with all the necessary data). But while this
_does_
work (as long as nobody drops my tables), it's not exactly the most
elegant solution.

So why do you need to drop and re-create the tables each time? Do
you
generate a different set of columns each time?
No, the columns are always the same, but occasionally (pretty rarely),
the entire set of data changes. The table isn't dropped and recreated
each time, just occasionally.

Hmm... actually, I think I see your point. I'm not sure why I'm
dropping the table instead of doing a DELETE FROM, when the data needs
to be recreated from scratch.

Thanks for the speedy assistance! I appreciate it

Laszlo



Reply With Quote
  #8  
Old   
laszlo_spamhole@freemail.hu
 
Posts: n/a

Default Re: Issue with creating tables - 05-24-2005 , 07:54 AM




andre... (AT) onetel (DOT) com wrote:
Quote:
laszlo_spamh... (AT) freemail (DOT) hu wrote:
andrewst (AT) onetel (DOT) com wrote:
Mayeb you want a GLOBAL TEMPORARY table?

Since creating the search tables takes a fair amount of time and
the
graph is fairly non-volatile, I don't want to have to re-generate
the
search tables every session.

I actually (kind of) solved the problem by generating dummy search
tables manually... this allowed my package to compile, and the
creator
procedure then did what it was supposed to (find the table, drop
it,
and re-create it with all the necessary data). But while this
_does_
work (as long as nobody drops my tables), it's not exactly the most
elegant solution.

So why do you need to drop and re-create the tables each time? Do
you
generate a different set of columns each time?
No, the columns are always the same, but occasionally (pretty rarely),
the entire set of data changes. The table isn't dropped and recreated
each time, just occasionally.

Hmm... actually, I think I see your point. I'm not sure why I'm
dropping the table instead of doing a DELETE FROM, when the data needs
to be recreated from scratch.

Thanks for the speedy assistance! I appreciate it

Laszlo



Reply With Quote
  #9  
Old   
DA Morgan
 
Posts: n/a

Default Re: Issue with creating tables - 05-24-2005 , 11:11 AM



laszlo_spamhole (AT) freemail (DOT) hu wrote:
Quote:
Hi. I'm relatively new to plSQL, and I have a bit of a problem. I'd
like to make a package with one procedure creating some tables, and
another procedure SELECTing from them.

Is this even possible? My problem is that (as far as I know), plSQL
only allows creating tables through EXECUTE IMMEDIATE. And if the table
creator procedure uses EXECUTE IMMEDIATE to create the tables, the
other procedures can't see that the tables exist, and the whole thing
refuses to compile, giving a "Table or view does not exist" error.

Any help with this one?

Thanks,

Laszlo
What you want can be done. It is equally true that it should NEVER
be done.
--
Daniel A. Morgan
http://www.psoug.org
damorgan@x.washington.edu
(replace x with u to respond)


Reply With Quote
  #10  
Old   
Frank van Bortel
 
Posts: n/a

Default Re: Issue with creating tables - 05-24-2005 , 01:46 PM



laszlo_spamhole (AT) freemail (DOT) hu wrote:

Quote:
Hmm... actually, I think I see your point. I'm not sure why I'm
dropping the table instead of doing a DELETE FROM, when the data needs
to be recreated from scratch.
Apart from comments pointing towards "you should not be doing this":
a truncate is much faster than a delete from .. However: it is DDL,
not DML
--
Regards,
Frank van Bortel


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.