Skip to content

Instantly share code, notes, and snippets.

@bobby5892
Created April 24, 2019 00:44
Show Gist options
  • Select an option

  • Save bobby5892/96cd23560a84908d8441ab43a8a24aca to your computer and use it in GitHub Desktop.

Select an option

Save bobby5892/96cd23560a84908d8441ab43a8a24aca to your computer and use it in GitHub Desktop.
InClass4-22-sql
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