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) do |a, b|
253:             s1 = ''
254:             complex_expression_sql_append(s1, :&, [a, b])
255:             "(#{literal(a)} - #{s1} + #{literal(b)})"
256:           end
257:         when :^
258:           sql << complex_expression_arg_pairs(args) do |*x|
259:             s1 = ''
260:             s2 = ''
261:             complex_expression_sql_append(s1, :|, x)
262:             complex_expression_sql_append(s2, :&, x)
263:             "(#{s1} - #{s2})"
264:           end
265:         when 'B~''B~'
266:           sql << BITCOMP_OPEN
267:           literal_append(sql, args.at(0))
268:           sql << BITCOMP_CLOSE
269:         when :<<
270:           sql << complex_expression_arg_pairs(args){|a, b| "(#{literal(a)} * power(2, #{literal(b)}))"}
271:         when :>>
272:           sql << complex_expression_arg_pairs(args){|a, b| "(#{literal(a)} / power(2, #{literal(b)}))"}
273:         when :%
274:           sql << complex_expression_arg_pairs(args){|a, b| "MOD(#{literal(a)}, #{literal(b)})"}
275:         else
276:           super
277:         end
278:       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 283
283:       def constant_sql_append(sql, c)
284:         if c == :CURRENT_TIME
285:           super(sql, :CURRENT_TIMESTAMP)
286:         else
287:           super
288:         end
289:       end

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

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 313
313:       def empty?
314:         db[:dual].where(@opts[:offset] ? exists : unordered.exists).get(1) == nil
315:       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 296
296:       def emulated_function_sql_append(sql, f)
297:         case f.f
298:         when :char_length
299:           literal_append(sql, Sequel::SQL::Function.new(:length, Sequel.join([f.args.first, 'x'])) - 1)
300:         else
301:           super
302:         end
303:       end

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

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 306
306:       def except(dataset, opts=OPTS)
307:         raise(Sequel::Error, "EXCEPT ALL not supported") if opts[:all]
308:         compound_clone(:minus, dataset, opts)
309:       end

Oracle requires recursive CTEs to have column aliases.

[Source]

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

Oracle requires SQL standard datetimes

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 318
318:       def requires_sql_standard_datetimes?
319:         true
320:       end

Handle LIMIT by using a unlimited subselect filtered with ROWNUM.

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 330
330:       def select_sql
331:         if (limit = @opts[:limit]) && !@opts[:sql]
332:           ds = clone(:limit=>nil)
333:           # Lock doesn't work in subselects, so don't use a subselect when locking.
334:           # Don't use a subselect if custom SQL is used, as it breaks somethings.
335:           ds = ds.from_self unless @opts[:lock]
336:           sql = @opts[:append_sql] || ''
337:           subselect_sql_append(sql, ds.where(SQL::ComplexExpression.new(:<=, ROW_NUMBER_EXPRESSION, limit)))
338:           sql
339:         else
340:           super
341:         end
342:       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 325
325:       def sequence(s)
326:         clone(:sequence=>s)
327:       end

Oracle supports GROUP BY CUBE

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 350
350:       def supports_group_cube?
351:         true
352:       end

Oracle supports GROUP BY ROLLUP

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 355
355:       def supports_group_rollup?
356:         true
357:       end

Oracle does not support INTERSECT ALL or EXCEPT ALL

[Source]

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

Oracle does not support IS TRUE.

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 365
365:       def supports_is_true?
366:         false
367:       end

Oracle does not support SELECT *, column

[Source]

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

Oracle supports timezones in literal timestamps.

[Source]

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

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

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 380
380:       def supports_where_true?
381:         false
382:       end

Oracle supports window functions

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 385
385:       def supports_window_functions?
386:         true
387:       end

[Validate]