def cleanQuery(query):
 retVal = query
 for sqlStatements in SQL_STATEMENTS.values():
  for sqlStatement in sqlStatements:
   sqlStatementEsc = sqlStatement.replace('(', '\\(')
   queryMatch = re.search(('(%s)' % sqlStatementEsc), query, re.I)
   if (queryMatch and ('sys_exec' not in query)):
    retVal = retVal.replace(queryMatch.group(1), sqlStatement.upper())
 return retVal

def cleanQuery ( query ) : retVal = query for sqlStatements in SQL_STATEMENTS . values ( ) : for sqlStatement in sqlStatements : sqlStatementEsc = sqlStatement . replace ( '(' , '\\(' ) queryMatch = re . search ( ( '(%s)' % sqlStatementEsc ) , query , re . I ) if ( queryMatch and ( 'sys_exec' not in query ) ) : retVal = retVal . replace ( queryMatch . group ( 1 ) , sqlStatement . upper ( ) ) return retVal
switch all sql statement keywords to upper case .