--%>

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 : Define Capability Normal 0 false false

    Normal 0 false false

  • Q : Compute the Total Shopper Spending in

    Most of the reports produced from the system compute the total dollars in purchases for a shopper. Process the following steps to build a function named TOT_PURCH_SF which accepts a shopper id as input and returns the total dollars which the shopper has spent with com

  • Q : Explain Cohesion Cohesion : The level

    Cohesion: The level to which a component executes a single well-stated task. A strongly cohesive technique, for example, will execute a single task, like adding an item to a data structure, or sorting several data, while a weakly cohesive technique wi

  • Q : "Const" qualifier for pointers and

    In C++ an arguments to a function can be declared as constant as shown below:

    Q : Print the factors of each perfect number

    An integer number is said to be a perfect number if its factors, including 1 (but not the number itself), sum to be the number. For example, 6 is a perfect number because 6 = 1+ 2+ 3. Write a function perfect that determines if parameter number is a perfect number. Us

  • Q : Public class in java Q. Explain the

    Q. Explain the concept of public classes in java. How they are useful? 

  • Q : What is a Micro-chip Micro-chip : It is

    Micro-chip: It is a small electronic device employed to build computers and other electronic equipment. The chips are generally employed to supply the memory and processing components of the computer.

  • Q : Explain Assignment operator Assignment

    Assignment operator: The operator (=) employed to store the value of an expression into the variable, for example: Variable = expression; The right-hand

  • Q : What is a Real-Time System What is a

    What is a Real-Time System?

  • Q : Explain Return type Return type : It is

    Return type: It is the declared type of a method, appearing instantly before the method name, like void in     public static void main(String[] args)    or Point[] in