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?
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework