473,378 Members | 1,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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 75811
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********@hotmail.com> wrote in message
news:67**************************@posting.google.c om...
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
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...
0
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...
3
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...
1
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...
5
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...
20
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...
1
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...
4
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...
2
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.