0% found this document useful (0 votes)
57 views4 pages

Harsharan Kaur Lab Section 1 January 23, 2021

This document contains examples and explanations of PL/SQL programming concepts. It begins with a table identifying characteristics of different programming languages and explains why a procedural language like PL/SQL is needed to combine logic and SQL statements. It then defines the optional and mandatory sections of a PL/SQL block including DECLARE, BEGIN, EXCEPTION, and END. Several PL/SQL block examples are provided and identified as succeeding or failing with explanations. The document concludes with two anonymous block examples - one outputting a name and another declaring a variable, populating it with a date six months from now, and outputting the result.

Uploaded by

Sonia Kaur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views4 pages

Harsharan Kaur Lab Section 1 January 23, 2021

This document contains examples and explanations of PL/SQL programming concepts. It begins with a table identifying characteristics of different programming languages and explains why a procedural language like PL/SQL is needed to combine logic and SQL statements. It then defines the optional and mandatory sections of a PL/SQL block including DECLARE, BEGIN, EXCEPTION, and END. Several PL/SQL block examples are provided and identified as succeeding or failing with explanations. The document concludes with two anonymous block examples - one outputting a name and another declaring a variable, populating it with a date six months from now, and outputting the result.

Uploaded by

Sonia Kaur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Harsharan Kaur

Lab Section 1
January 23, 2021

1. Circle the programming language meeting the criteria

3GL PL/SQL SQL PL/SQL

4GL PL/SQL SQL SQL

Is proprietary to Oracle Corporation PL/SQL SQL PL/SQL

Nonprocedural PL/SQL SQL SQL

Procedural PL/SQL SQL PL/SQL

Is ANSI-compliant PL/SQL SQL SQL

2. In your own words, describe why a procedural language like PL/SQL is needed.

It allows logic and control to be combined with basic SQL statements, making it
possible to create more useful programs.

3. Complete the following chart defining the syntactical requirements for a


PL/SQL block:
Optional or Mandatory? What is included in this
section?

DECLARE Optional Variables, cursors, user


Defined exception

BEGIN Mandatory SQL statements PL/SQL


statements

EXCEPTION Optional Actions to perform when


Errors occur

END; Mandatory End; (with semicolon)


That end closes the block
which contained the begin
section.

4. Which of the following PL/SQL blocks execute successfully? For the blocks
that fail, explain why they fail

4 A. BEGIN
END;

Fails because the executable section must contain at least one statement.

4 B. DECLARE
amount INTEGER(10);
END;

Fails because there is no executable section (BEGIN is missing).

4 C. DECLARE
BEGIN
END;

Fails because the executable section must contain at least one statement.

4 D. DECLARE
amount NUMBER(10);
BEGIN
DBMS_OUTPUT.PUT_LINE(amount);
END;

Succeeds
5. In Application Express:

A. Create and execute a simple anonymous block that outputs your name.

BEGIN
DBMS_OUTPUT.PUT_LINE(‘Harsharan Kaur’);
END;

B. Create and execute a simple anonymous block that does the following:

Declares a variable of datatype DATE and populates it with the date that is six
months from today
Outputs “In six months, the date will be: <insert date>.”

DECLARE
v_six DATE;
BEGIN
v_six := ADD_MONTHS(SYSDATE, 6);
DBMS_OUTPUT.PUT_LINE('In six months, the date will be: '|| v_six);
END;

You might also like