原来SQL SERVER 2000的存储过程
CREATE PROCEDURE up_analysisdraw
@gd varchar(10),
@rq varchar(10),
@num dec,
@stype int
asbegin transelect 任务分配表.制造工段 as zzcj,convert(char(7),任务分配表.zzjhrq,120) as zzjhrq,工序明细表.工序名称 as gxname,
sum(coalesce(工序明细表.单件定额 * 零件明细表.制件数量 ,0) )/60.0 as degs,'需求' as 
into #tmp
from 工序明细表 (NOLOCK),任务分配表 (NOLOCK) ,零件明细表 (NOLOCK) ,b_加工工艺使用设备表
where 工序明细表.任务号 = 任务分配表.任务号 and 
工序明细表.工装号 = 任务分配表.工装号 and
零件明细表.任务号 = 任务分配表.任务号 and 
零件明细表.工装号 = 任务分配表.工装号 and
零件明细表.件号 =  工序明细表.件号 and 
任务分配表.生产完工标识 = '0'  and
工序明细表.wwbz= '0'  and 工序明细表.单件定额>0 and 工序明细表.工序名称= b_加工工艺使用设备表.编号 and
ifusable='0' and b_加工工艺使用设备表.type <> '热表处理' and --hwgx is null and
case when 工序明细表.wwhm is null then 任务分配表.制造工段 else 工序明细表.wwhm end like @gd+'%'  and 任务分配表.zzjh = '1' and
convert(char(7),任务分配表.zzjhrq,120) like @rq+'%'   
group by 任务分配表.制造工段,convert(char(7),任务分配表.zzjhrq,120),工序明细表.工序名称 select a.工序名称 as gxname,coalesce(sum(operatorlist.degs)/60.0 ,0) as wcgs
into #tmp1
from operatorlist (NOLOCK),mom30100 (NOLOCK),mom30101 (NOLOCK),工序明细表 a (NOLOCK),任务分配表 b (NOLOCK)
where operatorlist.no = mom30101.no and operatorlist.seq = mom30101.seq and mom30101.no = mom30100.no and
a.任务号 = b.任务号 and  a.工装号 = b.工装号 and
mom30100.rwh =a.任务号 and mom30100.gzh =a.工装号  and mom30100.jh =a.件号 and mom30100.gxh = a.工序号 
and mom30100.type <>'2' and
b.生产完工标识 = '0'  and a.wwbz= '0'  and a.单件定额>0 
and b.制造工段 like @gd+'%' --and a.工序名称 = 工序明细表.工序名称 
and b.zzjh = '1' and convert(char(7),b.zzjhrq,120) like @rq+'%' 
group by b.制造工段,convert(char(7),b.zzjhrq,120),a.工序名称
elect FDeptNumber as zzcj,@rq as zzjhrq,icdeviceofgx.gx as gxname,
(@num*t_equipworker.worktime *percent1/100) as hournum,isnull(dwhour,1.3) as dwhour ,'能力'as 
into #tmp2
from ICDeviceAccount,icdeviceofgx,b_加工工艺使用设备表,t_equipworker
where ICDeviceAccount.FDeviceNumber = icdeviceofgx.fdevicenumber and
icdeviceofgx.fdevicenumber = t_equipworker.xh and
icdeviceofgx.gx = b_加工工艺使用设备表.编号 
and ifusable='0' and b_加工工艺使用设备表.type <> '热表处理' and FDeptNumber like @gd+'%' and hwgx is null
order by gxname  insert into #tmp2 
(zzcj,zzjhrq,gxname,hournum,dwhour,)
SELECT  icdeviceaddhour.cjgd,@rq as zzjhrq,icdeviceofgx.gx,
        (DATEDIFF ( Day , icdeviceaddhour.sdt , icdeviceaddhour.edt ) + 1)* icdeviceaddhour.addhour as hournum,
        isnull(icdeviceaddhour.dwhour,1.3) as dwhour , '能力'as  
