Using Java Stored Procedures—An Example

Let us consider an example that shows how Java stored procedures can be used with JavaStop. Suppose that we have a Java class manageOrder that has several methods that are used during order entry. One such method determineDiscount returns the amount of discount that should be given to a customer for any given order using two factors:

  • Amount of order— The discount policy is as follows:

    Total order amount > 1000 then discount rate = 20%

    Total order amount < 1000 and > 500 then discount rate = 10%

  • Country of residence— Customers in USA or Canada get an additional 5% discount

    The backbone of this Java class can be written without using any SQL or PL/SQL code (see Listing 9.1).

Code Listing 9.1. ThemanageOrder

Get e-Commerce Applications Using Oracle8i and Java from Scratch now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.