On 04-Feb-2002 Jeff Urlwin wrote:
> Martin,
> 
> I didn't think that I ever simply substituted " for ' (since it was an issue
> before and I couldn't remember what it was).  However, what recently
> happened was that someone was trying to insert something like:
>       insert into foo (DATECOL) VALUES ('01-JAN-1987 00:00:00')
> 
> and DBD::ODBC was turning that into:
>       insert into foo (DATECOL) VALUES ('01-JAN-1987 00??')

That is what happened to us.
Previously timestamps in ' worked fine, an upgrade to 0.32 broke them and an
further upgrade to 0.33_1 fixed them again.
 
> That's very bad...so, I added the ability to use ' and " for quoting.
> 
> Can you give me an example of why this is bad?
> 
> Thanks,
> 
> Jeff

It appears DBD::ODBC 0.32 contained:

    while(*src) {
        /*
         * JLU 10/6/2000 fixed to make the literal a " instead of '
         */
        if (*src == '"')
            in_literal = ~in_literal;
        if ((*src != ':' && *src != '?') || in_literal) {
            *dest++ = *src++;
            continue;
        }

and DBD::ODBC 0.28 contained:

    while(*src) {
        /*
         * JLU 10/6/2000 fixed to make the literal a " instead of '
         */
        if (*src == '"')
            in_literal = ~in_literal;
        if ((*src != ':' && *src != '?') || in_literal) {
            *dest++ = *src++;
            continue;
        }

and DBD::ODBC 0.33_1 is now

    while(*src) {
        /*
         * JLU 10/6/2000 fixed to make the literal a " instead of '
         * JLU 1/28/2001 fixed to make literals either " or ', but deal
         * with ' "foo" ' or " foo's " correctly (just to be safe).
         * 
         */
        if (*src == '"' || *src == '\'') {
            if (!in_literal) {
                literal_ch = *src;
                in_literal = 1;
            } else {
                if (*src == literal_ch) {
                    in_literal = 0;
                }
            }
        }

It just looked to me like we were see-sawing.

BTW, SQL_INDENTIFIER_QUOTE is not (as I said previously) the right SQLGetInfo
value to use here. It is perhaps best to stick to checking for ' and " if some
databases use ". I had thought the best way to do this was to ask the database
driver what quote shoul dbe used but I cannot find that value at the moment.

Martin


> 
>> -----Original Message-----
>> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
>> Behalf Of [EMAIL PROTECTED]
>> Sent: Monday, February 04, 2002 7:18 AM
>> To: [EMAIL PROTECTED]
>> Subject: Quoted Identiers - problem in DBD::ODBC 0.32
>>
>>
>> I installed DBD::ODBC 0.32 on a machine a few weeks ago and unnotticed by
>> myself (while a colleague was away on holiday) some of his cron
>> jobs using Perl
>> and DBD::ODBC were failing. These used to work. It appears it was
>> the change in
>> dbd_preparse() to use " as the quote chr instead of '. I notice
>> that DBD::ODBC
>> 0.33_01 test release has the ' back again but in addition to ".
>>
>> Can this not be a call to SQLGetInfo for SQL_IDENTIFIER_QUOTE
>> which is getinfo
>> number 29?
>>
>> Hopefully, this would then work for any identifier quote chr.
>>
>> Martin
>> --
>> Martin J. Evans
>> Easysoft Ltd, UK
>> Development
>>
>>

--
Martin J. Evans
Easysoft Ltd, UK
Development

Reply via email to