nmerriweather has asked for the wisdom of the Perl Monks concerning the following question:

DBI uses ? as the placeholder character.

Does anyone know if its possible to override it and use another character?

I'm doing a lot of multi-language development for a project, and I'm can't use stored procedures in my database ( the db supports them, but I'm can't use them until stage 2 of this project, which is in a month). Right now i store the SQL statements and regex them to have the correct bind placeholder ( ? for perl , %s for python )

If i could strip that step out somehow, i'd be happy. anyone have a clue?

and yes, this is a halfassed hack I'm looking for. its not a permanent solution.
  • Comment on overriding the placeholder charcter in DBI?

Replies are listed 'Best First'.
Re: overwriting the placeholder charcter in DBI?
by helphand (Pilgrim) on Mar 23, 2006 at 04:31 UTC
    Does anyone know if its possible to overwrite it and use another character?

    You cannot override the placeholder in DBI. DBI itself doesn't use placeholders, it's the underlying driver for the database engine that interprets the placeholder.

    This is pretty clearly documented in the DBI documentation.

    Scott

Re: overwriting the placeholder charcter in DBI?
by renodino (Curate) on Mar 23, 2006 at 01:21 UTC
    DBI uses ? as the placeholder character.

    Well...yes and no. SQL tends to use '?' as the placeholder (IIRC, its actually part of the std. for embedded SQL). However, variant dialects often use other things, e.g., :1, or :name are common.

    If python is using '%something', thats either (a) specific to the DBMS in question or (b) a peccadillo of python (for which python should be shamed!) (I'm blissfully ignorant of python, as every time I try learning it, it bitches about my indentation style).

    So I fear you're stuck w/ your regex. Or you should complain to the keepers of Python for varying from the SQL std., to which the DBI does its best to adhere.