FROM icdeviceaddhour ,icdeviceofgx     
WHERE icdeviceaddhour.FDeviceNumber =icdeviceofgx.fdevicenumber and 
( icdeviceaddhour.cjgd like @gd+'%' ) and 
( convert(char(7),icdeviceaddhour.sdt,120) = @rq ) and 1 = @stype insert into #tmp2 
(zzcj,zzjhrq,gxname,hournum,dwhour,)
SELECT ICDeviceAccount.fdeptnumber,@rq as zzjhrq,icdeviceofgx.gx,
(isnull(ICDeviceMaintainPlan.hournum,0) *percent1*(-1)/100) as hournum,isnull(dwhour,1.3) as dwhour ,'能力'as 
 FROM ICDeviceMaintainPlan,   ICDeviceAccount,icdeviceofgx,t_equipworker  
   WHERE ( ICDeviceMaintainPlan.fdevicenumber = ICDeviceAccount.FDeviceNumber ) and
ICDeviceAccount.FDeviceNumber =icdeviceofgx.fdevicenumber and
icdeviceofgx.fdevicenumber = t_equipworker.xh and 
ICDeviceAccount.fdeptnumber  like @gd+'%'  and
convert(char(7), ICDeviceMaintainPlan.FPlanBeginDate,120) = @rq
--
select a.zzcj,
a.zzjhrq,
(select 工序内容 from b_加工工艺使用设备表 where 编号 = a.gxname) as gxname,
sum((case when a.degs - b.wcgs <0 then 0 else a.degs - b.wcgs end))  as ability,
from #tmp a,#tmp1 b
where a.gxname = b.gxname --需求
group by zzcj,zzjhrq,a.gxname,
union
select  a.zzcj,
a.zzjhrq,
(select 工序内容 from b_加工工艺使用设备表 where 编号 = a.gxname) as gxname,
sum(a.hournum* a.dwhour) as ability,
from #tmp2 a
group by zzcj,zzjhrq,gxname,
drop table #tmp
drop table #tmp1
drop table #tmp2commit tran
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO想转为ORACLE9I数据库的 这个问题困扰我好几天了 因为刚接触ORACLE 以前用SQL SERVER 2000的 很多细节都过不去 希望高手指教下 越详细越好 我的问题 就出在临时表那块了 要详细说明啊

