Создать процедуру из запроса...
select (select wares.waremainname from wares where wares.warecode=@wareName) as WareName,
OIR.OtInDate as CURRENTDATE,
(OIR.OtInNdsMode*0.2+1)*LINES.OTINLNPRICE*LINES.OTINLNCOUNT*crnc.ratemaincoef as Summa,
(select mngr.mngrname from managers mngr where mngr.mngrcode=@mngrName) as ManagersName,
mngr.mngrname
from ((OutInvoiceReestr OIR
join Firms F on OIR.OtInFirmCode=F.FirmCode
join MANAGERS MNGR on OIR.OTINMNGR = MNGR.MNGRCODE
join OUTINVOICELINES LINES on OIR.OTINCODE = LINES.OTINLNDOCMCODE)
join WARES on WARES.WARECODE=LINES.OTINLNWARECODE)
left join MngrInGroupe(OIR.OtInMngr, @mngrName) on 1=1
left join WAREINGROUPE(WARES.WARECODE, @wareName) WG on 1=1
left join ratecrnc crnc on crnc.ratedate<=OIR.OtInDate
where (OIR.OtInDate>='@begDate' and
OIR.OtInDate<='@endDate') and
(RMNGRINGROUPE=1 or 0>@mngrName) and
(WG.rWAREINGROUPE=1 or 0>@wareName) and
crnc.ratecrnccode=OIR.OtInCrncCode and
crnc.ratedate = (SELECT max(crnc.ratedate) from ratecrnc crnc)
order by WARES.WAREMAINNAME, OIR.OTINDATE
где MngrInGroupe и WAREINGROUPE-процедуры, @xxxxx - параметры, передаваемые программой...
...подскажите, как создать процедуру из этого запроса!!!!
Сервер - InterBase 5.6