'Take in input a field string and return its processed nulled and
casted field string.
Examples:
MySQL input:  VERSION()
MySQL output: IFNULL(CAST(VERSION() AS CHAR(10000)), \' \')
MySQL scope:  VERSION()
PostgreSQL input:  VERSION()
PostgreSQL output: COALESCE(CAST(VERSION() AS CHARACTER(10000)), \' \')
PostgreSQL scope:  VERSION()
Oracle input:  banner
Oracle output: NVL(CAST(banner AS VARCHAR(4000)), \' \')
Oracle scope:  SELECT banner FROM v$version WHERE ROWNUM=1
Microsoft SQL Server input:  @@VERSION
Microsoft SQL Server output: ISNULL(CAST(@@VERSION AS VARCHAR(8000)), \' \')
Microsoft SQL Server scope:  @@VERSION
@param field: field string to be processed
@type field: C{str}
@return: field string nulled and casted
@rtype: C{str}'

def nullAndCastField(self, field):

    nulledCastedField = field
    if field:
        rootQuery = queries[Backend.getIdentifiedDbms()]
        if (field.startswith('(CASE') or field.startswith('(IIF') or conf.noCast):
            nulledCastedField = field
        else:
            if (not (Backend.isDbms(DBMS.SQLITE) and (not isDBMSVersionAtLeast('3')))):
                nulledCastedField = (rootQuery.cast.query % field)
            if (Backend.getIdentifiedDbms() in (DBMS.ACCESS,)):
                nulledCastedField = (rootQuery.isnull.query % (nulledCastedField, nulledCastedField))
            else:
                nulledCastedField = (rootQuery.isnull.query % nulledCastedField)
        kb.binaryField = (conf.binaryFields and (field in conf.binaryFields.split(',')))
        if (conf.hexConvert or kb.binaryField):
            nulledCastedField = self.hexConvertField(nulledCastedField)
    return nulledCastedField
