0% found this document useful (0 votes)
147 views2 pages

PDF PLSQL 2 7 Practice Compress

The document provides an example of a PL/SQL block that demonstrates bad programming practices. It asks the user to modify the block to demonstrate good programming practices such as explicit data type conversions, meaningful variable names, use of the %TYPE attribute, consistent uppercase and lowercase conventions, comments, and clear indentation. The good practices block should select the country name where the ID equals 1246, explicitly convert the string "1234" to a number, multiply that number by 2 and display the country name.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
147 views2 pages

PDF PLSQL 2 7 Practice Compress

The document provides an example of a PL/SQL block that demonstrates bad programming practices. It asks the user to modify the block to demonstrate good programming practices such as explicit data type conversions, meaningful variable names, use of the %TYPE attribute, consistent uppercase and lowercase conventions, comments, and clear indentation. The good practices block should select the country name where the ID equals 1246, explicitly convert the string "1234" to a number, multiply that number by 2 and display the country name.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as 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 goo


good
d progra
programming
mming practices,
practices, and re-run the block.
block.

B. Your modified block should c contain


ontain 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

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy