| 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.
| SQL_QUERY_TYPE | = | Hash.new{|h,k| h[k] = k} |
Call the stored procedure with the given args
# 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
Programmer friendly string showing this is a stored procedure, showing the name of the procedure.
# File lib/sequel/adapters/utils/stored_procedures.rb, line 22
22: def inspect
23: "<#{self.class.name}/StoredProcedure name=#{@sproc_name}>"
24: end
Run the stored procedure with the current args on the database
# 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
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).
# 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