Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need answer for questions 3 and 4 please help ( database ) 1 . Execute the com

ID: 3726123 • Letter: I

Question

I need answer for questions 3 and 4 please help ( database )

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

1A) The set serveroutput on; command will enable the printing of Arguments/Values that are passed in the DBMS_OUTPUT.PUT_LINE() on the main console. If this command is not executed the results won't be displayed on the standard output/ main console.

2A) DBMS_OUTPUT.PUT_LINE will display the Arguments/ values passed to it on the console. The program will display the below output,

Today's date is

08-MAR-18

3A) The fallowing query result will be stored in the variale "na" , Select count(*) from gradeReport where grade='A';

if the reports exist(na>0) for grade A then the Standard out put will be populated with "there are total xx A's" xx is number of records, else the Standard out put will be populated as "No student makes an A".

4A)

For A:

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;

For B:

DECLARE
na integer :=0;
BEGIN
Select count(*)
into na
from gradeReport
where grade='B';
if (na > 0) then
DBMS_OUTPUT.PUT_LINE('there are total ' || na || ' B''s');
else
DBMS_OUTPUT.PUT_LINE('No student makes an B');
end if;
END;

For C:

DECLARE
na integer :=0;
BEGIN
Select count(*)
into na
from gradeReport
where grade='C';
if (na > 0) then
DBMS_OUTPUT.PUT_LINE('there are total ' || na || ' C''s');
else
DBMS_OUTPUT.PUT_LINE('No student makes an C');
end if;
END;

For D:

DECLARE
na integer :=0;
BEGIN
Select count(*)
into na
from gradeReport
where grade='D';
if (na > 0) then
DBMS_OUTPUT.PUT_LINE('there are total ' || na || ' D''s');
else
DBMS_OUTPUT.PUT_LINE('No student makes an D');
end if;
END;

For F:

DECLARE
na integer :=0;
BEGIN
Select count(*)
into na
from gradeReport
where grade='F';
if (na > 0) then
DBMS_OUTPUT.PUT_LINE('there are total ' || na || ' F''s');
else
DBMS_OUTPUT.PUT_LINE('No student makes an F');
end if;
END;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote