sql003 存储过程

CREATE OR REPLACE Procedure SP_GETSUMMARY_OILTUBE(well in varchar2,kgsj in varchar2,p_cursor  out ego.cursorType)
as
begin
open p_cursor for
       select decode(xh,'',gjmc,xh) xh,kgrq,GJMC,GJSD,gjxh,gjcd from (
       select decode(xh1,'',xh,xh1) as xh,kgrq,GJMC,GJSD,gjxh,gjcd from (
     select (case when xh in(select min(to_number(xh)) as xh1 from ddb05
 where jh=well and KGRQ=to_date(kgsj,'yyyy-mm-dd'))
 then 'φ'||GJxh end)as xh1,xh,kgrq,GJMC,GJSD,gjxh,gjcd from ddb05  where jh=well
 and KGRQ=to_date(kgsj,'yyyy-mm-dd')));
end;
posted @ 2011-10-25 10:43  居后不争  阅读(6210)  评论(0编辑  收藏  举报