[DB-SIG] :1 vs. :arg variables in SQL (oracle interface).

Jim Fulton jim.fulton@Digicool.com
Tue, 29 Sep 1998 07:37:34 -0400


Anthony Baxter wrote:
> 
> Strangely, the thought of writing an SQL parser makes me twitch.

I don't think you actually need to write a full parser.  All you
have to worry about is not messing with ":1" that might be buried
in a string literal. Right?  Further, the rules for SQL string literals
make this pretty easy to avoid.

Something along the lines of (a better algorithm, 
avoiding regsub should be used):

  ssql=string.split(sql,"'")
  for i in range(0,2,len(ssql)):
    ssql[i]=regsub.gsub(':\([0-9]+\)',':p\\1',ssql[i])
  sql=string.join(sql,"'")
  
should work fine. No?  Can you think of any Oracle SQL that
would defeat this?

Jim

-- 
Jim Fulton           mailto:jim@digicool.com
Technical Director   (888) 344-4332             Python Powered!
Digital Creations    http://www.digicool.com    http://www.python.org

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.