Querying multiple times in Oracle using perl retur

2020-05-10 09:14发布

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";
 }

1条回答
狗以群分
2楼-- · 2020-05-10 09:25

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.

查看更多
登录 后发表回答