how to insert data into a table using pl/sql [message #145843] |
Mon, 07 November 2005 03:24  |
esteem4305
Messages: 13 Registered: November 2005 Location: India
|
Junior Member |
 
|
|
I have created a table emp_kunal with tthe following fields
Name Null? Type
----------------------------------------- -------- ----------------------------
EMP_NO NOT NULL VARCHAR2(8)
NAME VARCHAR2(20)
SALARY NUMBER(10,2)
DEPT_NO NUMBER(2)
Now What i want to do is to insert data into this blank table using pl/sql.Not to mention that the table is currently empty.
So i am just looking for the appropriate code where it should insert data accordingly in the table and ask the user to insert more data or not.
A help is appreciated in this regard
Esteem
[MOD-EDIT: Disabled smileys]
[Updated on: Mon, 07 November 2005 05:13] by Moderator Report message to a moderator
|
|
|
Re: how to insert data into a table using pl/sql [message #145937 is a reply to message #145843] |
Mon, 07 November 2005 16:27  |
rleishman
Messages: 3728 Registered: October 2005 Location: Melbourne, Australia
|
Senior Member |
|
|
esteem4305 wrote on Mon, 07 November 2005 20:24 | ....and ask the user to insert more data or not.
|
PL/SQL cannot handle user-interaction. You can't put a loop around an INSERT statement and wait for keyboard input (and I don't want any clever replies from anyone else mentioning DBMS_PIPE ).
What happens when you write PL/SQL is that the ENTIRE block of code (from DECLARE/BEGIN to END) is sent from the client (say SQL*Plus) to the Oracle server. It executes and then sends back success or failure. Whilst the code is executing on the server, it cannot come back to the client for more information.
If you want to write a program that repeatedly prompts the user for input and then inserts into the database, you will need to use an external programming language with database connectivity like Pro*C, Perl, Java etc.
An easier way would be to create a Link Table in MS-Access that connects to Oracle via ODBC and key the data in that way.
_____________
Ross Leishman
|
|
|