This is an example of my view.
create view VIEWTEST as
select
'1' as TYPE,
TABLE1.KEYFIELD1 as KEYFIELD1,
'' as KEYFIELD2,
'' as KEYFIELD3,
TABLE1.FIELDX as FIELD1
from TABLE1
when TABLE1.FIELDS = TABLE2.FIELDS
union all SELECT
'2' as TYPE,
'' as KEYFIELD1,
TABLE2.KEYFIELD10 as KEYFIELD2,
'' as KEYFIELD3,
TABLE2.FIELDW as FIELD1
from TABLE2
where ((TABLE2.FIELDK = '0') or (TABLE2.FIELDK='2'))
union all SELECT
'3' as TYPE,
'' as KEYFIELD1,
'' as KEYFIELD2,
TABLE2.KEYFIEL10 as KEYFIELD3,
TABLE2.FIELDW as FIELD1
from TABLE2
where ((TABLE2.FIELDK = '1'))
My problem is that TABLE1 (TYPE 1)
occours only when TABLE2.FIELDK = '0' or TABLE2.FIELDK = '2' (only for union with TYPE='2')
I tried (row 11) with
when TABLE1.FIELDS = TABLE2.FIELDS and ((TABLE2.FIELDK = '0') or (TABLE2.FIELDK='2'))
but it doesn't work.
Any suggestion?
Thanks in advance
create view VIEWTEST as
select
'1' as TYPE,
TABLE1.KEYFIELD1 as KEYFIELD1,
'' as KEYFIELD2,
'' as KEYFIELD3,
TABLE1.FIELDX as FIELD1
from TABLE1
when TABLE1.FIELDS = TABLE2.FIELDS
union all SELECT
'2' as TYPE,
'' as KEYFIELD1,
TABLE2.KEYFIELD10 as KEYFIELD2,
'' as KEYFIELD3,
TABLE2.FIELDW as FIELD1
from TABLE2
where ((TABLE2.FIELDK = '0') or (TABLE2.FIELDK='2'))
union all SELECT
'3' as TYPE,
'' as KEYFIELD1,
'' as KEYFIELD2,
TABLE2.KEYFIEL10 as KEYFIELD3,
TABLE2.FIELDW as FIELD1
from TABLE2
where ((TABLE2.FIELDK = '1'))
My problem is that TABLE1 (TYPE 1)
occours only when TABLE2.FIELDK = '0' or TABLE2.FIELDK = '2' (only for union with TYPE='2')
I tried (row 11) with
when TABLE1.FIELDS = TABLE2.FIELDS and ((TABLE2.FIELDK = '0') or (TABLE2.FIELDK='2'))
but it doesn't work.
Any suggestion?
Thanks in advance