--%>

Calculating Tax on an Order in SQL

Process the following steps to make a procedure to compute the tax on an order. The BB_TAX table includes the states which need taxes to be submitted for Internet sales. When the state is not listed in the table, then no tax must be accessed on any order. Shopper’s state and basket sub total are the inputs to the procedure whereas the tax amount must be returned.
 
A. Make a procedure called TAX_COST_SP to accomplish the tax computation task. Remember that the state and subtotal values are inputs into procedure and the procedure is to return the tax amount. Review the contents of the BB_TAX table, which contains the tax rate for each state that requires to be taxed.

B. Make a host variable named G_TAX to hold the value returned by procedure.
C. Invoke the procedure employing the values of “VA” for the state and $100 for the subtotal.
D. Exhibit the tax amount returned by the procedure (it must be $4.5).

E

Expert

Verified

create or replace PROCEDURE "TAX_COST_SP"
(TSTATE IN VARCHAR2,
SUBTOT IN NUMBER,
G_TAX OUT NUMBER)
is
TRATE NUMBER(4,3);
state_missing EXCEPTION;
begin
    SELECT TAXRATE INTO TRATE FROM BB_TAX WHERE STATE=TSTATE;
 
IF TRATE IS NULL THEN
  RAISE state_missing;
ELSE
  G_TAX := TRATE * SUBTOT;
END IF;
 
EXCEPTION
   WHEN state_missing THEN
      DBMS_OUTPUT.PUT_LINE(TSTATE || ' NOT FOUND');
   WHEN OTHERS THEN
       raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
 
end;

   Related Questions in Programming Languages

  • Q : Explain Polymorphism Polymorphism : It

    Polymorphism: It is the ability of an object reference to be employed as if it referred to an object with various forms. The polymorphism in Java outcomes from both class inheritance and interface inheritance. The actually different forms frequently o

  • Q : Define Continuous simulation Continuous

    Continuous simulation: In a continuous simulation, the time ticks past at a regular rate which is applicable to the specific simulation scenario. At each and every tick, all the objects in the simulation are informed of the passage of time and updated

  • Q : Basic features of OOPs Illustrate the

    Illustrate the basic features of OOPs?

  • Q : Describe MCP or Model Checker for C plus

    MCP: Model Checker for C++ (MCP) is an explicit-state software model checker being introduced by the Robust Software Engineering group at NASA Ames Research Center (Thompson and Brat, 2008). MCP was constructed specifically to allow programs written i

  • Q : What is Shortcut key Shortcut key : A

    Shortcut key: A key-press related with a component in a Graphical User Interface (abbreviated as GUI) which provides an alternative to choosing the component's operation with mouse.

  • Q : Explain Infinite loop Infinite loop :

    Infinite loop: The loop whose termination test never computes to false. At times this is a deliberate act on the portion of the programmer, employing a construct like:         whi

  • Q : What is an Arithmetic expression

    Expression: It is a combination of operands and operators which generates a resultant value. Expressions contain a resulting type that affects the context in which they might be employed.

  • Q : Define Loop variable Loop variable : A

    Loop variable: A variable employed to control the operation of a loop, like a for loop. Usually, a loop variable will be provided an initial value and it is then incremented after each and every iteration till it passes or reaches a terminating value.

  • Q : The COBOL ALTER statement Task 3

    Task 3 Explain the effect of the following pictures: 05 FIELD-1 PIC Z(5)9. 05 FIELD-2 PIC £(5)9.99. 05 FIELD-3 PIC £**,***.99. 05 FIELD-4 PIC £££,££9.99DB. 05

  • Q : Define Thread Thread : It is a

    Thread: It is a lightweight procedure which is managed by the Java Virtual Machine (abbreviated as JVM). Support for threads is given by the Thread class in java.lang package.