473,770 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inserting multiple rows in sqlplus

Hi,

In sqlplus, I can insert a single row using:

insert into employee
(name, salary, hiredate)
values
('xyz', '86378', sysdate);

Is there a modification of the insert command that will allow me to
insert more than one row into a table without having to resort to
multiple "insert into ..." statements?

For example, can I insert two rows via something that lloks like:

insert into employee
(name, salary, hiredate)
values
{
('xyz', '86378', sysdate),
('abc', '84249', sysdate-1)
};

Here I am assuming that { } encloses all valid rows, with () enclosing
a single row within the surrounding {}.
I do not want to use the sql loader, PL-SQL, or SQL-PLUS constructs
like functions, scripts, and stored procedures.

Thanks
Raj
Jul 19 '05 #1
4 75873
Raj Kotaru wrote:
I do not want to use the sql loader, PL-SQL, or SQL-PLUS constructs
like functions, scripts, and stored procedures.

well, you're SOL then
Jul 19 '05 #2
Raj Kotaru wrote:
Hi,

In sqlplus, I can insert a single row using:

insert into employee
(name, salary, hiredate)
values
('xyz', '86378', sysdate);

Is there a modification of the insert command that will allow me to
insert more than one row into a table without having to resort to
multiple "insert into ..." statements?

For example, can I insert two rows via something that lloks like:

insert into employee
(name, salary, hiredate)
values
{
('xyz', '86378', sysdate),
('abc', '84249', sysdate-1)
};

Here I am assuming that { } encloses all valid rows, with () enclosing
a single row within the surrounding {}.
I do not want to use the sql loader, PL-SQL, or SQL-PLUS constructs
like functions, scripts, and stored procedures.

Thanks
Raj


INSERT INTO EMPLOYEE AS
SELECT A.NAME, B.SALARY, C.HIREDATE
FROM NAME_TABLE A, SALARY_TABLE B, HIREDATE_TABLE C
WHERE A.SSN = B.SSN
AND A.SSN = C.SSN;

Jul 19 '05 #3

"Raj Kotaru" <ra********@hot mail.com> wrote in message
news:67******** *************** ***@posting.goo gle.com...
Hi,

In sqlplus, I can insert a single row using:

insert into employee
(name, salary, hiredate)
values
('xyz', '86378', sysdate);

Is there a modification of the insert command that will allow me to
insert more than one row into a table without having to resort to
multiple "insert into ..." statements?

For example, can I insert two rows via something that lloks like:

insert into employee
(name, salary, hiredate)
values
{
('xyz', '86378', sysdate),
('abc', '84249', sysdate-1)
};

Here I am assuming that { } encloses all valid rows, with () enclosing
a single row within the surrounding {}.
I do not want to use the sql loader, PL-SQL, or SQL-PLUS constructs
like functions, scripts, and stored procedures.

Thanks
Raj


Not really. But you could create an external table (if you are using 9i)
and then do a select into.
Is this for school? SQLLoader does this by multiple insert statements and
bind variables.
Jim
Jul 19 '05 #4
Raj Kotaru wrote:

Hi,

In sqlplus, I can insert a single row using:

insert into employee
(name, salary, hiredate)
values
('xyz', '86378', sysdate);

Is there a modification of the insert command that will allow me to
insert more than one row into a table without having to resort to
multiple "insert into ..." statements?

For example, can I insert two rows via something that lloks like:

insert into employee
(name, salary, hiredate)
values
{
('xyz', '86378', sysdate),
('abc', '84249', sysdate-1)
};

Here I am assuming that { } encloses all valid rows, with () enclosing
a single row within the surrounding {}.

I do not want to use the sql loader, PL-SQL, or SQL-PLUS constructs
like functions, scripts, and stored procedures.

Thanks
Raj