解决方案 »

  1.   

    汉字的表名与字段名是历史遗留问题啊 大家见谅 
    我现在做的方法是在太累了 基本是这样的CREATE OR REPLACE  PROCEDURE "SYSTEM"."UP_ANALYSISDRAW" (gd
        varchar2,rq varchar2,nums decimal,stype integer)
    AS
    str varchar2(4000);
    v_num int;
    begin
      select count(*) into v_num from user_tables where table_name = 'tmp';
      if v_num < 1 then
     str := 'drop table tmp';
      execute immediate str;
      str := 'create global temporary table tmp
      (
      zzcj varchar2(20),
      zzjhrq varchar2(20),
      gxname varchar2(40),
      degs decimal,
       varchar2(20))
      on commit preserve rows';
      execute immediate str;
      end if;
      str :='insert into tmp (select 任务分配表.制造工段 as zzcj,to_char(任务分配表.zzjhrq,'||'''yyyy-mm'''||') as zzjhrq,工序明细表.工序名称 as gxname,
    sum(nvl(工序明细表.单件定额 * 零件明细表.制件数量,0))/60.0 as degs,'||'''需求'''||' as from  "SYSTEM"."工序明细表" , "SYSTEM"."任务分配表", "SYSTEM"."零件明细表", "SYSTEM"."b_加工工艺使用设备表"
    where 工序明细表.任务号 = 任务分配表.任务号 and 
      工序明细表.工装号 = 任务分配表.工装号 and
      零件明细表.任务号 = 任务分配表.任务号 and 
      零件明细表.工装号 = 任务分配表.工装号 and
      零件明细表.件号 =  工序明细表.件号 and 
      任务分配表.生产完工标识 = '||'''0'''||'  and
      工序明细表.wwbz= '||'''0'''||'  and 工序明细表.单件定额>0 and 工序明细表.工序名称= "SYSTEM"."b_加工工艺使用设备表".编号 and
    ifusable='||'''0'''||' and "SYSTEM"."b_加工工艺使用设备表".type <> '||'''热表处理'''||' and 
    case when 工序明细表.wwhm is null then 任务分配表.制造工段 else 工序明细表.wwhm end like '||'''gd%'''||'  and 任务分配表.zzjh = '||'''1'''||' and
    to_char(任务分配表.zzjhrq,'||'''yyyy-mm'''||') like '||'''rq%'''||'   
    group by 任务分配表.制造工段,to_char(任务分配表.zzjhrq,'||'''yyyy-mm'''||'),工序明细表.工序名称) ';
    execute immediate str;
    -------------------------------------------------------------------------------------------------------------
    --str := 'drop table tmp1';
    --execute immediate str;
      --str := 'create global temporary table tmp1
      --(
      --gxname varchar2(40),
      --wcgs decimal
      --)
      --on commit preserve rows';
      --execute immediate str;
      --str := 'insert into tmp1 (select a.工序名称 as gxname,nvl(sum("SYSTEM"."operatorlist".degs)/60.0 ,0) as wcgs--from "SYSTEM"."operatorlist" ,"SYSTEM"."mom30100" ,"SYSTEM"."mom30101" ,"SYSTEM"."工序明细表" a ,
    --"SYSTEM"."任务分配表" b 
    --where "SYSTEM"."operatorlist".no = "SYSTEM"."mom30101".no and "SYSTEM"."operatorlist".seq = "SYSTEM"."mom30101".seq and "SYSTEM"."mom30101".no = "SYSTEM"."mom30100".no and
    --a.任务号 = b.任务号 and  a.工装号 = b.工装号 and
    --"SYSTEM"."mom30100".rwh =a.任务号 and "SYSTEM"."mom30100".gzh =a.工装号  and "SYSTEM"."mom30100".jh =a.件号 and "SYSTEM"."mom30100".gxh = a.工序号 
    --and "SYSTEM"."mom30100".type <>'||'''2'''||' and
    -- b.生产完工标识 = '||'''0'''||'  and a.wwbz= '||'''0'''||'  and a.单件定额>0 
    --and b.制造工段 like '||'''gd%'''||' 
    --and b.zzjh = '||'''1'''||' and to_char(b.zzjhrq,'||'''yyyy-mm'''||') like '||'''rq%'''||'
    --group by b.制造工段,to_char(b.zzjhrq,'||'''yyyy-mm'''||'),a.工序名称)';
    --execute immediate str;
    ----------------------------------------------------------------------------------------------------------------------------
    str := 'drop table tmp2';
    execute immediate str;
    str := 'create global temporary table tmp2
      (
      zzcj varchar2(20),
      zzjhrq varchar2(20),
      gxname varchar2(40),
      hournum decimal,
      dwhour decimal,
       varchar2(20))
      on commit preserve rows';
      execute immediate str;
      str :='insert into tmp2 (select "SYSTEM"."ICDeviceAccount".FDeptNumber as zzcj,rq as zzjhrq,"SYSTEM"."icdeviceofgx".gx as gxname,
    (nums*"SYSTEM"."t_equipworker".worktime *percent1/100) as hournum,nvl(dwhour,1.3) as dwhour ,'||'''能力'''||'as from "SYSTEM"."ICDeviceAccount","SYSTEM"."icdeviceofgx","SYSTEM"."b_加工工艺使用设备表","SYSTEM"."t_equipworker"
    where "SYSTEM"."ICDeviceAccount".FDeviceNumber = "SYSTEM"."icdeviceofgx".fdevicenumber and
    "SYSTEM"."icdeviceofgx".fdevicenumber = "SYSTEM"."t_equipworker".xh and
    "SYSTEM"."icdeviceofgx".gx = "SYSTEM"."b_加工工艺使用设备表".编号 
    and ifusable='||'''0'''||' and "SYSTEM"."b_加工工艺使用设备表".type <> '||'''热表处理'''||' and FDeptNumber like '||'''gd%'''||' and hwgx is null
    ) ';
    execute immediate str;end;
    这个东西累死了 尤其是拼接字符串那里 还有就是加表空间名字等等 有没有高手 帮我解决下啊 
      

  2.   

    1、建议你先建立好临时表,在存储过程里面每次调用时,先truncate table temptable一下,再操作数据2、不需要添加表空间之类的信息,都采用默认的
      

  3.   

    不要子过程里建temp表  就是把创建temp表那段 拿出去 先执行
    楼上不都说明白了么
      

  4.   

    你的意思 就是 我用多少临时表 都写成脚本 然后布数据库的时候先执行 然后再用 存储过程里面直接调用临时表 是吧 以前从来都是存储过程建立临时表 然后删除掉 ORACLE不支持这种吗 那样建立的临时表一直存在吗 如果2个用户同时用这个临时表 参数不一样 里面的数据会不会查出来是2个人的 那样不就不准了吗 ORACLE我是新手 还望前辈多指教指教啊 实在有太多的不明白了
      

  5.   


    --说的很详细了,存储过程里面不能每次都创建临时表,oracle与sqlserver不一样
    http://blog.csdn.net/jsyzzcx/archive/2008/10/28/3164018.aspx
      

  6.   

    1  你一定要每次创建在删 也没问题 不过那是ddl啊,虽然它并不真正分配空间 
    2  其他表都支持多用户查询 临时表也不例外
    实在你这个问题不用贴代码   呵呵
      

  7.   

    我刚才测试了 也就是说我用多少个临时表 就要就脚本创建多少个表在数据库里 然后存储过程里直接调用 
    ‘建议你先建立好临时表,在存储过程里面每次调用时,先truncate table temptable一下,再操作数据’
    像楼上说的 先清空数据最好 不过我刚才测试了 不同的登陆查询根本看不到对方的数据,即使同一个系统账户,我现在就想问 然后怎么写剩下的存储过程 我可以写脚本把用到的表先布在数据库里  难道非要这么写吗 str :='insert into tmp (select 任务分配表.制造工段 as zzcj,to_char(任务分配表.zzjhrq,'||'''yyyy-mm'''||') as zzjhrq,工序明细表.工序名称 as gxname,
    sum(nvl(工序明细表.单件定额 * 零件明细表.制件数量,0))/60.0 as degs,'||'''需求'''||' as from "SYSTEM"."工序明细表" , "SYSTEM"."任务分配表", "SYSTEM"."零件明细表", "SYSTEM"."b_加工工艺使用设备表"
    where 工序明细表.任务号 = 任务分配表.任务号 and  
      工序明细表.工装号 = 任务分配表.工装号 and
      零件明细表.任务号 = 任务分配表.任务号 and  
      零件明细表.工装号 = 任务分配表.工装号 and
      零件明细表.件号 = 工序明细表.件号 and  
      任务分配表.生产完工标识 = '||'''0'''||' and
      工序明细表.wwbz= '||'''0'''||' and 工序明细表.单件定额>0 and 工序明细表.工序名称= "SYSTEM"."b_加工工艺使用设备表".编号 and
    ifusable='||'''0'''||' and "SYSTEM"."b_加工工艺使用设备表".type <> '||'''热表处理'''||' and  
    case when 工序明细表.wwhm is null then 任务分配表.制造工段 else 工序明细表.wwhm end like '||'''gd%'''||' and 任务分配表.zzjh = '||'''1'''||' and
    to_char(任务分配表.zzjhrq,'||'''yyyy-mm'''||') like '||'''rq%'''||' 
    group by 任务分配表.制造工段,to_char(任务分配表.zzjhrq,'||'''yyyy-mm'''||'),工序明细表.工序名称) ';
    execute immediate str;这么写太累人了 测试也不好测试 有没有更好的办法处理 拼接字符串实在太累了 望解答。还有就是为什么我把存储过程建立到SYSTEM这个表空间下 我的数据表也都在SYSTEM这个表空间下 为什么用的时候还要加表空间名字 不加的话就提示“找不到这个表” SQL SERVER 2000 2个数据库之间查询 不就是加数据库前缀就可以吗 难道这个跟那个还不一样吗
      

  8.   

    不同用户不同session  当然看不到
    感觉你sqlserver里 temporary table的概率和oracle不同
      

  9.   

    /*建立存储过程临时表*/
    create global temporary table tmp
      (
      zzcj varchar2(20),
      zzjhrq varchar2(20),
      gxname varchar2(40),
      degs decimal,
       varchar2(20))
      on commit delete rows;  ------------------------------------------------------------------------------------------------------------------
    create global temporary table tmp1
      (
      gxname varchar2(40),
      wcgs decimal
      )
      on commit delete rows;
      -----------------------------------------------------------------------------------------------------------------
      create global temporary table tmp2
      (
      zzcj varchar2(20),
      zzjhrq varchar2(20),
      gxname varchar2(40),
      hournum decimal,
      dwhour decimal,
       varchar2(20))
      on commit DELETE rows
    ----------------------------------------------------------------------------------------------------------------
    --这是ORACLE存储过程
    CREATE OR REPLACE  PROCEDURE "SYSTEM"."UP_ANALYSISDRAW" (gd
        varchar2,rq varchar2,nums decimal,stype integer,RESULTSET OUT TEST_PAK.TESTRESULTSET)
    ASbegin
      insert into tmp (select 任务分配表.制造工段 as zzcj,to_char(任务分配表.zzjhrq,'yyyy-mm') as zzjhrq,工序明细表.工序名称 as gxname,
    sum(coalesce(工序明细表.单件定额 * 零件明细表.制件数量 ,0) )/60.0 as degs,'需求' as 
    from "SYSTEM".工序明细表,"SYSTEM".任务分配表,"SYSTEM".零件明细表,"SYSTEM"."b_加工工艺使用设备表"
    where 工序明细表.任务号 = 任务分配表.任务号 and
      工序明细表.工装号 = 任务分配表.工装号 and
      零件明细表.任务号 = 任务分配表.任务号 and
      零件明细表.工装号 = 任务分配表.工装号 and
      零件明细表.件号 =  工序明细表.件号 and
      任务分配表.生产完工标识 = '0'  and
      工序明细表.wwbz= '0'  and 工序明细表.单件定额>0 and 工序明细表.工序名称= "SYSTEM"."b_加工工艺使用设备表".编号 and
      ifusable='0' and "SYSTEM"."b_加工工艺使用设备表".type <> '热表处理' and
      case when 工序明细表.wwhm is null then 任务分配表.制造工段 else 工序明细表.wwhm end like gd||'%'  and 任务分配表.zzjh = '1' and
      to_char(任务分配表.zzjhrq,'yyyy-mm') like rq||'%'
    group by 任务分配表.制造工段,to_char(任务分配表.zzjhrq,'yyyy-mm'),工序明细表.工序名称);-------------------------------------------------------------------------------------------------------------
    insert into tmp1 (select a.工序名称 as gxname,coalesce(sum("SYSTEM"."operatorlist".degs)/60.0 ,0) as wcgsfrom "SYSTEM"."operatorlist" ,"SYSTEM"."mom30100" ,"SYSTEM"."mom30101","SYSTEM"."工序明细表" a,"SYSTEM"."任务分配表" b
    where "SYSTEM"."operatorlist".no = "SYSTEM"."mom30101".no and "SYSTEM"."operatorlist".seq = "SYSTEM"."mom30101".seq and "SYSTEM"."mom30101".no = "SYSTEM"."mom30100".no and
      a.任务号 = b.任务号 and  a.工装号 = b.工装号 and
    "SYSTEM"."mom30100".rwh =a.任务号 and "SYSTEM"."mom30100".gzh =a.工装号  and "SYSTEM"."mom30100".jh =a.件号 and "SYSTEM"."mom30100".gxh = a.工序号
      and "SYSTEM"."mom30100".type <>'2' and
      b.生产完工标识 = '0'  and a.wwbz= '0'  and a.单件定额>0
      and b.制造工段 like gd||'%'
      and b.zzjh = '1' and to_char(b.zzjhrq,'yyyy-mm') like rq||'%'
    group by b.制造工段,to_char(b.zzjhrq,'yyyy-mm'),a.工序名称);
    -------------------------------------------------------------------------------------------------------------------------
    --下面是能力:
    --标准能力(含倒班)
    insert into tmp2 select FDeptNumber as zzcj,rq as zzjhrq,"SYSTEM"."icdeviceofgx".gx as gxname,
      (nums*"SYSTEM"."t_equipworker".worktime *percent1/100) as hournum,NVL(dwhour,1.3) as dwhour ,'能力'as 
    from "SYSTEM"."ICDeviceAccount","SYSTEM"."icdeviceofgx","SYSTEM"."b_加工工艺使用设备表","SYSTEM"."t_equipworker"
    where "SYSTEM"."ICDeviceAccount".FDeviceNumber = "SYSTEM"."icdeviceofgx".fdevicenumber and
    "SYSTEM"."icdeviceofgx".fdevicenumber = "SYSTEM"."t_equipworker".xh and
    "SYSTEM"."icdeviceofgx".gx = "SYSTEM"."b_加工工艺使用设备表".编号
    and ifusable='0' and "SYSTEM"."b_加工工艺使用设备表".type <> '热表处理' and FDeptNumber like gd||'%' and hwgx is null
    order by gxname;
    ---------------------------------------------------------------------------------------------------------------- 加班  ,注:在加班输入时不能跨越
    insert into tmp2
    (zzcj,zzjhrq,gxname,hournum,dwhour,)
    SELECT  "SYSTEM"."icdeviceaddhour".cjgd,rq as zzjhrq,"SYSTEM"."icdeviceofgx".gx,
             ABS(ROUND(TO_NUMBER("SYSTEM"."icdeviceaddhour".sdt , "SYSTEM"."icdeviceaddhour".edt) + 1))* "SYSTEM"."icdeviceaddhour".addhour as hournum,
            NVL("SYSTEM"."icdeviceaddhour".dwhour,1.3) as dwhour , '能力'as 
    FROM "SYSTEM"."icdeviceaddhour" ,"SYSTEM"."icdeviceofgx"
    WHERE "SYSTEM"."icdeviceaddhour".FDeviceNumber ="SYSTEM"."icdeviceofgx".fdevicenumber and
    ( "SYSTEM"."icdeviceaddhour".cjgd like gd||'%' ) and
    ( to_char("SYSTEM"."icdeviceaddhour".sdt,'yyyy-mm') = rq ) and 1 = stype;
    ----------------------------------------------------------------------------------------------------------------------
    --保养计划时间
    insert into tmp2
    (zzcj,zzjhrq,gxname,hournum,dwhour,)
    SELECT "SYSTEM"."ICDeviceAccount".fdeptnumber,rq as zzjhrq,"SYSTEM"."icdeviceofgx".gx,
      (NVL("SYSTEM"."ICDeviceMaintainPlan".hournum,0) *percent1*(-1)/100) as hournum,NVL(dwhour,1.3) as dwhour ,'能力'as 
     FROM "SYSTEM"."ICDeviceMaintainPlan","SYSTEM"."ICDeviceAccount","SYSTEM"."icdeviceofgx","SYSTEM"."t_equipworker"
       WHERE ( "SYSTEM"."ICDeviceMaintainPlan".fdevicenumber = "SYSTEM"."ICDeviceAccount".FDeviceNumber ) and
      "SYSTEM"."ICDeviceAccount".FDeviceNumber ="SYSTEM"."icdeviceofgx".fdevicenumber and
      "SYSTEM"."icdeviceofgx".fdevicenumber = "SYSTEM"."t_equipworker".xh and
      "SYSTEM"."ICDeviceAccount".fdeptnumber  like gd||'%'  and
      to_char("SYSTEM"."ICDeviceMaintainPlan".FPlanBeginDate,'yyyy-mm') = rq ;
    ---------------------------------------------------------------------------------------------------------------------
    OPEN RESULTSET FOR
    select a.zzcj,a.zzjhrq,
    (select 工序内容 from "SYSTEM"."b_加工工艺使用设备表" where 编号 = a.gxname) as gxname,
    sum((case when a.degs - b.wcgs <0 then 0 else a.degs - b.wcgs end))  as ability,
    from tmp a,tmp1 b
    where a.gxname = b.gxname --需求
    group by zzcj,zzjhrq,a.gxname,
    union
    select  a.zzcj,
    a.zzjhrq,
    (select 工序内容 from "SYSTEM"."b_加工工艺使用设备表" where 编号 = a.gxname) as gxname,
    sum(a.hournum* a.dwhour) as ability,
    from tmp2 a
    group by zzcj,zzjhrq,gxname,;
    COMMIT;
    end;
    ----------------------------------------------------------------------------------
    /*创建程序包头与程序包体*/
    create or replace package "SYSTEM".test_pak is 
    type testresultset is ref cursor;
    end test_pak;
    --------------------------------------------------------------------------------------------------
    上面就是建立这个存储过程用到的 下面是测试数据的在PL/SQL里面declare gd varchar(20);
    rq varchar(20);
    nums decimal;
    stype integer;
    dsfs  TEST_PAK.TESTRESULTSET;
    begin
      gd:= '048';
      rq := '2010-01';
      nums :=1;
      stype := 1;
      system.up_analysisdraw(gd ,
                             rq ,
                             nums ,
                             stype ,
                             dsfs);
      
    end;我现在就是不知道怎么能把数据查出来 执行也没问题 可是就是看不到数据 不知道问题出在哪了
      

  10.   

    楼上的2位仁兄 帮俺看看呗 谢谢了 可能是我哪写错了 同样的数据 同样的参数 我在SQL SERVER 2000里面调用存储过程有数据 在这里调用就没有 也不知道问题出在哪了
      

  11.   

    1。(nums*"SYSTEM"."t_equipworker".worktime *percent1/100) as hournum,NVL(dwhour,1.3) as dwhour ,'能力'as 
    2。( "SYSTEM"."icdeviceaddhour".cjgd like gd||'%' ) and
    3。to_char(任务分配表.zzjhrq,'yyyy-mm') like rq||'%'
    4。 to_char("SYSTEM"."icdeviceaddhour".sdt,'yyyy-mm') = rq ) and 1 = stype
    这上面的NUMS,gd,rq,stype都是存储过程参数 这么用是不是不对啊 可我在ORACLE里面可以编译过去 在PL/SQL里面执行 也能成功 问题是看不都数据 
      

  12.   


    最后记得commit一下,oracle数据库默认不提交,需要自己手工去commit 
      

  13.   

    OPEN RESULTSET FOR
    select a.zzcj,a.zzjhrq,
    (select 工序内容 from "SYSTEM"."b_加工工艺使用设备表" where 编号 = a.gxname) as gxname,
    sum((case when a.degs - b.wcgs <0 then 0 else a.degs - b.wcgs end)) as ability,
    from tmp a,tmp1 b
    where a.gxname = b.gxname --需求
    group by zzcj,zzjhrq,a.gxname,
    union
    select a.zzcj,
    a.zzjhrq,
    (select 工序内容 from "SYSTEM"."b_加工工艺使用设备表" where 编号 = a.gxname) as gxname,
    sum(a.hournum* a.dwhour) as ability,
    from tmp2 a
    group by zzcj,zzjhrq,gxname,;
    COMMIT;
    我建立的是事物级的临时表 最后查询提交了啊 如果每次INSERT都提交 那就差不出数据了  我的意思是不是我哪写错了 你帮我看看返回数据集那块是不是有问题 就是建立程序包头那里 是不是还需要建立个程序包体
      

  14.   

    引用 2 楼 codearts 的回复:
    sql>var x refcursor; 
    sql>exec MENURIGHT('user_code', :x); 
    sql>print :x; 正确,但要在sqlplus下.我用的这种模式 打印出数据了 而且是正确的 我想问下 如果在PL/SQL里面 想得到数据集 我要怎么写
    declare gd varchar(20);
    rq varchar(20);
    nums decimal;
    stype integer;
    dsfs TEST_PAK.TESTRESULTSET;
    begin
      gd:= '048';
      rq := '2010-01';
      nums :=1;
      stype := 1;
      system.up_analysisdraw(gd ,
      rq ,
      nums ,
      stype ,
      dsfs);
       
    end;
    这么写肯定不对了 有没有人帮我改正下 
      

  15.   


    不要再存储过程里面写SQL语句,没有什么意义,还需要用游标去取数据,很麻烦 
      

  16.   

    那我如果想用存储过程返回一个数据集 该如何处理呢 谢谢你了 你对我的帮助很大啊 呵呵 写完这个存储过程 我再写其他的 就应该没什么大问题了 如果我不用SQL语句的话 我怎么返回数据集
      

  17.   

    存储过程要返回记录集需要用游标,与sqlserver不一样,再说存储主要是DML的,查询没有什么意义还不如用程序实现