Class: DBI::DBD::OCI8::BindType::DBIStatementHandle
- Inherits:
-
OCI8::BindType::Cursor
- Object
- OCI8::BindType::Cursor
- DBI::DBD::OCI8::BindType::DBIStatementHandle
- Defined in:
- lib/dbd/OCI8.rb
Overview
helper class to bind ref cursor as DBI::StatementHandle.
# Create package
dbh.execute(<<EOS)
create or replace package test_pkg is
type ref_cursor is ref cursor;
procedure tab_table(csr out ref_cursor);
end;
EOS
# Create package body
dbh.execute(<<EOS)
create or replace package body test_pkg is
procedure tab_table(csr out ref_cursor) is
begin
open csr for select * from tab;
end;
end;
EOS
# Execute test_pkg.tab_table.
# The first parameter is bound as DBI::StatementHandle.
plsql = dbh.execute("begin test_pkg.tab_table(?); end;", DBI::StatementHandle)
# Get the first parameter, which is a DBI::StatementHandle.
sth = plsql.func(:bind_value, 1)
# fetch column data.
sth.fetch_all
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.decorate(b) ⇒ Object
554 555 556 557 558 559 560 561 562 563 564 565 |
# File 'lib/dbd/OCI8.rb', line 554 def decorate(b) def b.set(val) raise NotImplementedError end def b.get() val = super return val if val.nil? cur = ::OCI8::Cursor.new(@env, @svc, @ctx, val) stmt = DBI::DBD::OCI8::Statement.new(cur) DBI::StatementHandle.new(stmt, true, false) end end |
Instance Method Details
#get ⇒ Object
490 491 492 493 494 495 |
# File 'lib/dbd/OCI8.rb', line 490 def get() val = super return nil if val.nil? stmt = DBI::DBD::OCI8::Statement.new(val) DBI::StatementHandle.new(stmt, true, false) end |
#set(val) ⇒ Object
482 483 484 485 486 487 488 489 |
# File 'lib/dbd/OCI8.rb', line 482 def set(val) if val.is_a? DBI::StatementHandle # get OCI8::Cursor val = val.instance_eval do @handle end val = val.instance_eval do @cursor end end super(val) end |