Created
May 29, 2012 22:30
-
-
Save jamesmoriarty/2831182 to your computer and use it in GitHub Desktop.
This file contains 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 FUNCTION calculate_dialup( | |
hours real, | |
service_dialup_id int | |
) RETURNS real as $$ | |
DECLARE | |
dialup service_dialups%ROWTYPE; | |
excess_usage_charge real := 0; | |
BEGIN | |
SELECT * INTO dialup FROM service_dialups WHERE id = service_dialup_id; | |
-- ... | |
END | |
$$ LANGUAGE plpgsql; |
This file contains 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 FUNCTION calculate_dialup( | |
hours real, | |
dialup_monthly_charge real, | |
dialup_uncharged real, | |
dialup_excess_usage_charge real | |
) RETURNS real as $$ | |
DECLARE | |
excess_usage_charge real := 0; | |
BEGIN | |
-- ... | |
END | |
$$ LANGUAGE plpgsql STABLE; |
This file contains 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
draft=# SELECT * FROM pg_stat_user_functions; | |
funcid | schemaname | funcname | calls | total_time | self_time | |
--------+------------+--------------------------------------+-------+------------+----------- | |
423124 | public | calculate_dialup | 4265 | 292042 | 291912 | |
423129 | public | calculate_local_calling | 4265 | 2643 | 2643 |
This file contains 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
draft=# SELECT * FROM pg_stat_user_functions; | |
funcid | schemaname | funcname | calls | total_time | self_time | |
--------+------------+--------------------------------------+-------+------------+----------- | |
423124 | public | calculate_dialup | 4265 | 222 | 222 | |
423129 | public | calculate_local_calling | 4265 | 2400 | 2400 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment