0% found this document useful (0 votes)
7 views

Assignment PLSQL

Uploaded by

التعزي
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Assignment PLSQL

Uploaded by

التعزي
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Instructions: Complete each task by writing a PL/SQL script.

Task 1: Display a Welcome Message

Write a simple PL/SQL script that displays the message "Welcome to PL/SQL Programming!" using
dbms_output.put_line.

BEGIN

dbms_output.put_line('Welcome to PL/SQL Programming!');

END;

Task 2: Multiplication of Two Numbers

Write a PL/SQL script that declares two variables a and b, takes values from the user as input, calculates their
product, and displays the result.

DECLARE

a NUMBER;

b NUMBER;

product NUMBER;

BEGIN

a := &a;

b := &b;

product := a * b;

dbms_output.put_line('The product of ' || a || ' and ' || b || ' is: ' || product);

END;
Task 3: Checking Even or Odd

Write a PL/SQL script that accepts a number as input and checks whether it is even or odd. Display "Even" or
"Odd" accordingly.

DECLARE

num NUMBER;

BEGIN

num := #

IF MOD(num, 2) = 0 THEN

dbms_output.put_line('Even');

ELSE

dbms_output.put_line('Odd');

END IF;

END;
Task 4: Conditional Message with IF Statement

Write a PL/SQL script that declares a variable x with a value of your choice. If x is greater than 10, display "High
value"; otherwise, display "Low value".

DECLARE

x NUMBER := 16;

BEGIN

IF x > 10 THEN

dbms_output.put_line('High value');

ELSE

dbms_output.put_line('Low value');

END IF;

END;

Task 5: Finding the Maximum of Three Numbers

Write a PL/SQL script that accepts three numbers as input and displays the larger of them.

DECLARE

num1 NUMBER;

num2 NUMBER;

num3 NUMBER;

max_num NUMBER;

BEGIN

num1 := &num1;

num2 := &num2;

num3 := &num3;
max_num := num1;

IF num2 > max_num THEN

max_num := num2;

END IF;

IF num3 > max_num THEN

max_num := num3;

END IF;

dbms_output.put_line('The maximum of the three numbers is: ' || max_num);

END;

You might also like