Created
April 24, 2019 00:44
-
-
Save bobby5892/96cd23560a84908d8441ab43a8a24aca to your computer and use it in GitHub Desktop.
InClass4-22-sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SET SERVEROUTPUT ON; | |
| CREATE OR REPLACE PROCEDURE calc_commission | |
| (sales_amount_in IN number, commission OUT number) | |
| IS | |
| excep_has_no_sales EXCEPTION; | |
| PRAGMA EXCEPTION_INIT (excep_has_no_sales,-2292); | |
| v_comission number(10,2) := 0; | |
| BEGIN | |
| --Throw exception if negative sales | |
| v_comission := sales_amount_in * .1; | |
| commission := v_comission; | |
| IF commission <= 0 | |
| THEN | |
| RAISE excep_has_no_sales; | |
| END IF; | |
| EXCEPTION | |
| WHEN excep_has_no_sales | |
| THEN dbms_output.put_line('Commission is only added on sales'); | |
| END; | |
| DECLARE | |
| commission NUMBER(10,2) := 0; | |
| BEGIN | |
| calc_commission (0,commission); | |
| END; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment