Class: PLSQL::ProcedureCall

Inherits:
SubprogramCall
  • Object
show all
Defined in:
lib/plsql/procedure_call.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(procedure, args = [], options = {}) ⇒ ProcedureCall



5
6
7
8
# File 'lib/plsql/procedure_call.rb', line 5

def initialize(procedure, args = [], options = {})
  @output_stream = procedure.schema.dbms_output_stream
  super
end

Instance Attribute Details

#output_streamObject (readonly)

Returns the value of attribute output_stream.



3
4
5
# File 'lib/plsql/procedure_call.rb', line 3

def output_stream
  @output_stream
end

Instance Method Details

#execObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/plsql/procedure_call.rb', line 10

def exec
  # puts "DEBUG: sql = #{@sql.gsub("\n","<br/>\n")}"
  @cursor = @schema.connection.parse(@sql)

  @binds[:values].each do |arg, value|
    @cursor.bind_param(":#{arg}", value, @binds[:metadata][arg])
  end

  @return[:variables].each do |var|
    @cursor.bind_param(":#{var}", nil, @return[:metadata][var])
  end

  @cursor.exec

  dbms_output_log

  if block_given?
    yield get_return_value
    nil
  else
    get_return_value
  end
ensure
  @cursor.close if @cursor
end