Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combinig sections into one SQL-Script 1

Status
Not open for further replies.

karlomutschler

Programmer
Jun 5, 2001
75
0
0
DE
good day,

I have separate sql-scripts to
drop mytable
create mytable with description of variables
insert data from other tables into mytable
grant select privileges to USER2

how do I combine these into one single sql-script?

if somecriteria (mytable exists)
then
drop table mytable
create table mytable (
var1 varchar2(8),
var2 varchar2(32)
)
insert into mytable (
var1,
var2
)
select a.source1
a.source
from othertable
where .....;
commit;
grant select on mytable to USER2;

Any help most welcome.
Kind regards
Karlo
 
Karlo,

Why don't you just have a script that says:
Code:
drop table mytable;
create table mytable
    (var1     varchar2(8),
     var2     varchar2(32));
insert into mytable (var1,var2)
        select a.source1
               a.source
        from   othertable
        where  .....;
commit;
grant select on mytable to USER2;
The only statement that might fail is the "Drop table mytable;" statement, and that error would be:
Code:
drop table mytable
           *
ERROR at line 1:
ORA-00942: table or view does not exist
Is it such a big problem if you receive an error on a DROP TABLE statement because it cannot find a table that you don't want to exist anyway?

Let us know if this answers your questions.


[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
“Beware of those that seek to protect you from harm. The cost will be your freedoms and your liberty.”
 
Mufasa,
thanks for your prompt reply

- worked perfectly !!

Kindest regards
Karlo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top