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 : What is sticky bit Explain the sticky

    Explain the sticky bit?

  • Q : What is Native Mode Native Mode :

    Native Mode: Whenever all the domain controllers in a specified domain are executing Windows 2000 Server. This mode permits organizations to take benefit of new Active Directory features like Universal groups, nested group membership, and the inter-do

  • Q : Explain Parallel programming Parallel

    Parallel programming: It is a style of programming in which statements are not essentially executed in an ordered series but in parallel. The parallel programming languages make it simpler to produce programs which are designed to be run on multi-proc

  • Q : Define Implements clause Implements

    Implements clause: That part of a class header which points out which interfaces are applied by the class. A class might implement for more than one interface.

  • Q : Explain the java applets with a

      APPLET: an applet is an application designed to tra

  • Q : Explain Counters Counter variables are

    Counter variables are commonly used in many computer applications for different purposes. Here is a typical example where a variable is used to measures the progress of some activity of interest:

    Q : Explain For loop For loop : This is one

    For loop: This is one of the Java's three control structures employed for looping. The other two are while loop and do loop. A for loop includes of a loop header and a loop body. The header comprises of three expressions separated by two semicolons an

  • Q : Illustrations of XML DTDs or schemas

    Give some illustrations of XML DTDs or schemas which you have?

  • Q : Explain Two dimensional array Two

    Two dimensional array: A two dimensional array is a continuous memory location having similar kind of data arranged in row and column format (such as a matrix structure). D

  • Q : Explain the common uses of XML Explain

    Explain the common uses of XML.

©TutorsGlobe All rights reserved 2022-2023.