--
-- ### View in subselect check 
--

-- this check validates an effect occured with version 2.47.8 and below
-- for views in subselects, the attribute references have been not resolved correctly

drop if exists table sr;
create table sr ( srid int, srcode int);

drop if exists table vt;
create table vt ( vtid int, srid int, vtcode int);

drop if exists table svmap;
create table svmap ( srcode int, vtcode int);

drop if exists view srvtview;
create view srvtview as select vt.vtid as vtid, sr.srcode as srcode, vt.vtcode as vtcode from sr, vt where vt.srid = sr.srid ;
 
insert into sr values ( 1, 42);
insert into sr values ( 2, 43);
insert into vt values ( 1, 1, 4711);
insert into vt values ( 2, 1, 4712);
insert into vt values ( 2, 2, 4713);
 
insert into svmap values ( 42, 4711 );
insert into svmap values ( 44, 11);

select * from srvtview;
 
select * from svmap m where not exists ( select vtid from srvtview v where v.srcode = m.srcode and v.vtcode = m.vtcode );
 
-- Error : Unknown attribute field <m.vtcode>
