Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 错误-Ruby OCI8-参数数目错误(2代表0..1)_Sql_Ruby_Oracle_Oci8 - Fatal编程技术网

Sql 错误-Ruby OCI8-参数数目错误(2代表0..1)

Sql 错误-Ruby OCI8-参数数目错误(2代表0..1),sql,ruby,oracle,oci8,Sql,Ruby,Oracle,Oci8,运行此脚本时: require 'oci8' conn = OCI8.new('username', 'password', 'tnsname') cursor = conn.exec('SELECT 1+1 FROM dual') while r = cursor.fetch() puts r.join(',') end cursor.close conn.logoff 出现以下错误消息: C:/tech/Ruby193/lib/ruby/site

运行此脚本时:

require 'oci8'

  conn = OCI8.new('username', 'password', 'tnsname')
  cursor = conn.exec('SELECT 1+1 FROM dual')

  while r = cursor.fetch()
    puts r.join(',')
  end

  cursor.close
  conn.logoff
出现以下错误消息:

   C:/tech/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `initi
alize': wrong number of arguments (2 for 0..1) (ArgumentError)
        from C:/tech/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb
:36:in `new'
        from C:/tech/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb
:36:in `require'
        from C:/tech/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb
:36:in `require'
        from C:/tech/Ruby193/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.1.5-x86-mingw3
2/lib/oci8.rb:81:in `<top (required)>'
        from C:/tech/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb
:60:in `require'
        from C:/tech/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb
:60:in `rescue in require'
        from C:/tech/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb
:35:in `require'
        from u:/Ruby/test_oci_connect.rb:1:in `<main>'
C:/tech/Ruby193/lib/ruby/site\u ruby/1.9.1/rubygems/custom\u require.rb:36:in`initi
alize':参数数目错误(2代表0..1)(ArgumentError)
来自C:/tech/Ruby193/lib/ruby/site\u ruby/1.9.1/rubygems/custom\u require.rb
:36:在“new”中
来自C:/tech/Ruby193/lib/ruby/site\u ruby/1.9.1/rubygems/custom\u require.rb
:36:在'require'中
来自C:/tech/Ruby193/lib/ruby/site\u ruby/1.9.1/rubygems/custom\u require.rb
:36:在'require'中
来自C:/tech/Ruby193/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.1.5-x86-mingw3
2/lib/oci8.rb:81:in`'
来自C:/tech/Ruby193/lib/ruby/site\u ruby/1.9.1/rubygems/custom\u require.rb
:60:在'require'中
来自C:/tech/Ruby193/lib/ruby/site\u ruby/1.9.1/rubygems/custom\u require.rb
:60:在“紧急救援”中
来自C:/tech/Ruby193/lib/ruby/site\u ruby/1.9.1/rubygems/custom\u require.rb
:35:require中的'require'
from u:/Ruby/test\u oci\u connect.rb:1:in`'

我可以在SQLPLUS中使用这些凭据,并且我已经安装了gems和devkit。是否有人可以帮助解决此问题,或者就下面的答案提供一些说明?

此问题是由于Oracle DLL体系结构与Ruby安装不匹配,或者您的系统找不到正确的DLL造成的

下载。重要的是,它与您的Ruby位于同一拱门中,因为它包含必要的DLL

将其解压缩到硬盘上的某个位置,例如: C:/OracleInstantClient C:/OracleInstantClient也很方便地同时添加这两者 /network/admin/sqlnet.ora /network/admin/tnsnames.ora /network/admin/sqlnet.ora /network/admin/tnsnames.ora到该文件夹


将即时客户端的位置添加到系统路径。如果添加了正确的连接信息,您现在应该能够连接而不出现错误。

该问题似乎与OCI8无关

你没有显示全部代码,这有点误导我们

从错误堆栈跟踪中,我可以看出您有一个试图初始化的类,但是您已经为该方法定义了一个参数,并且在创建对象时没有提到它

这真正的意思是,您提到了两个参数,其中它不需要任何参数,或者只需要一个参数


如果您创建一个test.rb fiel并粘贴您首先向我们展示的代码,它会工作吗?

我使用依赖于ruby-oci8(datamapper的dm oracle适配器)的gem收到了相同的错误消息。 在新环境中按照以下说明重新运行安装:

仔细检查路径设置是否正确,然后重新启动我的ruby控制台。 一切都很顺利

在它不工作的机器上(上述参数错误),我为其他一些服务安装了Oracle 64位DLL。我的理论是,它与这些DLL相冲突(Ruby-oci8需要32位DLL),即使路径中没有指向这些DLL的内容


另外,如果您在运行“gem install ruby-oci8”时收到警告“ext/oci8 not found”,那么让我为您节省一些时间。在我的情况下,这只是一个转移视线的问题,根本不会影响gem的功能。

我已经安装了Oracle即时客户端(32位版本),但我已经设置了如下新的系统变量:ORA\u HOME-C:\Oracle\product\10.2.0\Client\u 1 TNS\u ADMIN-C:\Oracle\product\10.2.0\Client\u 1\NETWORK\ADMIN(sqlnet.ora和tnsnames.ora文件所在的位置)。不幸的是,返回了相同的错误。我遇到了相同的问题。我发现最好删除双变量,只将位置添加到系统路径。系统变量-路径现在包含:“C:\Program files\Business Objects\Common\3.5\bin\NOTES\”;“C:\Program Files\Business Objects\Common\3.5\bin\NOTES\DATA\”;%SystemRoot%\system32;C:\tech\Ruby193\bin;C:\oracle\product\10.2.0\client\u 1;C:\oracle\product\10.2.0\client\u 1\NETWORK\ADMIN-仍然没有更改。只需添加C:/[即时客户端的路径]位置到您的路径。另外,请记住重新启动控制台。因此,我在PATH变量中输入了以下内容:
C:\oracle\product\10.2.0\client\u 1
,并且我已将sqlnet.ora和tnsnames.ora添加到该目录中,但仍然出现相同的错误。还有什么想法吗?我报告了相同的问题。但问题尚未解决。请参阅