Making a function to get info on the first pre-flop raiser

Forum for users that want to write their own custom queries against the PT database either via the Structured Query Language (SQL) or using the PT3 custom stats/reports interface.

Moderator: Moderators

Making a function to get info on the first pre-flop raiser

Postby Mike0550 » Sun Nov 23, 2008 5:52 pm

Hi, I'm working on making a function to process the hand history and get the first pre-flop raiser and store it in the DB.

I have a lot of experience with C++, and a bit with MSSQL, but none with PostgreSQL. I know I'm making some mistakes in here, but maybe someone knows how to help.

I'm making a bunch of custom stats that will call this function to get the pre-flop raiser's position. This is only designed to work with Stars HHs, but could be modified to work on other sites. This will also only need to be done once

I get errors on any variable declaration line. Apparently I'm not doing it right, but I can't find good documentation on it very easily. I think if I can get past this, I should be able to fix any other bugs this code might have.

Thanks,

Mike

Code: Select all

DECLARE
   raise_position integer;
   hole integer;
   flop integer;
   summary integer;
   stop integer;
   playercount integer;
   preflop text;
   raisetext text;

BEGIN
   SELECT PreflopRaisePosition INTO raise_position FROM holdem_hand_player_detail WHERE id_hand = id_hand;
   IF (RaisePosition IS NULL)
      SELECT cnt_players INTO playercount FROM holdem_hand_summary WHERE id_hand = id_hand;
      SELECT history INTO hh FROM holdem_hand_histories WHERE id_hand = id_hand;
      
      SET raise_position = -100;

      SET hole = position("*** HOLE CARDS ***" in history);
      IF (hole > 0)
         SET summary = position("*** SUMMARY ***" in history);
         SET flop = position("*** FLOP ***" in history);
         IF (flop < 1)
            SET stop = summary;
         ELSE
            SET stop = summary;
         END IF

         SET preflop = substring(hh from hole for stop - hole);
         SET raisepos = position("raises" in preflop);
         IF (raisepos > 0)
            SET raisetext = substring(preflop from 0 for raisepos);
            SET raise_position = playercount - 1;
            
            LOOP
               SET raisepos = position(":" in preflop);
            
               IF (raisepos < 1)
                  EXIT;

               SET preflop = substring(preflop from raisepos + 1);
               SET raise_position = raise_position - 1;
            END LOOP
            
            IF (raise_position = -1)
               SET raise_position = 8;
            ELSEIF (raise_position = -2)
               SET raise_position = 9;
            END IF
            
         ELSE
            SET raise_position = -1;
         END IF
      
      END IF

      IF (raise_position > -100)
         UPDATE holdem_hand_player_detail SET PreflopRaisePosition=raise_position WHERE id_hand = id_hand;
      END IF
   END IF
   RETURN raise_position;
END;
Mike0550
 
Posts: 24
Joined: Thu May 15, 2008 1:03 pm

Re: Making a function to get info on the first pre-flop raiser

Postby shalder » Mon Nov 24, 2008 9:38 pm

opps, nm...

plz post if u get this to work, it would be nice to have a template for writing custom functions that read from the HandHistory text.
shalder
 
Posts: 51
Joined: Sat May 31, 2008 9:16 pm


Return to Custom Stats, Reports, and SQL [Read Only]

Who is online

Users browsing this forum: No registered users and 2 guests