require "rubygems"
require "ruby-plsql"
sql = s = IO.read('my_sql_stub.sql')
plsql.connection = OCI8.new("user","pass","db")
plsql.execute(sql)
Thanks in advance for your help.
Probably this script could work:
require "rubygems"
require "ruby-plsql"
plsql.connection = OCI8.new("user","pass","db")
plsql.dbms_output_stream = StringIO.new
sql = File.read('my_sql_stub.sql')
sql.split(';').each do {|s| plsql.execute(s)}
# or you can try to use this if line with single '/' is used as PL/SQL
blocks separator
# sql.split(/^\s*\/\s*$/).each do {|s| plsql.execute(s)}
# get results of DBMS_OUTPUT
puts plsql.dbms_output_stream.string
On Feb 26, 12:41 pm, Raimonds Simanovskis
DECLARE
i_fin_inst_id NUMBER;
i_adv_tax_id VARCHAR2(9);
i_ssn_tin VARCHAR2(23);
i_user_type NUMBER;
i_port_id NUMBER;
more data tyles declared
BEGIN
i_fin_inst_id := 16;
i_adv_tax_id := '123234234';
i_ssn_tin := '232323234';
i_port_id := -1;
i_log_flag := 'Y';
i_flag_arr := sone_string_arr();
i_flag_arr.extend(60);
i_flag_arr(1) := 'Y';
i_flag_arr(2) := 'Y';
i_flag_arr(3) := 'Y';
i_flag_arr(4) := 'N';
i_flag_arr(5) := 'Y';
i_flag_arr(6) := 'N';
i_flag_arr(7) := 'N';
i_flag_arr(8) := 'Y';
i_flag_arr(9) := 'N';
plenty more variables here
somePackage_pkg.someotherPpkg (
o_segment_list => o_segment_list,
o_output_rows => o_header_row,
o_fi_rpt_pkg_disc => o_fi_rpt_pkg_disc,
o_period => o_period,
o_execution_method => o_execution_method,
i_fin_inst_id => i_fin_inst_id,
i_adv_tax_id => i_adv_tax_id,
i_ssn_tin => i_ssn_tin,
i_user_type => i_user_type,
i_port_id => i_port_id);
display_row_data_csv(o_header_row);
dbms_output.put_line('========================');
display_row_data_csv(o_fi_rpt_pkg_disc);
Thanks
BK
On Feb 26, 12:41 pm, Raimonds Simanovskis
<raimonds.simanovs...@gmail.com> wrote:
block then you should be able to do this just with one plsql.execute
call. But why do you want to do that from Ruby with ruby-plsql? In
your case if you want to use more Ruby and less PL/SQL then you can
directly call
plsql.somePackage_pkg.someotherPpkg(...)
and pass necessary parameters and handle results in Ruby. Otherwise
just stick with sqlplus for executing large PL/SQL code blocks :)
Raimonds
On Feb 28, 3:37 am, Raimonds Simanovskis