Modular Pattern Matching In Sql