Привет. Засунь в отдельную процедуру/вьюху
for select gd.nm,gd.fprn, unt.nm as unt, gd.qinp, gd.prub as prub,sec.nm as sec from gd inner join unt unt on (gd.id_unt = unt.id) inner join sec sec on (gd.id_sec = sec.id) Order By id_sec, gd.nm INTO :nm,:fprn,:unt,:qinp,:prub,:sec /* для процедуры */ Ну а в основной процедуре проверяй условия и накладывай свое дополнительное where. Что-то вроде: If (fprn>0) then For select nm,unt,qinp,prub,sec From subprocedure Where fprn=1 Into :nm,:unt,:qinp,:prub,:sec Do suspend; Else For select nm,unt,qinp,prub,sec From subprocedure Into :nm,:unt,:qinp,:prub,:sec Do suspend; WBR, Dmitry Beloshistov AKA [-=BDS=-] __________ Eioi?iaoey io ESET NOD32 Antivirus, aa?ney aacu aaiiuo neaiaoo? ae?onia 3568 (20081030) __________ Niiauaiea i?iaa?aii i?ia?aiiie ESET NOD32 Antivirus. http://www.esetnod32.ru