Last active
April 27, 2025 16:25
-
-
Save Jacob-Anderson-Developer/ee6aac9821bbb0fd655292bf1dd2c373 to your computer and use it in GitHub Desktop.
This is the SQL you will run to create the get balance procedure.
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
CREATE OR REPLACE PROCEDURE YourLibrary.GETBALANCE ( | |
OUT BALANCE DECIMAL(15, 2) | |
) | |
NOT DETERMINISTIC | |
BEGIN | |
SET BALANCE = | |
COALESCE((SELECT SUM(AMOUNT) FROM YourLibrary.BALANCETAB WHERE TRANSTYPE = 'D'), 0) | |
- | |
COALESCE((SELECT SUM(AMOUNT) FROM YourLibrary.BALANCETAB WHERE TRANSTYPE = 'W'), 0); | |
END; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment