在Oracle中使用perl查询多次只返回第一个查询 [英] Querying multiple times in Oracle using perl returns only the first query

查看:132
本文介绍了在Oracle中使用perl查询多次只返回第一个查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:我已经更正了变量差异,它打印来自第一个集合的查询,但它不返回任何从第二个集合。如果我使用第二个集合只有它工作。



在下面的代码中,我有some_array数组数组包含文本像名称。所以
@ some_array =([sam,jon,july],[Mike,Han,Tommy],[angie,sita,lanny]
现在当我查询列表,如'sam jon july'第一和'mike han tommy'。只有execute从第一个列表返回结果,其他的是undef。我不知道为什么会有任何帮助。

 我的$指针; 
my $ db = $ db-> prepare_cached(
begin
:pointer:= myFun(:A1);
end;
无法准备stat:。 $ db-> errstr;
$ db-> bind_param_inout(:pointer,\ $ pointer,0,{ora_type => ORA_RSET});

for(my $ i = 0; $ i< @some_array; $ i ++){
my @firstarray = @ {$ some_array [$ i]};
my $ sql = lc(join(,@firstarray));
print< pre> $ sql< / pre> \\\
;
$ db-> bind_param(:A1,$ sql);
$ db-> execute();
print< pre>。Dumper($ db-> execute())。< / pre> \\\

}


解决方案

您提出的最后一个问题,初始化您的数组括号,而不是嵌套的括号。

  @ some_array =([sam,jon,july],[Mike,Han,Tommy] [angie,sita,lanny])

不是

  @ some_array = [[sam,jon,july],[Mike,Han,Tommy],[angie,sita,lanny]] 



 使用strict; 
使用警告;

。这将捕获你尝试初始化 @some_array 的奇怪的方式,它会捕获你的不一致的使用 @sql @query 更新 $ sdh $ db $ dbh


Note: I have corrected the variable differences and it does print the query from the first set but it returns nothing from the second set. If I use the second set only it works.

In the code below, I have some_array which is array of array the array contains text like name. So @some_array= ([sam, jon, july],[Mike, Han,Tommy],[angie, sita, lanny]); Now when I querying the list like 'sam jon july' first and 'mike han tommy' . Only the execute return the result from the first list others is undef. I don't know why any help will be appreciated.

my $pointer;
my $db = $db->prepare_cached("
        begin
                :pointer := myFun(:A1);
        end;
                ") or die "Couldn't prepare stat: " . $db->errstr;
$db->bind_param_inout(":pointer",\$pointer,0,{ ora_type => ORA_RSET });

for (my $i=0; $i < @some_array ; $i++) {
        my @firstarray = @{$some_array[$i]};
        my $sql = lc(join(" ", @firstarray));
        print "<pre>$sql</pre>\n";
        $db->bind_param(":A1",$sql);
        $db->execute();
        print "<pre>".Dumper($db->execute())."</pre>\n";
 }

解决方案

Just like everyone told you on the last question you asked, initialize your array with parentheses, not nested brackets.

@some_array= ([sam, jon, july],[Mike, Han,Tommy],[angie, sita, lanny])

not

@some_array= [[sam, jon, july],[Mike, Han,Tommy],[angie, sita, lanny]]

You would also benefit tremendously from including

use strict;
use warnings;

at the top of all of your programs. That would catch the strange way you are trying to initialize @some_array, and it would catch your inconsistent usage of @sql and @query. update and $sdh and $db and $dbh.

这篇关于在Oracle中使用perl查询多次只返回第一个查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