Hi all,
Ruby 1.6.8
ruby-dbi 0.18
oracle 0.2.11 (ruby driver)
Oracle 8.1.5 (oracle)
Solaris 9
I’ve noticed a parsing problem with leading sql comments and sql that ends
with a placeholder. For example,
–random comment
select column1, column2
from table1
where somevalue > ?
In both ruby and TORA, this causes oracle error 24374: “define not done
before fetch or execute and fetch”. However, I do not get this error via
sqlplus or TOAD, so I’m fairly certain it’s not an Oracle client side issue.
It appears to be some sort of sql parsing problem.
Interestingly, changing the “?” to a fixed value fixes the parsing error in
ruby-dbi, although TORA still chokes.
Is this an oracle driver problem or a ruby-dbi problem? And can it be fixed
(please)?
Regards,
Dan
I’ve noticed a parsing problem with leading sql comments and sql that ends
with a placeholder. For example,
–random comment
select column1, column2
from table1
where somevalue > ?
In both ruby and TORA, this causes oracle error 24374: “define not done
before fetch or execute and fetch”. However, I do not get this error via
sqlplus or TOAD, so I’m fairly certain it’s not an Oracle client side issue.
It appears to be some sort of sql parsing problem.
Interesting. What’s TORA?
Interestingly, changing the “?” to a fixed value fixes the parsing error in
ruby-dbi, although TORA still chokes.
Is this an oracle driver problem or a ruby-dbi problem? And can it be fixed
(please)?
A workaround would be to add a tautological line to your query. Like
“and 1 < 2”.
Gavin
···
On Friday, January 31, 2003, 2:16:24 AM, Daniel wrote:
Berger, Daniel wrote:
Hi all,
Ruby 1.6.8
ruby-dbi 0.18
oracle 0.2.11 (ruby driver)
Oracle 8.1.5 (oracle)
Solaris 9
I’ve noticed a parsing problem with leading sql comments and sql that ends
with a placeholder. For example,
–random comment
select column1, column2
from table1
where somevalue > ?
In both ruby and TORA, this causes oracle error 24374: “define not done
before fetch or execute and fetch”. However, I do not get this error via
sqlplus or TOAD, so I’m fairly certain it’s not an Oracle client side issue.
It appears to be some sort of sql parsing problem.
Interestingly, changing the “?” to a fixed value fixes the parsing error in
ruby-dbi, although TORA still chokes.
Is this an oracle driver problem or a ruby-dbi problem? And can it be fixed
(please)?
It should be simple to fix. All we have to do is to split the SQL statement into
lines (separated by \n), then sort those out starting with --, and finally join
it again to proceed with the usual tokenizing steps.
I’ll put this into 0.0.19.
Are there problems with “–” comments for other databases than Oracle?
Or should I only process comments for the Oracle-DBD?
Regards,
Michael
···
Regards,
Dan
–
Michael Neumann *** eMail uu9r@rz.uni-karlsruhe.de
I should have posted a more accurate comment. Try this:
–Dan’s query
–random comment
select column1, column2
from table1
where somevalue = ?
The problem, it turns out, is the use of the apostrophe in the comment.
Strangely, this only causes a problem if used in conjunction with a
placeholder. My testing shows that if I replace ‘?’ with a fixed value it
works ok, even with the apostrophe. This tells me that there’s some sort
of parsing issue in sql.rb. At least, that’s my suspicion. I’ll see if
I can find the exact culprit.
Anyway, now you know.
Regards,
Dan
···
On Friday, January 31, 2003, 2:16:24 AM, Daniel wrote:
I’ve noticed a parsing problem with leading sql comments and sql that
ends
with a placeholder. For example,
–random comment
select column1, column2
from table1
where somevalue > ?
Michael Neumann uu9r@rz.uni-karlsruhe.de wrote in message news:20030201110023.GB5574@rz.uni-karlsruhe.de…
Berger, Daniel wrote:
Hi all,
Ruby 1.6.8
ruby-dbi 0.18
oracle 0.2.11 (ruby driver)
Oracle 8.1.5 (oracle)
Solaris 9
I’ve noticed a parsing problem with leading sql comments and sql that ends
with a placeholder. For example,
–random comment
select column1, column2
from table1
where somevalue > ?
In both ruby and TORA, this causes oracle error 24374: “define not done
before fetch or execute and fetch”. However, I do not get this error via
sqlplus or TOAD, so I’m fairly certain it’s not an Oracle client side issue.
It appears to be some sort of sql parsing problem.
Interestingly, changing the “?” to a fixed value fixes the parsing error in
ruby-dbi, although TORA still chokes.
Is this an oracle driver problem or a ruby-dbi problem? And can it be fixed
(please)?
It should be simple to fix. All we have to do is to split the SQL statement into
lines (separated by \n), then sort those out starting with --, and finally join
it again to proceed with the usual tokenizing steps.
I’ll put this into 0.0.19.
Are there problems with “–” comments for other databases than Oracle?
Or should I only process comments for the Oracle-DBD?
Regards,
Michael
Actually Michael, see my “upon further review” message. It turns out
that it only has a problem if there’s an apostrophe in the comment
when used with a placeholder. So, “–random comment” works fine, but
“–Dan’s minstrel wrote this” does not. The problem occurs in the
tokens() method in sql.rb.
Regards,
Dan
Daniel Berger wrote:
I’ve noticed a parsing problem with leading sql comments and sql that
ends
with a placeholder. For example,
–random comment
select column1, column2
from table1
where somevalue > ?
I should have posted a more accurate comment. Try this:
–Dan’s query
–random comment
select column1, column2
from table1
where somevalue = ?
Try out the newest lib/dbi/sql.rb file from CVS or use the attached patch.
Regards,
Michael
sql.rb.diff (2.21 KB)
···
On Friday, January 31, 2003, 2:16:24 AM, Daniel wrote: