Skip to content

Instantly share code, notes, and snippets.

@myleftboot
Created May 11, 2012 22:23
Show Gist options
  • Save myleftboot/2662790 to your computer and use it in GitHub Desktop.
Save myleftboot/2662790 to your computer and use it in GitHub Desktop.
Move your logic into the sql statement, clean up your code....
FUNCTION get_printed_status
RETURN varchar2 IS
v_order status orders.printed%TYPE;
v_status varchar2(30);
BEGIN
SELECT decode(printed, null, 'NOT PRINTED'
, 0, 'NOT PRINTED'
, 1, 'PRINTED'
, 2, 'ON HOLD'
, 'UNKNOWN')
INTO v_status
FROM orders
WHERE order_no = p_order_no;
RETURN v_status;
END get_printed_status;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment