Home » SQL & PL/SQL » SQL & PL/SQL » Multiple SQL Statements in a sql script
Multiple SQL Statements in a sql script [message #9568] Wed, 19 November 2003 13:54 Go to next message
Just Me
Messages: 10
Registered: November 2000
Junior Member
Hi,
I am using Oracle 9i.

Is there a way to write more than one sql statements in one sql script and run them all at once? example,

Insert Into table1 values (1, 2, 3)

Insert Into table2 values (10, 20, 30)

To do these two actions, I have to select each statement and then run it. I have 50 such statements!

Thanks
Re: Multiple SQL Statements in a sql script [message #9569 is a reply to message #9568] Wed, 19 November 2003 14:10 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
Put all the statements in a file, say, script.sql, and make sure to put a semicolon at the end of each statement.

Insert Into table1 values (1, 2, 3);
Insert Into table2 values (10, 20, 30);


Then, in SQL*Plus, to run the script:

sql>@c:mydirscript.sql
Re: Multiple SQL Statements in a sql script [message #9574 is a reply to message #9568] Wed, 19 November 2003 21:43 Go to previous messageGo to next message
PPMD
Messages: 1
Registered: November 2003
Junior Member
Make 2 seperate sql scripts for 2 data files
that script will have

abc.sql
insert into table_name values ('&&1','&&2','&&3')
abc_1.sql

take the datafile /text file the contains data &for that append in the beginning as below
for ex: if ur data file isas below

data file
00 12 11

@abc.sql 00 12 11
means to ur datafile, u add thescript name so that, that will get executes no of time as thedata.

Hope this is clear...
try it out
good luck...
Re: Multiple SQL Statements in a sql script [message #9581 is a reply to message #9568] Fri, 21 November 2003 07:05 Go to previous messageGo to next message
Just Me
Messages: 10
Registered: November 2000
Junior Member
PPMD and Todd,
Thanks a lot for your replies.
I am using Toad and what worked was adding a
Begin

End

to the script!!
Re: Multiple SQL Statements in a sql script [message #10734 is a reply to message #9568] Fri, 13 February 2004 01:22 Go to previous message
r.s.shreeraam
Messages: 1
Registered: February 2004
Junior Member
I am new to UDB db2.I have around 90 text files which contains sql statements.How to run all the statements in a single shot.I will be very thankful if anyone can kindly clarify.

regds,
shreeraam.r.s
Previous Topic: displaying ascii
Next Topic: How to divide 2 select statement, both have multible rows
Goto Forum:
  


Current Time: Thu Apr 25 22:27:11 CDT 2024