Write a PL/SQL program to check whether a given number is positive, negative or zero

  • pl/sql

Write a PL/SQL program to check whether a given number is positive, negative or zero

الأجوبة

DECLARE
num1 NUMBER := &get_num;
BEGIN
IF num1 < 0 THEN
DBMS_OUTPUT.PUT_LINE ('The number '||num1||' is a negative number');
ELSIF num1 = 0 THEN
DBMS_OUTPUT.PUT_LINE ('The number '||num1||' is equal to zero');
ELSE
DBMS_OUTPUT.PUT_LINE ('The number '||num1||' is a positive number');
END IF;
END;
/

Sample Output:

SQL> /
Enter value for get_num: 45
old   2: num1 NUMBER := &get_num;
new   2: num1 NUMBER := 45;
The number 45 is a positive number

PL/SQL procedure successfully completed
هل كان المحتوى مفيد؟

معلومات ذات صلة

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...