You are on page 1of 1

Database Development and Applications

Topic 4: User Interaction in SQL*Plus


(Refer SQL*Plus User Guide and Reference.pdf, Chapter 12 SQL*Plus Command Reference)
(Page 12-10 (ACCEPT command)
(Page 12-72 (PROMPT command)
(Page 5-12 on Using Substitution Variables)

Learning objectives:

1. Use of the ACCEPT and PROMPT commands for interactive input


2. Use of substitution variables in the SELECT and INSERT commands for greater flexibility

ACCEPT and PROMPT command allows for some user interactions


Inserting records:
Insertion of records into the database is done using the INSERT INTO… statement.
For example:
insert into customer values(999,'New Customer','a123@tarc.edu.my',null,null,'M');

The interactive method of adding records to the database would require a script.
Examine the file in_new_cust.txt. Copy the file to drive C:\

Execute the script as many times as necessary to insert the required number of records.
Start c:\in_new_cust.txt

After successfully adding a new record, run a SELECT statement to check display your new data.

Now create the scripts to insert the necessary data for the following table:
menu
food_order
order_list

Homework
Substitution variables in the SELECT statement
The following SQL statement
Select description, price, date_introduced
from menu
where price > 5;

can also be written as


Select description, price, date_introduced
from menu
where price > &v_price;

Describe the user interaction required and the result for the above statement.

You might also like