在Oracle中使用perl查询多次只返回第一个查询 [英] Querying multiple times in Oracle using perl returns only the first query
问题描述
注意:我已经更正了变量差异,它打印来自第一个集合的查询,但它不返回任何从第二个集合。如果我使用第二个集合只有它工作。
在下面的代码中,我有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屋!