Objective
Create a library information system
Program
SQL> create table library(book_id varchar(10) primary
key, b_name varchar(20) notnull, author varchar(20) notnull);
Table created
SQL>insert into library values(‘b001’,’vb’,’abbas’);
1 row created
SQL>insert into library values(‘b002’,’cpp’,’kanethkar’);
1 row created
SQL>insert into library values(‘b003’,’SAD’,’Alias’);
1 row created
SQL>insert into library values(‘b004’,’java’,’kanethkar’);
1 row created
SQL> ed lib
Declare
Cursor c is select * from library;
V_nam varchar(20);
Begin
V_nam:=’author’;
dbms_output.put_line(‘books of ‘||v_nam||’are:);
for i in c loop
if (i.author=v_nam)then
dbms_output.put_line(i.b_name);
end if;
end loop;
end;
SQL>@ lib;
13 /
Enter value for author: alias
Old 5: v_nam:=’author’;
New 5:v_nam:=’alias’;
Books of alias are:SAD
PL/SQL procedure successfully completed
0 comments:
Post a Comment