Professional Documents
Culture Documents
Alejaga It6 Module-1
Alejaga It6 Module-1
D. Pre-list;
Answer the following questions concisely.
In your own words, describe why a procedural language like PL/SQL is needed.
ANSWER:
PL/SQL is most useful to write triggers and stored procedures. Stored procedures are
units of procedural code stored in a compiled form within the database. Why a procedural
language like PL/SQL is needed for the reasons that users allowed to access data for a large
database application, it allows logic and control to be combined with basic SQL statements,
making it possible to create more useful programs.
PL/SQL provides high security level. PL/SQL is a highly structured and readable
language. Its constructs express the intent of the code clearly. Also, PL/SQL is a straightforward
language to learn. The PL/SQL language allows you to submit a complete block of statements
to the database at once. This minimizes network traffic while maintaining good application
performance. Because it can query, transform, and update data in a database, PL/SQL allows
programmers to work more efficiently.
F. ASSESSMENT;
3GL PL/SQL S
Q
L
4GL PL/SQL S
Q
L
Is proprietary to Oracle Corporation PL/SQL S
Q
L
Nonprocedural PL/SQL S
Q
L
Procedural PL/SQL S
Q
L
Is ANSI-compliant PL/SQL S
Q
L
DECLARE
v_first_name varchar2(40);
v_last_name varchar2(40);
v_first_letter varchar2(1);
BEGIN
SELECT first_name, last_name INTO v_first_name, v_last_name
FROM students
WHERE student_id = 105;
v_first_letter := get_first_letter(v_last_name);
IF 'N' > 'v_first_letter' THEN
DBMS_OUTPUT.PUT_LINE('The last name for ' || v_first_name || ' ' || v_last_name ||
' is between A and M');
ELSE
DBMS_OUTPUT.PUT_LINE('The last name for ' || v_first_name || ' ' || v_last_name ||
' is between N and Z');
END IF;
END;
LESSON 1.2
B. Analysis
D. Application
Try It / Solve It
2. Why is it beneficial to use PL/SQL with an Oracle database? List at least three reasons.
ANSWER:
There are many benefits to using the PL/SQL programming language with an Oracle database.
Integration of procedural constructs with SQL
Modularized program development
Improved performance
Integration with Oracle tools
Portability
Exception handling
3. How is PL/SQL different from C and Java? List three differences.
ANSWER:
4. List three examples of what you can build with PL/SQL code.
ANSWER:
Using PL/SQL, you can build:
Create Web and other applications
Manage application data (write programs for DDL or DML)
Manage the Oracle database (write programs for security, for managing database jobs)
Create custom reports
LESSON 1.3
F. Analysis
Complete the following chart defining the syntactical requirements for a PL/SQL block:
Optional or Mandatory? Describe what is included in this
section
H. Application
Vocabulary
Identify the vocabulary word for each definition below:
Try It / Solve It
1. Which of the following PL/SQL blocks executes successfully? For the blocks that fail,
explain why they fail
A. BEGIN
END;
ANSWER:
Fails because the executable section must contain at least one statement.
(After begin we must have something or NULL.)
C. DECLARE
BEGIN
END;
ANSWER:
ANSWER:
B. PROCEDURES and FUNCTIONS are named blocks and are stored in the
database.
3. In Application Express, create and execute a simple anonymous block that outputs “Hello
World.”
ANSWER:
BEGIN
DBMS_OUTPUT.PUT_LINE ('Hello World');
END;
4. 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>.”
ANSWER:
DECLARE v_timestamp DATE;
BEGIN
SELECT ADD_MONTHS(SYSDATE,6) INTO v_timestamp FROM
DUAL;
DBMS_OUTPUT.PUT_LINE('In six months, the date will be: '||v_timestamp);
END;