Re: Problem in using PostgreSQL ODBC driver with VBA

From: Vincenzo Turturro <vincenzo(dot)turturro(at)regione(dot)toscana(dot)it>
To: pgsql-odbc(at)postgresql(dot)org
Subject: Re: Problem in using PostgreSQL ODBC driver with VBA
Date: 2016-11-09 11:06:26
Message-ID: efe15476-1cfc-ceb5-c31d-9469045204c4@regione.toscana.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

Il 08/11/2016 01:58, Tsunakawa, Takayuki ha scritto:
> From: pgsql-odbc-owner(at)postgresql(dot)org
>> [mailto:pgsql-odbc-owner(at)postgresql(dot)org] On Behalf Of Fred Parkinson
>> One thing I now remember from when this issue first appeared is that there
>> was another possible solution.
>> When trying to use FALSE or TRUE in an Access query that uses a postgres
>> boolean, I would get the error:
>> ODBC call failed: ERROR: operator does not exist: boolean = integer;...
>>
>> Apparently you can write an operator and add it to the postgres server,
>> an operator that will perform the comparison between a boolean and an
>> integer.
>> The intern I was working with at the time tried once to write that operator,
>> but when his attempt failed at the first try, we went with the kludge because
>> we were in a hurry and didn't want to spend the time debugging his code.
>>
>> I am not sure but I think the operator was written in PHP. In any case,
>> that might be a fruitful line of inquery given that you can't rewrite a
>> major application to use the kludge I describe below.
> A dirty hack is to run the following UPDATE only once on the target database. You can do this from any program such as psql.
>
> UPDATE pg_cast
> SET castcontext = 'I'
>
> WHERE castsource = 'int'::regtype AND
> casttarget = 'boolean'::regtype;
>
> This will make the type cast from integer to Boolean implicit, enabling the comparison like "WHERE 1 = true".
>
> But implicit casts might cause unexpected trouble. If you find something wrong, revert the castcontext to 'e'.
>
> Regards
> Takayuki Tsunakawa

Arigato !

Thank you very much for your answer.
I tried your suggestion and it worked !

But, in order to have the issue solved, I had to slightly change the SQL
statement you provided:

SET castcontext = 'i' (lowercase)
instead of
SET castcontext = 'I' (uppercase)

Thank you again !

Kon'nichiwa (in Italy is late morning ...)

------------------------------------------------------------
Vincenzo Turturro

Regione Toscana
Direzione generale Governo del territorio
Sistema Informativo Territoriale ed Ambientale

Via di Novoli 26
50127 Firenze

Tel 055 43 83 855
------------------------------------------------------------

In response to

Browse pgsql-odbc by date

  From Date Subject
Next Message Andreas 2016-11-09 18:51:54 SSL with Access VBA
Previous Message Inoue, Hiroshi 2016-11-09 08:15:30 Re: Problem in using PostgreSQL ODBC driver with VBA