From: | redhat0320 <unruly_wind(at)sina(dot)com> |
---|---|
To: | pgsql-cygwin(at)postgresql(dot)org |
Subject: | Re: ERROR: c: permission de |
Date: | 2003-09-02 13:40:49 |
Message-ID: | 20030902134049.20201.qmail@sina.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-cygwin |
Hi, all,
I don't like this syntax:
SELECT * FROM t1 LEFT JOIN t2 ON (t1.num = t2.num);
I prefer:
SELECT * FROM t1, t2 WHERE t1.num *= t2.num; (syntax of Sybase)
or
SELECT * FROM t1, t2 WHERE t1.num(+)= t2.num; (syntax of Oracle)
Because I have many source codes I need to port to PostgreSQL, there are many outer join in the source codes. It's a tired job to rewrite the source codes using the 'LEFT JOIN ... ON' syntax. So I want to write a pair of operators '*=' and '=*' to simulate the behavior of Sybase.
I don't know how to write a join procedure. I'm not familiar with the source codes of PostgreSQL, so this mission seems to hard for me. Who can give me some advice?
I had just started from this code.
outerjoin.sql:
CREATE FUNCTION int_left_outer_join(int, int) RETURNS bool
AS '/usr/src/postgresql-7.3.4-1/src/tutorial/outerjoin' LANGUAGE 'c';
CREATE FUNCTION int_right_outer_join(int, int) RETURNS bool
AS '/usr/src/postgresql-7.3.4-1/src/tutorial/outerjoin' LANGUAGE 'c';
CREATE OPERATOR *= (
leftarg = int,
rightarg = int,
procedure = int_left_outer_join,
join = int_left_outer_join
);
CREATE OPERATOR =* (
leftarg = int,
rightarg = int,
procedure = int_right_outer_join,
join = int_right_outer_join
);
outerjoin.c:
#include "postgres.h"
bool int_left_outer_join(int32 * a, int32 * b);
bool int_right_outer_join(int32 * a, int32 * b);
bool
int_left_outer_join(int32 * a, int32 * b)
{
return ((NULL == a) || (NULL != a && NULL != b && *a == *b));
}
bool
int_right_outer_join(int32 * a, int32 * b)
{
return ((NULL == b) || (NULL != a && NULL != b && *a == *b));
}
______________________________________
===================================================================
5 (http://ad4.sina.com.cn/sina/dangdang0825.html)
From | Date | Subject | |
---|---|---|---|
Next Message | unruly_wind | 2003-09-02 13:42:04 | Re: ERROR: c: permission de |
Previous Message | unruly_wind | 2003-09-02 13:21:52 | Re: ERROR: c: permission de |