Solotion 6

1 Retrieve details of all books in the library–id, title, name of publisher, authors, number of copies in each branch, etc.


 select b.book_id,b.title,b.name,a.author_name,c.no_of_copies,l.branch_id from BOOK1 B,AUTHORP A,B_COPIES C,LIBRARY L where B.book_id=A.book_id and B.book_id=C.book_id and L.branch_id=C.branch_id;


2.Get the particulars of borrowers who have borrowed more than 3 books, but from Jan 2017 to Jun2017

select card_no from B_LENDING where date_out between '01-jan-17'and'01-jul-17'group by card_no having count(*)>3;


3.Delete a book in BOOK table. Update the contents of other tables to reflect this data manipulation operation.


delete from BOOK1 where book_id=3; 


4.Create a view of all books and its number of copies that a recurrently available in the Library.


create view v_books as select b.book_id,b.title,c.no_of_copies from BOOK1 b,B_COPIES c,LIBRARY L where b.book_id=c.book_id and c.branch_id=l.branch_id;



PL/SQL implicit cursor
create table CUSTOM
(
ID int primary key,
name varchar(20),
age int,
address varchar(20),
salary number(6)
);
 insert into CUSTOM values(1,'Ramesh',23,'Allahabad','20000');
insert into CUSTOM values(2,'Suresh',22,'Kanpur','22000');
 insert into CUSTOM values(3,'Mahesh',24,'Ghaziabad','24000'); 
insert into CUSTOM values(4,'Chandan',25,'Noida','26000');
 insert into CUSTOM values(5,'Alex',21,'Paris','28000');
insert into CUSTOM values(6,'Sunita',20,'Delhi','30000');
 select * from CUSTOM;
DECLARE
total_rows number(2); BEGIN
UPDATE CUSTOM
SET salary=salary+5000;
IF sql%notfound THEN dbms_output.put_line('no customers applied');
ELSIF sql%found THEN total_rows := sql%rowcount;
dbms_output.put_line(total_rows||'customers updated'); END IF;
END;
/






Comments

Popular posts from this blog

Solutions 5

Solution 2

Solutions 1