Using parameters in views



I need a little help with a query.

I have a 2 views and a select:


testCTE AS


select loc, parent, lochierarchyid, locationid

from lochierarchy 

where loc=(select loc from workorder where workorder.wonum='44325333rfsrrhyvf') and locationid=(select locationid from workorder where wonum='44325333rfsrrhyvf')




select lochierarchy.loc, lochierarchy.parent, lochierarchy.lochierarchyid, lochierarchy.locationid, 

from lochierarchy 

join testCTE on lochierarchy.loc = testCTE.parent where lochierarchy.locationid='INTERNATIONAL'



/* Another view here TEST2VIEW */


SELECT (select distinct  l.description from testCTE t1

left outer JOIN testCTE t2 on t1.parent=t2.loc left outer join 

 locations l on l.loc=t1.loc

and l.locationid=t1.locationid


 where l.FIELD='YES') as Community, /* other fields */ from TEST2VIEW where TEST2VIEW.wonum='44325333rfsrrhyvf'



I know that i can define a parameter and connect it to  TEST2VIEW.wonum but if I try to give the same parameter in the first view it doesn't work. Can someone please help me?


Sign In or Register to comment.