Question

Create an anonymous PL/SQL block that accepts the current salary and raise percentage through SQL*Plus substitution...

Create an anonymous PL/SQL block that accepts the current salary and raise percentage through SQL*Plus substitution variables and calculate the new salary based on the input: new salary := old salary * ( 1 + raise percentage / 100 ) The result should be stored in a PL/SQL variable and printed on the screen. Your program should handle NULL values. A NULL value entered for either one or both of the input values is equivalent to a numerical 0 (Note: To associate NULL values for your SQL*Plus substitution variables, just enter NULL.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

SET SERVEROUTPUT ON;

DECLARE
new_salary NUMBER(10,2);
current_salary NUMBER(10,2):=10000;
raise_percent NUMBER(10,2):=5;

BEGIN
new_salary := NVL(current_salary,0) * ( 1 + NVL(raise_percent,0)/ 100 );
DBMS_OUTPUT.PUT_LINE( new_salary );
END;

Output( None of the variable is NULL)

Chrome File Edit View History Bookmarks People Tab Tab Window Help 43%D Sat 12:29 PM Q i whatsapı (3) What x Oracle LI X I co

SET SERVEROUTPUT ON;

DECLARE
new_salary NUMBER(10,2);
current_salary NUMBER(10,2);
raise_percent NUMBER(10,2):=5;

BEGIN
new_salary := NVL(current_salary,0) * ( 1 + NVL(raise_percent,0)/ 100 );
DBMS_OUTPUT.PUT_LINE( new_salary );
END;

Output ( Salary is NULL)

Chrome File Edit View History Bookmarks People Tab Tab Window Help 43%D Sat 12:29 PM Q i whatsapı (3) What x Oracle LI X I co

SET SERVEROUTPUT ON;

DECLARE
new_salary NUMBER(10,2);
current_salary NUMBER(10,2):=10000;
raise_percent NUMBER(10,2);

BEGIN
new_salary := NVL(current_salary,0) * ( 1 + NVL(raise_percent,0)/ 100 );
DBMS_OUTPUT.PUT_LINE( new_salary );
END;

Output ( Raise is NULL)

Chrome File Edit View History Bookmarks People Tab Tab Window Help 43%D Sat 12:29 PM Q i whatsapı (3) What x Oracle Lix I com

Add a comment
Know the answer?
Add Answer to:
Create an anonymous PL/SQL block that accepts the current salary and raise percentage through SQL*Plus substitution...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PL/SQL Auction Program 1. Create a user xyz, who is the owner of the auction. Create...

    PL/SQL Auction Program 1. Create a user xyz, who is the owner of the auction. Create the schema, and package. 2. Create users x1 and x2 who are the participants in the auction. They will need acces to the package. 3. Bid on the same item and record your observations. Verify all scenarios. Upload the files with the missing code and a detailed sample run. AUCTION OWNER.TXT SQL> conn / as sysdba Connected. SQL> drop user xyz cascade; User dropped....

  • 1. Create a PL/SQL program block that determines the top students with respect to GPA. Assume...

    1. Create a PL/SQL program block that determines the top students with respect to GPA. Assume that the database has four tables. Student(SSN, SName, DOB, Major) , Grade(SSN, CNo, Grade(0,1,2,3,4)) and Course table(CNo,CName, Credit Hour), Prerequisite(CNo, PreCNo); Student and couse data ae given in the following SQL statements a. Accept a number n as user input with SQL*Plus telling top n%. b. In a loop get the SName and GPA of the top n% people with respect to GPA. c....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT