Module: Sequel::Dataset::StoredProcedureMethods

Module | Sequel::Dataset::StoredProcedureMethods
In: | lib/sequel/adapters/jdbc.rb lib/sequel/adapters/utils/stored_procedures.rb

Use JDBC CallableStatements to execute stored procedures. Only supported if the underlying database has stored procedure support.

### Methods

call inspect run sproc_type=

### Included Modules

Sequel::Dataset::StoredProcedureMethods

### Constants

SQL_QUERY_TYPE | = | Hash.new{|h,k| h[k] = k}

### Attributes

sproc_args | [W] | The name of the stored procedure to call
sproc_name | [RW] | The name of the stored procedure to call

### Public Instance methods

call(*args, &block)

Call the stored procedure with the given args

[Source]

        # File lib/sequel/adapters/utils/stored_procedures.rb, line 14
    14:       def call(*args, &block)
    15:         sp = clone
    16:         sp.sproc_args = args
    17:         sp.run(&block)
    18:       end

inspect()

Programmer friendly string showing this is a stored procedure, showing the name of the procedure.

[Source]

        # File lib/sequel/adapters/utils/stored_procedures.rb, line 22
    22:       def inspect
    23:         "<#{self.class.name}/StoredProcedure name=#{@sproc_name}>"
    24:       end

run(&block)

Run the stored procedure with the current args on the database

[Source]

        # File lib/sequel/adapters/utils/stored_procedures.rb, line 27
    27:       def run(&block)
    28:         case @sproc_type
    29:         when :select, :all
    30:           all(&block)
    31:         when :first
    32:           first
    33:         when :insert
    34:           insert
    35:         when :update
    36:           update
    37:         when :delete
    38:           delete
    39:         end
    40:       end

sproc_type=(type)

Set the type of the stored procedure and override the corresponding _sql method to return the empty string (since the result will be ignored anyway).

[Source]

        # File lib/sequel/adapters/utils/stored_procedures.rb, line 45
    45:       def sproc_type=(type)
    46:         @sproc_type = type
    47:         meta_def("#{sql_query_type}_sql"){|*a| ''}
    48:       end

[Validate]