Oracle 使用1个值调用bind_列,但需要2个值

Oracle 使用1个值调用bind_列,但需要2个值,oracle,perl,dbi,Oracle,Perl,Dbi,我试图理解为什么我有以下问题 我正在编写一个小的Perl脚本,从这里和那里获取一些示例,添加一些我自己的示例 我所做的是将查询存储在cfg文件中,根据传递的参数检索查询,执行并返回一个值 use strict; use warnings; ... $comm = 'tablespace_critical'; # In the real script, this is a command-line argument. ... my $query = "$CFG::CFG{'checks'}{$co

我试图理解为什么我有以下问题

我正在编写一个小的Perl脚本,从这里和那里获取一些示例,添加一些我自己的示例

我所做的是将查询存储在cfg文件中,根据传递的参数检索查询,执行并返回一个值

use strict;
use warnings;
...
$comm = 'tablespace_critical'; # In the real script, this is a command-line argument.
...
my $query = "$CFG::CFG{'checks'}{$comm}{'query'}";
# this part was literally copied from another script
# that didn't used the strict and warnings.
#---------------------------------------------------
my $query_handle = $dbh->prepare($query);
my $result;

$query_handle->execute();
$query_handle->bind_columns( \$result);
$result=$query_handle->fetchrow_array();
$query_handle->finish;
$dbh->disconnect();
#---------------------------------------------------
*.cfg

%CFG = (
    'tablespace_critical' => {
        'query'     => "select x\.tablespace_name,x\.used_pct from (select a\.tablespace_name,((total_space-free_space)/total_space)*100 used_pct from (select tablespace_name,sum(bytes)/(1024*1024) total_space from dba_data_files group by tablespace_name) a, (select tablespace_name,sum(Bytes)/(1024*1024) free_space from dba_free_space group by tablespace_name) b where a\.tablespace_name = b\.tablespace_name(+)) x, mon_control y where x\.tablespace_name = y\.name(+) and y\.monitoring_type (+) = 'TABLESPACE' and x\.used_pct >= decode (y\.err_value,-1,NULL,NULL,90,y\.err_value)"
    }    
)
在最初的脚本中,这没有任何麻烦,但是在这里,我得到了用1个值调用的
bind\u列,但需要2个
。配置中存储了几个查询,这是唯一一个出现问题的查询。Perl并不是我真正喜欢的东西,所以我仍在研究一些薄弱的概念,但我已经花了很多时间,所以我希望你能帮我一把


注意。

您正在执行一个提取两个值的查询:

select x.tablespace_name, x.used_pct from ... 
       ^^^                ^^^
       1st field          2nd field
因此,我们希望您也绑定两个标量

$query_handle->bind_columns( \$result);    # <-- only a single variable

这是我的想法,但是,正如我在片段中所说的,另一个脚本对同一个查询执行相同的操作(我正在将所有执行相同操作的脚本合并为一个脚本)可以工作!我想,除了解决这个问题(你的建议可能会,我会去看看),我更想做的是了解那里发生了什么。我猜是因为严格,但我真的说不出来。
$query_handle->execute();
my @result = $query_handle->fetchrow_array();