Domains, casts, and MS Access - Mailing list pgsql-sql

From Peter Koczan
Subject Domains, casts, and MS Access
Date
Msg-id AANLkTi=3HQborwBRTMfiPtKDFzRzQLtkHJ-E=m31vkUT@mail.gmail.com
Whole thread Raw
Responses Re: Domains, casts, and MS Access  (Richard Broersma <richard.broersma@gmail.com>)
List pgsql-sql
Hi all,

I'm working on porting an old MS Access form application from Sybase
to postgres/ODBC as part of a larger database port project.

One of the snags that's popped up is that there's some incompatibility
between data types. Specifically, many fields are the Sybase type
"bit", which is basically a boolean, but it accepts and displays
bareword 1 and 0 instead of 't' and 'f'. For the sake of compatibility
(especially bareword integers in queries), I've defined a 'sybit' type
in postgres to be a domain.

=> create domain sybit as smallint check ( value in (0,1) );

That is compatible behavior for most applications, but Access gets
confused since it wants to map it to an integer instead of a boolean
(it does the right thing for a native Sybase driver). I thought that
creating casts between sybit and boolean might help, but that won't
work so much it seems.

=# create cast (sybit as smallint) without function as implicit;
CREATE CAST
=# create cast (sybit as integer) with function int4(smallint) as implicit;
CREATE CAST
=# create cast (sybit as boolean) with function bool(integer) as assignment;
ERROR:  argument of cast function must match or be binary-coercible
from source data type

Is there a way to tell Access to do the right thing, or is there a
better way to define the type/domain, or is there some better product
to use?

Thanks much,
Peter

P.S. In case people are interested in the specifics of the sybase
"bit" type, you can look at
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.blocks/html/blocks/blocks54.htm.


pgsql-sql by date:

Previous
From: Kenneth Marshall
Date:
Subject: Re: Some quick questions
Next
From: John Hasler
Date:
Subject: Re: What does PostgreSQL do when time goes backward?