Oracle does not support what you ask, and AFAIk neither does the SQL
standard. (Corrections appreciated if I'm wrong here.)

I'm not sure why *you* want this, although I can think of several
reasons. Nor do I know your environmnt, your Oracle version, your
operating system version, or your data source. I'd certianly be
interested in the reasoning behind your restrictions about SQL Loader,
etc.

Some alternate ways I've used to do something like this:

1) With a flat file and Oracle9i, consider External Tables;
2) If data is in the database already, use CTAS;
3) Create a SQL Plus script to contains all inserts. If possible
(incredibly easy in unix/linux), generate the script using sed, awk or
perl. Cut size by inserting against a view that maps only to the
columns you want, eliminating the column spec.

<rant>
While there may be legit reasons for the restrictions, you are
effectively increasing the cost of your Oracle investment. This is
similar to saying "though shalt not use the power seats, power windows
or radio in the car - the money that was spent on those features is
wasted."
</rant>
Jul 19 '05 #5

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

Similar topics

2
12750
by: RJ | last post by:
We currently send product releases to our customers, and often have to include scripts that need to be ran on the Oracle databases (also do it for SqlServer customers, but we use a different set of scripts for that). Some of the Sql scripts can be quite long, and so we break them out to their own script files and call them all from one main ..sql file, using sqlplus to execute it all. The admin would run the file like:
0
2395
by: tyousaf | last post by:
Hi i am new to mysql and mysql++, i have installed mysql server, it is running fine. i also installed "mysql++-1.7.9gcc3.2-2.i386.rpm" (i have gcc 3.3) , first of all as the readme file says to do automake, if i do that in the proper director it says "automake: 'configure.ac' or 'configure.in' is required" i dont know where to bring those files. secondly if i only compile simple1.cc using gcc proving all the link flags to libraries and...
3
16345
by: JB | last post by:
To anyone that is able to help.... What I am trying to do is this. I have two tables (Orders, and OrderDetails), and my question is on the order details. I would like to set up a stored procedure that essentially inserts in the orders table the mail order, and then insert multiple orderdetails within the same transaction. I also need to do this via SQL 2000. Right now i have "x" amount of variables for all columns in my orders tables,...
1
4528
by: Scott Chapman | last post by:
I am working with Python (psycopg). I have HTML with embedded Python that I'm inserting into a database and it could contain any character. Single quotes, at least, must be escaped (to two single quotes, right?) before inserting it into Postgres. This poses a problem when I get the data out of the table. It could have originally contained two single quotes together and I replace them with one single quote in the unescaping process.
5
6181
by: Arsen V. | last post by:
Hello, What is the optimal way to insert multiple rows (around 1000) from a web application into a table? The user enters multiple lines into a text box (up to 10,000). The ASP.NET application breaks that data into a string array. Each line is an item of that array. The user clicks Submit.
20
188352
by: talktozee | last post by:
Hey, everyone! Basically, I need to insert *multiple rows* into table A from table B based upon some criteria, and I need to insert some static values along with each row from table A. For example: insert into tableA (col1,col2,col3,col4,col5) values ('Cheese', 'Blue',
1
3106
by: nunrgleo | last post by:
Hi all, I need to write a script that logs into several oracle databases in a sequential manner from a unix box using different login and password e.g sqlplus found/duckl@dnd007 and many more databases to check the logon details work and database is up. At the moment i've got it all hardcoded in a script e.g echo 'testing xxx' sqlplus xxx/yyy@xxx . . . echo 'testing aaa' sqlplus aa/yyy@aaa
4
1776
by: Raj Kotaru | last post by:
Hi, In sqlplus, I can insert a single row using: insert into employee (name, salary, hiredate) values ('xyz', '86378', sysdate); Is there a modification of the insert command that will allow me to
2
10154
by: Eraser | last post by:
Hello, I'm just starting to learn PL/SQL. To get my feet wet, I'm trying to write a simple stored procedure that takes some values as parameters, and inserts those values into a table. For some reason my simple procedure is not working, I'm probably missing something simple. Here is how I'm trying to create this procedure: CREATE OR REPLACE PROCEDURE insert_person(uid IN NUMBER,
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10260
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10101
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6712
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.