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 the relationship between XHTML

    Explain the relationship between XHTML and HTTP?

  • Q : Explain Program counter Program counter

    Program counter: A program counter is an integral portion of a computer's Central Processing Unit. It includes a reference to the memory address of the subsequent instruction to be fetched, ready to be executed throughout the next fetch-execute cycle.

  • Q : Template class and class template in

    Illustrate the difference between a template class and class template in the programming?

  • Q : What is Member What is Member : Members

    What is Member: Members of a class are methods, fields and nested classes.

  • Q : Write a recursive function intpower(base

    Write a recursive function intpower(base, exponent) that when invoked returns base^exponent. For example, intpower(3,4) = 3*3*3*3. Assume that the exponent is an integer greater than or equal to 1.

  • Q : What is pipe What is meant by the term

    What is meant by the term pipe?

  • 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 : Define Livelock Livelock : It is a

    Livelock: It is a situation in which a thread waits to be notified of a condition however, on waking, finds that the other thread has inverted the condition another time. The primary thread is forced to wait again. Whenever this occurs for an indefini

  • Q : Define Class Class : It is a

    Class: It is a programming language concept which permits data and techniques to be grouped altogether. The class concept is basic to the notion of an object-oriented programming language. Methods of a class define the set of permitte

  • Q : Define Little-endian Little-endian : It

    Little-endian: It is a common difference among machines is the order in which they store up the individual bytes of multi-byte numerical data. The little-endian machine stores the lower-order bytes prior to the higher-order bytes.

©TutorsGlobe All rights reserved 2022-2023.