Home » Open Source » Programming Interfaces » perl database access (7 merged) (oracle 10g)
perl database access (7 merged) [message #686581] Mon, 17 October 2022 11:24
arun888
Messages: 100
Registered: June 2015
Location: INDIA
Senior Member
I need to find out the new shop id where the shop id is missing in the oracle table shoptable. all the processed shop name is present in the shop look up table ran_lookup. I need to print the shop id which is not present in the oracle table by checking the lookup ran_lookup. I have tried the below perl script but it is consuming more time. not sure fetchall_arrayref will get the first column of the data form the table. any other best alternative way to get the first column in the array.
#**********************************************************
#   Read shops from database.
#**********************************************************
sub new_read_shop_lookup {
    my ($ret_code) = @_;
    my $dbh = DBI->connect('dbi:Oracle:ussmft', 'dsu', 'morning', {AutoCommit => 0, RaiseError => 1})
    or die "Unable to connect to Oracle: $!";
    my $sth = $dbh->prepare(qq{ select country_shop_no from shoptable where country_file = ? });
        $sth->execute($ret_code);
    my $array = $sth->fetchall_arrayref();
        foreach (@$array) {
                print "$_ ";
    }
    $dbh1->disconnect;
	return \@array;
    }

&new_read_shop_lookup ($ret_code);

for my $new_shop (sort keys @array) {
       if ( ! defined $ran_lookup{$new_shop} ) {
        print "new shop is $new_shop\n";
      }
    }
Previous Topic: insert the records into table perl
Next Topic: export the query into csv file
Goto Forum:
  


Current Time: Tue May 21 10:32:33 CDT 2024