Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

djberg96 (2603)

  (email not shown publicly)

Journal of djberg96 (2603)

Thursday January 30, 2003
02:00 PM

Apostrophe hell with SQL

[ #10300 ]
Bonus points if you can figure out what might cause problems with this bit of sql:

--Dan's minstrel wrote this sql
select column1, column2
from sometable
where column1 = ?

Any guesses?

Perl's DBI (or perhaps Oracle's DBD) parses this sql properly. However, TOAD, TORA and Ruby's DBI do not. The problem, believe it or not, is the apostrophe when combined with a placeholder (although TORA seems to choke even with a hard coded value). It seems everything east of the apostrophe (inlcuding the apostrophe) is getting lumped together with the "select" clause.

I can't speak for TOAD, but the problem in Ruby's DBI lies in the simple lexer it uses to parse sql when placeholders are used. Shouldn't be too hard to fix, though.

Only five hours of work down the tubes thanks to this bug. No biggie. GAH!

Update: Michael Neumann has fixed this for the next release. Hooray!

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Are you trying to pass a comment through DBI? That's an iffy proposition. It's been my experience that database client tools do a bit of preprocessing before shipping SQL to the server, and part of that preprocessing is to strip comments.