this is not showing output
You never call the procedure.
If you format the PL/SQL block:
declare
name book.book_title%type;
price book.book_price%type;
p book.book_price%type;
PROCEDURE expensive_books(
name in out book.book_title%type,
price in out book.book_price%type,
p in out number
)
is
begin
expensive_books(name,price,p);
select book_price,book_title into price,name from book;
end;
begin
for i in 1..5 loop
if p > price then
dbms_output.put_line('Book Name='||name);
end if;
end loop;
end;
/
Then you can see that in the body of the PL/SQL block (between the BEGIN
and the final END
) that you never call the procedure so your code is effectively:
declare
name book.book_title%type;
price book.book_price%type;
p book.book_price%type;
begin
for i in 1..5 loop
if p > price then
dbms_output.put_line('Book Name='||name);
end if;
end loop;
end;
/
Since p
and price
are not initialised then they will have NULL
values and the IF
statement is effectively IF NULL > NULL THEN
and that will never be true (since NULL
compared to anything is never true) so nothing will be output.
If you want to display something then you need to call the procedure and set the value of p
, price
and name
(and your procedure never sets the p
value and also calls itself at every iteration so would get into a infinite loop if you did call it).