Not sure if this is a Perl or Oracle issue. I’m new to both.
I have 1 row in a table. Its value is a number. This number is updated very often.
When I run a select query from Perl to get this value… it is not always the latest value. It is usually an old value. I’ll run the same query through SQLPLUS and I’ll see the correct value… Perl only shows the correct value if I delete the data in the table and insert it again.
So, I’m wondering – is this query somehow being cached?
This is how I’m running the query in Perl:
my $sql_latest_jobID = "SELECT /*+ NOCACHE */ job_number FROM example_table WHERE ID = 1";
my $sth = $dbh->prepare($sql_latest_jobID)
or die "Couldn't prepare statement: " . $dbh->errstr;
$sth->execute();
my @data = $sth->fetchrow_array();
$jobID = $data[0];
I also tried the Query without NOCACHE. Had the same result.
I don’t know Perl, but it seems you are not committing the data and thus Perl does not see the updated value.
Another possibility could be that Perl changes the isolation level to repeatable read. If that was the case, you will need to end the current transaction in Perl (even a SELECT is a transaction!) by issuing a commit or rollback (from within Perl) in order to see the updated value.