Please help! ( database ) Assignment 3 PL/SQL Assignment 1 1 . Execute the comma
ID: 3725753 • Letter: P
Question
Please help! ( database )
Assignment 3
PL/SQL Assignment 1
1. Execute the command
set serveroutput on;
What does this command do? Google it on the Internet.
2. Type the following program and execute it. Can you tell from the result what the command
DBMS_OUTPUT.PUT_LINE does?
--PL/SQL program to display current date
DECLARE
today_date DATE;
BEGIN
today_date := SYSDATE;
DBMS_OUTPUT.PUT_LINE('Today''s date is ');
DBMS_OUTPUT.PUT_LINE(today_date);
END;
3. Before you begin to work on the following questions, first download createDB.sql from
the course website and execute it.
Read the following program and figure out what it does. Then type it and execute it to verify if
you are right.
--PL/SQL program to get grade statistics
DECLARE
na integer :=0;
BEGIN
Select count(*)
into na
from gradeReport
where grade='A';
if (na > 0) then
DBMS_OUTPUT.PUT_LINE('there are total ' || na || ' A''s');
else
DBMS_OUTPUT.PUT_LINE('No student makes an A');
end if;
END;
4. Revise the above program, so that it will output the statistics for the grades A, B, C, D, and F.
Explanation / Answer
1. Execute the command
set serveroutput on;
What does this command do?
----------------------------------------------------------------------------------------------------------------------------------------------
Ans: when we are running PL/SQL code in Oracle Engine we always need server output result. this result will be shown to screen. if serveroutput is off no result will be shown to screen.
so serveroutput print the contents of Oracle Buffer.
------------------------------------------------------------------------------------------------------------------------------------------------------
2. Type the following program and execute it. Can you tell from the result what the command
DBMS_OUTPUT.PUT_LINE does?
Ans: DBMS_OUTPUT.PUT_LINE is a procedure in Oracle.it allows writing data to file or to direct our PL/SQL output to a screen.
------------------------------------------------------------------------------------------------------------------------------------------------------