0% found this document useful (0 votes)
45 views

M.Mani Muthiah Cse-B R.NO:41909104045 Functions and Procedures

The document demonstrates how to create tables, procedures, and functions in Oracle SQL. It creates tables to store book information and orders, then defines a procedure to insert a book record and delete its order. A function is also created to return the rate of a book given its title. The procedures and functions are executed successfully and the tables are queried to show the added/deleted records.

Uploaded by

Kalai Selvan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

M.Mani Muthiah Cse-B R.NO:41909104045 Functions and Procedures

The document demonstrates how to create tables, procedures, and functions in Oracle SQL. It creates tables to store book information and orders, then defines a procedure to insert a book record and delete its order. A function is also created to return the rate of a book given its title. The procedures and functions are executed successfully and the tables are queried to show the added/deleted records.

Uploaded by

Kalai Selvan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

M.

MANI MUTHIAH
CSE-B
R.NO:41909104045

FUNCTIONS AND PROCEDURES

QUERIES:

SQL> create table bookshelf(title varchar2(10),author varchar2(10),rate integer);

Table created.

SQL>create table bookorder values(title varchar2(10));

Table created.

SQL> insert into bookorder values('&title');


Enter value for title: vc++

1 row created.

SQL> create or replace procedure books


2 (a varchar2,b varchar2,c integer) as
3 begin insert into bookshelf values(a,b,c);
4 delete from bookorder where title=a;
5 end;
6 /

Procedure created.

SQL> execute books('dbms','sri',400);

PL/SQL procedure successfully completed.

SQL> select * from bookorder;


TITLE
----------
vc++

SQL> execute books('networks','tanenbaum',450);

PL/SQL procedure successfully completed.

SQL> insert into bookorder values('&title');


Enter value for title: vc++

1 row created.

SQL> select * from bookorder;

TITLE
----------
vc++
vc++

SQL> execute books('mino','ray',300);

PL/SQL procedure successfully completed.

SQL> select * from bookshelf


PL/SQL procedure successfully completed.

SQL> insert into bookorder values('&title');


Enter value for title: vc++

1 row created.

SQL> select * from bookorder;

TITLE
----------
vc++
vc++

SQL> execute books('mino','ray',300);


PL/SQL procedure successfully completed.

SQL> select * from bookshelf;

TITLE AUTHOR RATE


---------- -------------------- ----------
dbms sri 400
networks tanenbaum 450
mino ray 300

SQL> create or replace function book(title1 varchar2)


2 return integer as r integer;
3 begin
4 select rate into r from bookshelf where title=title1;
5 return(r);
6 end;
7 /

Function created.

SQL> variable x number;


SQL> execute:x:=book('dbms');

PL/SQL procedure successfully completed.

SQL> print x;

X
----------
400

SQL>

You might also like