/[sql]/access_fix.sql
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /access_fix.sql

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Fri Feb 22 17:46:58 2002 UTC (20 years, 9 months ago) by dpavlin
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +12 -2 lines
come documentation

1 -- you will need this function if you are using row versioning
2 -- according to http://odbc.postgresql.org/psqlodbc.php?DocID=faq-advanced#rowversioning you might not need it at all...
3
4 drop function int4eq(xid,int4);
5 drop operator = (xid,int4) ;
6
7 create function int4eq(xid,int4)
8 returns bool
9 as ''
10 language 'internal';
11
12 create operator = (
13 leftarg=xid,
14 rightarg=int4,
15 procedure=int4eq,
16 commutator='=',
17 negator='<>',
18 restrict=eqsel,
19 join=eqjoinsel
20 );
21
22
23 -- we need operators which can complare int and bool (because boolean type
24 -- in Access are really integers when they finish thair way through optimizer
25
26 DROP OPERATOR = (bool, int4);
27 DROP OPERATOR = (int4, bool);
28
29 DROP FUNCTION MsAccessBool1 (bool, int4);
30 CREATE FUNCTION MsAccessBool1 (bool, int4) RETURNS BOOL AS '
31 BEGIN
32 IF $1 ISNULL THEN
33 RETURN NULL;
34 END IF;
35
36 IF $1 IS TRUE THEN
37 IF $2 <> 0 THEN
38 RETURN TRUE;
39 END IF;
40 ELSE
41 IF $2 = 0 THEN
42 RETURN TRUE;
43 END IF;
44 END IF;
45 RETURN FALSE;
46 END;
47 ' LANGUAGE 'plpgsql';
48
49 CREATE OPERATOR = (
50 LEFTARG = BOOL,
51 RIGHTARG = INT4,
52 PROCEDURE = MsAccessBool1,
53 COMMUTATOR = '=',
54 NEGATOR = '<>',
55 RESTRICT = EQSEL,
56 JOIN = EQJOINSEL
57 );
58
59 -- this is reverse of above
60
61 DROP FUNCTION MsAccessBool2 (int4, bool);
62 CREATE FUNCTION MsAccessBool2 (int4, bool) RETURNS BOOL AS '
63 BEGIN
64 IF $2 ISNULL THEN
65 RETURN NULL;
66 END IF;
67
68 IF $2 IS TRUE THEN
69 IF $1 <> 0 THEN
70 RETURN TRUE;
71 END IF;
72 ELSE
73 IF $1 = 0 THEN
74 RETURN TRUE;
75 END IF;
76 END IF;
77 RETURN FALSE;
78 END;
79 ' LANGUAGE 'plpgsql';
80
81 CREATE OPERATOR = (
82 LEFTARG = int4,
83 RIGHTARG = bool,
84 PROCEDURE = MsAccessBool2,
85 COMMUTATOR = '=',
86 NEGATOR = '<>',
87 RESTRICT = EQSEL,
88 JOIN = EQJOINSEL
89 );
90
91 -- this is generaly not possible. However, when using boolean fields in
92 -- PostgreSQL and Access you will need not on int type.
93 -- so, if possible, rename this function to not
94
95 DROP FUNCTION xnot (int4);
96 CREATE FUNCTION xnot (int4) RETURNS BOOL AS '
97 BEGIN
98 IF $1 IS NULL THEN
99 RETURN NULL;
100 END IF;
101
102 IF $1 == 0 THEN
103 RETURN TRUE;
104 END IF;
105 RETURN FALSE;
106 END;
107 ' LANGUAGE 'plpgsql';
108

  ViewVC Help
Powered by ViewVC 1.1.26