Module | Sequel::DB2::DatasetMethods
In: | lib/sequel/adapters/shared/db2.rb

### Methods

cast_sql_append complex_expression_sql_append supports_group_cube? supports_group_rollup? supports_is_true? supports_multiple_column_in? supports_select_all_and_column? supports_timestamp_usecs? supports_where_true? supports_window_functions?

### Included Modules

EmulateOffsetWithRowNumber

### Constants

PAREN_CLOSE | = | Dataset::PAREN_CLOSE
PAREN_OPEN | = | Dataset::PAREN_OPEN
BITWISE_METHOD_MAP | = | {:& =>:BITAND, :| => :BITOR, :^ => :BITXOR, :'B~'=>:BITNOT}
BOOL_TRUE | = | '1'.freeze
BOOL_FALSE | = | '0'.freeze
CAST_STRING_OPEN | = | "RTRIM(CHAR(".freeze
CAST_STRING_CLOSE | = | "))".freeze
FETCH_FIRST_ROW_ONLY | = | " FETCH FIRST ROW ONLY".freeze
FETCH_FIRST | = | " FETCH FIRST ".freeze
ROWS_ONLY | = | " ROWS ONLY".freeze
EMPTY_FROM_TABLE | = | ' FROM "SYSIBM"."SYSDUMMY1"'.freeze

### Public Instance methods

cast_sql_append(sql, expr, type)

DB2 casts strings using RTRIM and CHAR instead of VARCHAR.

[Source]

         # File lib/sequel/adapters/shared/db2.rb, line 198
    198:       def cast_sql_append(sql, expr, type)
    199:         if(type == String)
    200:           sql << CAST_STRING_OPEN
    201:           literal_append(sql, expr)
    202:           sql << CAST_STRING_CLOSE
    203:         else
    204:           super
    205:         end
    206:       end

complex_expression_sql_append(sql, op, args)

Handle DB2 specific LIKE and bitwise operator support, and emulate the extract method, which DB2 doesn‘t natively support.

[Source]

         # File lib/sequel/adapters/shared/db2.rb, line 210
    210:       def complex_expression_sql_append(sql, op, args)
    211:         case op
    212:         when :ILIKE
    213:           super(sql, :LIKE, [SQL::Function.new(:upper, args.at(0)), SQL::Function.new(:upper, args.at(1)) ])
    214:         when "NOT ILIKE""NOT ILIKE"
    215:           super(sql, "NOT LIKE""NOT LIKE", [SQL::Function.new(:upper, args.at(0)), SQL::Function.new(:upper, args.at(1)) ])
    216:         when :&, :|, :^
    217:           # works with db2 v9.5 and after
    218:           op = BITWISE_METHOD_MAP[op]
    219:           sql << complex_expression_arg_pairs(args){|a, b| literal(SQL::Function.new(op, a, b))}
    220:         when :<<
    221:           sql << complex_expression_arg_pairs(args){|a, b| "(#{literal(a)} * POWER(2, #{literal(b)}))"}
    222:         when :>>
    223:           sql << complex_expression_arg_pairs(args){|a, b| "(#{literal(a)} / POWER(2, #{literal(b)}))"}
    224:         when 'B~''B~'
    225:           literal_append(sql, SQL::Function.new(:BITNOT, *args))
    226:         when :extract
    227:           sql << args.at(0).to_s
    228:           sql << PAREN_OPEN
    229:           literal_append(sql, args.at(1))
    230:           sql << PAREN_CLOSE
    231:         else
    232:           super
    233:         end
    234:       end

supports_group_cube?()

DB2 supports GROUP BY CUBE

[Source]

         # File lib/sequel/adapters/shared/db2.rb, line 237
    237:       def supports_group_cube?
    238:         true
    239:       end

supports_group_rollup?()

DB2 supports GROUP BY ROLLUP

[Source]

         # File lib/sequel/adapters/shared/db2.rb, line 242
    242:       def supports_group_rollup?
    243:         true
    244:       end

supports_is_true?()

DB2 does not support IS TRUE.

[Source]

         # File lib/sequel/adapters/shared/db2.rb, line 247
    247:       def supports_is_true?
    248:         false
    249:       end

supports_multiple_column_in?()

DB2 does not support multiple columns in IN.

[Source]

         # File lib/sequel/adapters/shared/db2.rb, line 252
    252:       def supports_multiple_column_in?
    253:         false
    254:       end

supports_select_all_and_column?()

DB2 only allows * in SELECT if it is the only thing being selected.

[Source]

         # File lib/sequel/adapters/shared/db2.rb, line 257
    257:       def supports_select_all_and_column?
    258:         false
    259:       end

supports_timestamp_usecs?()

DB2 does not support fractional seconds in timestamps.

[Source]

         # File lib/sequel/adapters/shared/db2.rb, line 262
    262:       def supports_timestamp_usecs?
    263:         false
    264:       end

supports_where_true?()

DB2 does not support WHERE 1.

[Source]

         # File lib/sequel/adapters/shared/db2.rb, line 272
    272:       def supports_where_true?
    273:         false
    274:       end

supports_window_functions?()

DB2 supports window functions

[Source]

         # File lib/sequel/adapters/shared/db2.rb, line 267
    267:       def supports_window_functions?
    268:         true
    269:       end

[Validate]