Module Sequel::Oracle::DatasetMethods
In: lib/sequel/adapters/shared/oracle.rb

Methods

Included Modules

EmulateOffsetWithRowNumber

Constants

SELECT_CLAUSE_METHODS = Dataset.clause_methods(:select, %w'with select distinct columns from join where group having compounds order lock')
ROW_NUMBER_EXPRESSION = LiteralString.new('ROWNUM').freeze
SPACE = Dataset::SPACE
APOS = Dataset::APOS
APOS_RE = Dataset::APOS_RE
DOUBLE_APOS = Dataset::DOUBLE_APOS
FROM = Dataset::FROM
BITCOMP_OPEN = "((0 - ".freeze
BITCOMP_CLOSE = ") - 1)".freeze
TIMESTAMP_FORMAT = "TIMESTAMP '%Y-%m-%d %H:%M:%S%N %z'".freeze
TIMESTAMP_OFFSET_FORMAT = "%+03i:%02i".freeze
BOOL_FALSE = "'N'".freeze
BOOL_TRUE = "'Y'".freeze
HSTAR = "H*".freeze
DUAL = ['DUAL'.freeze].freeze

Public Instance methods

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 247
247:       def complex_expression_sql_append(sql, op, args)
248:         case op
249:         when :&
250:           sql << complex_expression_arg_pairs(args){|a, b| "CAST(BITAND(#{literal(a)}, #{literal(b)}) AS INTEGER)"}
251:         when :|
252:           sql << complex_expression_arg_pairs(args){|a, b| "(#{literal(a)} - #{complex_expression_sql(:&, [a, b])} + #{literal(b)})"}
253:         when :^
254:           sql << complex_expression_arg_pairs(args){|*x| "(#{complex_expression_sql(:|, x)} - #{complex_expression_sql(:&, x)})"}
255:         when 'B~''B~'
256:           sql << BITCOMP_OPEN
257:           literal_append(sql, args.at(0))
258:           sql << BITCOMP_CLOSE
259:         when :<<
260:           sql << complex_expression_arg_pairs(args){|a, b| "(#{literal(a)} * power(2, #{literal b}))"}
261:         when :>>
262:           sql << complex_expression_arg_pairs(args){|a, b| "(#{literal(a)} / power(2, #{literal b}))"}
263:         when :%
264:           sql << complex_expression_arg_pairs(args){|a, b| "MOD(#{literal(a)}, #{literal(b)})"}
265:         else
266:           super
267:         end
268:       end

Oracle doesn‘t support CURRENT_TIME, as it doesn‘t have a type for storing just time values without a date, so use CURRENT_TIMESTAMP in its place.

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 273
273:       def constant_sql_append(sql, c)
274:         if c == :CURRENT_TIME
275:           super(sql, :CURRENT_TIMESTAMP)
276:         else
277:           super
278:         end
279:       end

Use a custom expression with EXISTS to determine whether a dataset is empty.

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 304
304:       def empty?
305:         db[:dual].where(@opts[:offset] ? exists : unordered.exists).get(1) == nil
306:       end

Oracle treats empty strings like NULL values, and doesn‘t support char_length, so make char_length use length with a nonempty string. Unfortunately, as Oracle treats the empty string as NULL, there is no way to get trim to return an empty string instead of nil if the string only contains spaces.

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 286
286:       def emulated_function_sql_append(sql, f)
287:         case f.f
288:         when :char_length
289:           literal_append(sql, Sequel::SQL::Function.new(:length, Sequel.join([f.args.first, 'x'])) - 1)
290:         else
291:           super
292:         end
293:       end

Oracle uses MINUS instead of EXCEPT, and doesn‘t support EXCEPT ALL

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 296
296:       def except(dataset, opts={})
297:         opts = {:all=>opts} unless opts.is_a?(Hash)
298:         raise(Sequel::Error, "EXCEPT ALL not supported") if opts[:all]
299:         compound_clone(:minus, dataset, opts)
300:       end

Oracle requires recursive CTEs to have column aliases.

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 336
336:       def recursive_cte_requires_column_aliases?
337:         true
338:       end

Oracle requires SQL standard datetimes

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 309
309:       def requires_sql_standard_datetimes?
310:         true
311:       end

Handle LIMIT by using a unlimited subselect filtered with ROWNUM.

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 321
321:       def select_sql
322:         if (limit = @opts[:limit]) && !@opts[:sql]
323:           ds = clone(:limit=>nil)
324:           # Lock doesn't work in subselects, so don't use a subselect when locking.
325:           # Don't use a subselect if custom SQL is used, as it breaks somethings.
326:           ds = ds.from_self unless @opts[:lock]
327:           sql = @opts[:append_sql] || ''
328:           subselect_sql_append(sql, ds.where(SQL::ComplexExpression.new(:<=, ROW_NUMBER_EXPRESSION, limit)))
329:           sql
330:         else
331:           super
332:         end
333:       end

Create a copy of this dataset associated to the given sequence name, which will be used when calling insert to find the most recently inserted value for the sequence.

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 316
316:       def sequence(s)
317:         clone(:sequence=>s)
318:       end

Oracle supports GROUP BY CUBE

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 341
341:       def supports_group_cube?
342:         true
343:       end

Oracle supports GROUP BY ROLLUP

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 346
346:       def supports_group_rollup?
347:         true
348:       end

Oracle does not support INTERSECT ALL or EXCEPT ALL

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 351
351:       def supports_intersect_except_all?
352:         false
353:       end

Oracle does not support IS TRUE.

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 356
356:       def supports_is_true?
357:         false
358:       end

Oracle does not support SELECT *, column

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 361
361:       def supports_select_all_and_column?
362:         false
363:       end

Oracle supports timezones in literal timestamps.

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 366
366:       def supports_timestamp_timezones?
367:         true
368:       end

Oracle does not support WHERE ‘Y’ for WHERE TRUE.

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 371
371:       def supports_where_true?
372:         false
373:       end

Oracle supports window functions

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 376
376:       def supports_window_functions?
377:         true
378:       end

[Validate]