Class: DBI::DBD::OCI8::BindType::DBIStatementHandle
- Inherits:
-
OCI8::BindType::Cursor
- Object
- OCI8::BindType::Cursor
- DBI::DBD::OCI8::BindType::DBIStatementHandle
- Defined in:
- lib/DBD/OCI8/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
527 528 529 530 531 532 533 534 535 536 537 538 |
# File 'lib/DBD/OCI8/OCI8.rb', line 527 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 |
.fix_type(env, val, length, precision, scale) ⇒ Object
523 524 525 526 |
# File 'lib/DBD/OCI8/OCI8.rb', line 523 def fix_type(env, val, length, precision, scale) raise NotImplementedError unless val.nil? [::OCI8::SQLT_RSET, nil, env.alloc(OCIStmt)] end |
Instance Method Details
#get ⇒ Object
463 464 465 466 467 468 |
# File 'lib/DBD/OCI8/OCI8.rb', line 463 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
455 456 457 458 459 460 461 462 |
# File 'lib/DBD/OCI8/OCI8.rb', line 455 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 |