@@ -407,7 +407,7 @@ def simpleConcatQuery(self, query1, query2):
407407 if Backend .isDbms (DBMS .MYSQL ):
408408 concatenatedQuery = "CONCAT(%s,%s)" % (query1 , query2 )
409409
410- elif Backend .getIdentifiedDbms () in (DBMS .PGSQL , DBMS .ORACLE , DBMS .SQLITE ):
410+ elif Backend .getIdentifiedDbms () in (DBMS .PGSQL , DBMS .ORACLE , DBMS .SQLITE , DBMS . DB2 ):
411411 concatenatedQuery = "%s||%s" % (query1 , query2 )
412412
413413 elif Backend .getIdentifiedDbms () in (DBMS .MSSQL , DBMS .SYBASE ):
@@ -466,7 +466,7 @@ def concatQuery(self, query, unpack=True):
466466 elif fieldsNoSelect :
467467 concatenatedQuery = "CONCAT('%s',%s,'%s')" % (kb .misc .start , concatenatedQuery , kb .misc .stop )
468468
469- elif Backend .getIdentifiedDbms () in (DBMS .PGSQL , DBMS .ORACLE , DBMS .SQLITE ):
469+ elif Backend .getIdentifiedDbms () in (DBMS .PGSQL , DBMS .ORACLE , DBMS .SQLITE , DBMS . DB2 ):
470470 if fieldsExists :
471471 concatenatedQuery = concatenatedQuery .replace ("SELECT " , "'%s'||" % kb .misc .start , 1 )
472472 concatenatedQuery += "||'%s'" % kb .misc .stop
@@ -544,12 +544,15 @@ def forgeInbandQuery(self, query, position, count, comment, prefix, suffix, char
544544 inbandQuery = self .prefixQuery ("UNION ALL SELECT " , prefix = prefix )
545545
546546 if query .startswith ("TOP" ):
547- # TOP enumeration on DBMS.MSSQL is too specific and it has to go into it's own brackets
548- # because those NULLs cause problems with ORDER BY clause
547+ # TOP enumeration on DBMS.MSSQL is too specific and it has to go
548+ # into its own brackets because those NULLs cause problems with
549+ # ORDER BY clause
549550 if Backend .isDbms (DBMS .MSSQL ):
550551 inbandQuery += "," .join (map (lambda x : char if x != position else '(SELECT %s)' % query , range (0 , count )))
551552 inbandQuery = self .suffixQuery (inbandQuery , comment , suffix )
553+
552554 return inbandQuery
555+
553556 topNum = re .search ("\ATOP\s+([\d]+)\s+" , query , re .I ).group (1 )
554557 query = query [len ("TOP %s " % topNum ):]
555558 inbandQuery += "TOP %s " % topNum
@@ -643,7 +646,7 @@ def limitQuery(self, num, query, field=None, uniqueField=None):
643646 limitStr = queries [Backend .getIdentifiedDbms ()].limit .query % (num + 1 , num + 1 )
644647 limitedQuery += " %s" % limitStr
645648
646- elif Backend .isDbms ( DBMS .ORACLE ):
649+ elif Backend .getIdentifiedDbms () in ( DBMS .ORACLE , DBMS . DB2 ):
647650 if " ORDER BY " in limitedQuery and "(SELECT " in limitedQuery :
648651 orderBy = limitedQuery [limitedQuery .index (" ORDER BY " ):]
649652 limitedQuery = limitedQuery [:limitedQuery .index (" ORDER BY " )]
0 commit comments