Reputation: 10855
I am having a strange issue here with perl and DBI module. I can get the query successfully sometimes, but sometimes, when I add a line of code which is remotely related to database access or anything like that, I got an error saying:
DBD::Oracle::st fetchrow_array failed: ERROR no statement executing (perhaps you need to call execute first) [for Statement "select * from (...)"] at script.pl line 18.
I verified using sqlplus that my select command has no problem here (of course, that is why I said the script worked sometimes!)
If I added a semicolon after the select command in the perl script, I got another error saying:
DBD::Oracle::db prepare failed: ORA-00911: invalid character (DBD ERROR: error possibly near <*> indicator at char 970 in 'select * from (...)<*>;') [for Statement "select * from (...);"] at script.pl line 13.
Can anyone please suggest to me what is going on here? Is it because the sql command is too long (~900 chars)?
Upvotes: 1
Views: 9087
Reputation: 5992
That error means you've prepared a statement but not executed it. You may also get it if you prepared a statement, executed it and fetched all the rows then call fetch again but I'm less sure about that. Don't put semi-colons on the end of your SQL in this case as it is not required.
See https://metacpan.org/pod/DBI#Executed for th executed attribute.
Upvotes: 2
Reputation: 482
I had the same issue, and I notice that I had a fetchrow_array after a fetch, that was the problem.
while ($sth->fetch) {
sth->fetchrow_array;
$myvar = some logic here
$myvar2 = some other logic here
}
I removed the sth->fetchrow_array; and now everything is working :)
Upvotes: 0