PL/SQL Control Statement Exercises: Show the value of a same variable declared as local and global
PL/SQL Control Statement: Exercise-25 with Solution
Write a program in PL/SQL to show the value of a same variable declared as local and global.
Sample Solution:
PL/SQL Code:
<<main_label>>
DECLARE
n NUMBER := 6;
BEGIN
FOR n IN 1..4 LOOP
DBMS_OUTPUT.PUT_LINE (
'When local the value: ' || TO_CHAR(n) || ', but the value as global: ' ||
TO_CHAR(main_label.n)
);
END LOOP;
END main_label;
/
Flowchart:
Sample Output:
When local the value: 1, but the value as global: 6 When local the value: 2, but the value as global: 6 When local the value: 3, but the value as global: 6 When local the value: 4, but the value as global: 6 PL/SQL procedure successfully completed.
Improve this sample solution and post your code through Disqus
Previous: Write a program in PL/SQL to print 1st n numbers with a difference of 3 and starting from 1.
Next: Write a program in PL/SQL to explain the uses of nested for loop with label.
What is the difficulty level of this exercise?
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/plsql-exercises/control-statement/plsql-control-statement-exercise-25.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics