2014-01-17 4 views
0

ruby-oci8 gem으로 저장 프로 시저를 실행하려고합니다. 그리고 정상적인 쿼리는 실행할 수 있지만 내 프로 시저는 실행할 수 없습니다.ruby-oci8로 프로 시저 실행

# irb -r oci8 
Warning: NLS_LANG is not set. fallback to US7ASCII. 
irb(main):001:0> conn = OCI8.new('AAA/[email protected]//10.112.68.14:1521/dptedp0') 
irb(main):002:0> conn.exec("SELECT * FROM mytable"){|r| puts r.join(", ")} 
1, user1, data1 
2, user2, data2 
irb(main):003:0> conn.exec("ALTER TRIGGER trigger_mytable_id ENABLE") 
=> 0 
irb(main):004:0> conn.exec("ALTER TRIGGER trigger_mytable_id DISABLE") 
=> 0 

여기까지는 정상적으로 작동하지만 프로 시저를 실행하려고 시도하면 작동하지 않습니다.

irb(main):005:0> conn.exec("EXECUTE reset_seq('mytable_id_seq', 'mytable', 'id')") 
OCIError: ORA-00900: invalid SQL statement 
     from stmt.c:253:in oci8lib_191.so 
     from /opt/ruby/gems/ruby-oci8-2.1.2/lib/oci8/oci8.rb:474:in `exec' 
     from /opt/ruby/gems/ruby-oci8-2.1.2/lib/oci8/oci8.rb:282:in `exec_internal' 
     from /opt/ruby/gems/ruby-oci8-2.1.2/lib/oci8/oci8.rb:275:in `exec' 
     from (irb):9 
     from /usr/bin/irb:12:in `<main>' 

내 절차는 sqldeveloper에서 잘 작동합니다.

execute reset_seq('lrf_id_seq', 'lrf', 'id') 
    anonymous block completed 

나는 값을 반환하지 않습니다. oci8 gem에서 이와 같은 프로 시저를 실행할 수 있습니까?

내가 사용하고 : 루비 1.9.3p429 루비 OCI8을 (2.1.2)

답변

3

는 루비/OCI8에서 인식하지 EXECUTE - 당신은 당신의 전화 대신 익명 PL/SQL 블록을 insided 포장한다 :

require 'oci8' 

conn = OCI8.new('AAA/[email protected]//10.112.68.14:1521/dptedp0') 
conn.exec("begin reset_seq('mytable_id_seq', 'mytable', 'id'); end;") 
+0

탱크하면, 그것은 EXECUTE 참고로 완벽하게 – fabio

+2

를 작동하는 SQLPLUS 명령입니다. Sqlplus는 'EXECUTE xxxx'를 'xxxx를 시작합니다. 종료;' 변환 된 문자열을 Oracle 서버로 보냅니다. –