-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsp.sql
More file actions
executable file
·40 lines (32 loc) · 872 Bytes
/
sp.sql
File metadata and controls
executable file
·40 lines (32 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
DROP PROCEDURE IF EXISTS vpip;
DELIMITER $$
CREATE PROCEDURE vpip (
in playerid BIGINT,
out vpip decimal(6,2)
) READS SQL DATA COMMENT 'Determine vpip'
BEGIN
DECLARE no_more_rows BOOLEAN;
DECLARE loop_cntr INT DEFAULT 0;
DECLARE num_rows INT DEFAULT 0;
DECLARE action ENUM('BET','CHECK','RAISE','RERAISE','FOLD','CALL','RECALL');
DECLARE gameid BIGINT;
DECLARE vpip_cur CURSOR FOR
SELECT h.action, h.gameid FROM hands h
WHERE h.playerid=playerid AND h.state="PREFLOP";
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET no_more_rows = TRUE;
OPEN vpip_cur;
SELECT FOUND_ROWS() INTO num_rows;
the_loop: LOOP
FETCH vpip_cur INTO action, gameid;
IF no_more_rows THEN
CLOSE vpip_cur;
LEAVE the_loop;
END IF;
select action, gameid, num_rows;
SET loop_cntr = loop_cntr + 1;
END LOOP the_loop;
select num_rows into @a;
END
$$
DELIMITER ;