I have written following code to get data from starting table
select * from starting where PID in
(
select I.InstID from Inst I,
Trus T where I.TrusID=75 and T.TrusId= 75 and I.InstID = 54 and I.InstStatusID=1
)
Now I want to get "TrusID" and "InstID" dynamically to variable from another tables (lets say "Trus" and "Inst") and pass these as parameter to above query and run in a loop for each "TrusID" and "InstID" I got. How can I do this?