100% found this document useful (2 votes)
1K views

PLSQL 2 7 Practice

The document provides an example of a PL/SQL block containing bad programming practices and instructs the user to modify the block to demonstrate good programming practices. The good practices include using explicit data type conversions, meaningful variable names, the %TYPE attribute, consistent uppercase and lowercase conventions, single-line and multi-line comments, and clear indentation. The user is asked to modify the provided block accordingly and re-run it.

Uploaded by

Santiago Lara
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
1K views

PLSQL 2 7 Practice

The document provides an example of a PL/SQL block containing bad programming practices and instructs the user to modify the block to demonstrate good programming practices. The good practices include using explicit data type conversions, meaningful variable names, the %TYPE attribute, consistent uppercase and lowercase conventions, single-line and multi-line comments, and clear indentation. The user is asked to modify the provided block accordingly and re-run it.

Uploaded by

Santiago Lara
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

www.oracle.

com/academy

Database Programming with PL/SQL


2-7: Good Programming Practices Practice
Activities
Vocabulary
No new vocabulary for this lesson.

Try It / Solve It
1. Enter and run the following PL/SQL block. It will execute correctly if you have entered it
correctly, but it contains some examples of bad programming practices.

A. Modify the block to use good programming practices, and re-run the block.

B. Your modified block should contain examples of the following good programming
practices: explicit data type conversions, meaningful and consistent variable names,
use of %TYPE, upper and lowercase conventions, single and multi-line comments, and
clear indentation.

DECLARE
myvar1 VARCHAR2(20);
myvar2 number(4);
BEGIN
SELECT country_name INTO myvar1
FROM countries WHERE country_id = 421;
myvar2 := '1234';
MYVAR2 := myvar2 * 2;
DBMS_OUTPUT.PUT_LINE(myvar1);
End;

DECLARE
myvar1 VARCHAR2(20);
myvar2 number(4);
BEGIN
SELECT country_name INTO myvar1
FROM wf_countries WHERE country_id =
1246;
myvar2 := 1234;
MYVAR2 := myvar2 * 2;
DBMS_OUTPUT.PUT_LINE(myvar1);
End;

You might also like