Created
November 8, 2012 15:16
-
-
Save abrkn/4039407 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 match_order ( | |
left_id int | |
) RETURNS int AS $$ | |
DECLARE | |
left "order"%ROWTYPE; | |
right "order"%ROWTYPE; | |
price bigint; | |
BEGIN | |
SELECT * INTO left FROM "order" o WHERE o.order_id = left_id; | |
SELECT * INTO right FROM "order" o | |
WHERE | |
o.have = left.want AND | |
o.want = left.have | |
ORDER BY | |
o.price ASC, o.created ASC; | |
RETURN NULL; | |
END; $$ LANGUAGE plpgsql; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment