1. Home
  2. /
  3. Plsql
  4. /
  5. PL/SQL Counter and Theme Toggle

PL/SQL Counter and Theme Toggle - Plsql Typing CST Test

Loading…

PL/SQL Counter and Theme Toggle — Plsql Code

Demonstrates a simple counter with theme toggling using PL/SQL variables and DBMS_OUTPUT for output.

DECLARE
	count NUMBER := 0;
	isDark BOOLEAN := FALSE;
BEGIN
	-- Display initial state
	DBMS_OUTPUT.PUT_LINE('Counter: ' || count);
	DBMS_OUTPUT.PUT_LINE('Theme: ' || CASE WHEN isDark THEN 'Dark' ELSE 'Light' END);

	-- Increment counter
	count := count + 1;
	DBMS_OUTPUT.PUT_LINE('Counter: ' || count);

	-- Toggle theme
	isDark := NOT isDark;
	DBMS_OUTPUT.PUT_LINE('Theme: ' || CASE WHEN isDark THEN 'Dark' ELSE 'Light' END);

	-- Decrement counter
	count := count - 1;
	DBMS_OUTPUT.PUT_LINE('Counter: ' || count);

	-- Reset counter
	count := 0;
	DBMS_OUTPUT.PUT_LINE('Counter: ' || count);
END;

Plsql Language Guide

PL/SQL (Procedural Language/Structured Query Language) is Oracle Corporation's procedural extension to SQL. It combines SQL's data manipulation capabilities with procedural constructs like loops, conditions, and exceptions, enabling complex business logic execution directly within the database.

Primary Use Cases

  • ▸Writing stored procedures and functions
  • ▸Creating database triggers
  • ▸Automating batch jobs
  • ▸Data validation and business rule enforcement
  • ▸Complex reporting and ETL tasks

Notable Features

  • ▸Seamless SQL integration
  • ▸Support for cursors and collections
  • ▸Exception handling and error propagation
  • ▸Procedural constructs: loops, conditions, variables
  • ▸Package-based modular development

Origin & Creator

Developed by Oracle Corporation in the late 1980s to extend SQL with procedural capabilities.

Industrial Note

PL/SQL is the backbone of Oracle database applications, supporting triggers, stored procedures, and batch processing in enterprise environments.

More Plsql Typing Exercises

PL/SQL Simple AdditionPL/SQL FactorialPL/SQL Fibonacci SequencePL/SQL Max of Two NumbersPL/SQL Array SumPL/SQL Even Numbers FilterPL/SQL Conditional Counter IncrementPL/SQL Resettable CounterPL/SQL Theme Toggle Only

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher