ORACLE存储过程的
BEGIN
INSERT INTO TMP_UP(ZZCJ,ZZJHRQ,GXNAME,ABILITY,MARK)
后面接调用另外的存储过程 这个存储过程返回一个数据集,改怎么写
我是这么写的
up_analysisdraw(这里是参数)
提示我ora-00947 没有足够的值
END; 临时表是建立好的 5个字段没问题 up_analysisdraw这个存储过程返回的数据集也是5个字段的 没什么问题啊  谁能告诉我 问题出在哪 不要找网上那些啊 根本解决不了这个问题

解决方案 »

  1.   

    CREATE OR REPLACE  PROCEDURE "SYSTEM"."UP_ANALYSISDRAW_DYNAMIC" 
        (gd
        varchar2,rq varchar2,num decimal,stype integer,RESULTSET OUT TEST_PAK.TESTRESULTSET)
    ASbegininsert into tmp_up(zzcj,zzjhrq,gxname,ability,)values up_analysisdraw (gd,rq,num,stype,RESULTSET);end;
    这个就是上个问题的延伸了 
    up_analysisdraw (gd,rq,num,stype,RESULTSET);就是上次我问你的问题 这个问题我不想深究了 已经能查询出数据了 5个字段 2行 没有空值的 跟SQL SERVER 2000查询出来的数据一样 虽然我在PL/SQL里面还不能查询出数据集 可是在SQLPLUS里面已经可以打印出来了 现在是 我想用上面这个存储过程调用up_analysisdraw 然后返回数据集 插入到tmp_up 这个临时表里
      

  2.   

    上面的存储过程我连编译都编译不过去 更别提执行了 写ORACLE存储过程太累人了 还是SQL SERVER的简单 
      

  3.   

    CREATE OR REPLACE PROCEDURE "SYSTEM"."UP_ANALYSISDRAW_DYNAMIC"  
    AS
    gd int;
    rq varchar2(20);
    gxname varchar2(20);
    ability varchar2(20);
     varchar2(20);
    begin
    --先取下返回值
     up_analysisdraw (gd,rq,num,stype,RESULTSET);
    --再插入
    insert into tmp_up(zzcj,zzjhrq,gxname,ability,)
    select gd,rq,num,stype,RESULTSET from dual;
    --再提交
    commit;end;
      

  4.   

    问题是这个up_analysisdraw (gd,rq,num,stype,RESULTSET);
     返回的是一个数据集 多行的 我改怎么取值 还是用游标吗 能不能给我写点东西
    我好参照下 再有就是难道就没有不有游标的方法吗 insert into tmp_up(zzcj,zzjhrq,gxname,ability,)
    select gd,rq,num,stype,RESULTSET from dual;
    你这里SELETE的不就是变量吗 然后一条一条的插入 还就必须有游标啊
      

  5.   

    通過管道函數,也許可以實現你的需求http://blog.csdn.net/nGX20080110/archive/2010/09/10/5875877.aspx
      

  6.   

    感谢楼上的回答 我目前状态是头疼中 刚接触ORACLE没到一个星期呢 对于上面的内用实在无法理解 难道ORACLE写存储过程就非要这么麻烦吗 临时表也要拿出来建立好 然后存储过程调用 我看到网上说的 ORACLE存储过程可以调用存储过程 非常简单
    A这个存储过程
    begin
     b(参数1,参数2); 这就实现了A存储过程调用B存储过程了啊
    end; 
    SQL SERVER 可以 实现 INSERT INTO 临时表 exec 过程名 参数1,参数2
    把存储过程返回的数据集插入到临时表里
    我就想问 这种方式ORACLE如何能实现 最好有代码的 简略的也可以啊
      

  7.   

    insert into tmp_up(zzcj,zzjhrq,gxname,ability,)values up_analysisdraw (gd,rq,num,stype,RESULTSET);这种语法按理说ORACLE是支持的。
      

  8.   

    看看这个例子是否有帮助create table emps(emp_id number(6),fname varchar2(20),salary number(8,2),status varchar2(10))
    /create or replace procedure get_employees 
    (slr number, rs out sys_refcursor)
    is
    begin
     open rs for select employee_id,first_name,salary*(1+nvl(commission_pct,0)) salary
      from employees where salary>slr;
    end;
    /create or replace procedure insert_emps
    (salary number,status varchar2)
    is
     type employees_rec_type is record (emp_id number(6),fname varchar2(20),salary number(8,2));
     type employees_tab_type is table of employees_rec_type;
     employees_tab employees_tab_type;
     
     type emps_tab_type is table of emps%rowtype;
     emps_tab emps_tab_type:=emps_tab_type();
     
     rs sys_refcursor;
    begin
     get_employees(salary,rs);
     
    -- 批量提取结果集到 nested table
     fetch rs bulk collect into employees_tab;
     
    -- 处理要插入 emps 表的数据
     for i in 1..employees_tab.count loop
      emps_tab.extend;
      emps_tab(i).emp_id:=employees_tab(i).emp_id;
      emps_tab(i).fname:=employees_tab(i).fname;
      emps_tab(i).salary:=employees_tab(i).salary;
      emps_tab(i).status:=status;
     end loop;
      
    -- 将数据批量插入 emps 表
     forall i in 1..emps_tab.count
     insert into emps values emps_tab(i);
     
     close rs;
     commit;
    end;
    /begin
     insert_emps(5000,'working');
    end;
    /select * from emps;drop procedure insert_emps
    /
    drop procedure get_employees
    /
    drop table emps purge
    /
      

  9.   

    调用的时候 你用到了 =>   没
    另外 你用了  : 没问题可能就处在这
    =>标识要传参
    :标识需要引用的值给你个例子PAGEUTIL为包名
    getResults为过程名create or replace package  MAHANPACK astype my_cursor is  ref cursor;
    end MAHANPACK;
    -------------------------------------create or replace package body PAGEUTIL is
    procedure   getResults(
    tableName  in varchar2,
    colsStr in varchar2,
    pageSize  in number,
    currentPage in number,
    pageCount out number,
    p_cursor out MAHANPACK.my_cursor
    ) is
    v_sql  varchar2(2000);
    v_begin number:= (currentPage-1)*pageSize+1;
    v_end number := currentPage*pageSize;
    begin v_sql:='select * from (
    select t.*,rownum rn from 
    (select  '||colsStr ||' from '
    ||tableName||' ) t where rownum <='||v_end||') where rn>='||v_begin;
    open p_cursor for v_sql;
    v_sql :=' select count(*) from '||tableName;
    execute  immediate v_sql into pageCount;
    if mod(pageCount,pageSize)=0 then 
    pageCount:= pageCount/pageSize ;
    else
    pageCount:= pageCount/pageSize+1;
    end if;
    end;
    end PAGEUTIL; SQL> ed已写入 file afiedt.buf   1  begin  2  PAGEUTIL.getResults(tableName=>'emp',  3   colsStr=>'empno , ename ',  4   pageSize=>20,  5   currentPage=>1,  6   pageCount=>:count,  7   p_cursor=>:c1);  8* end;SQL> / PL/SQL 过程已成功完成。 SQL> print count;      COUNT----------       1.7 SQL> print c1;
    本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/voyage_mh1987/archive/2010/09/12/5879646.aspx
      

  10.   

    xman_78tom 给出的存储过程编译通过,但测试不通过,提示bulk bind error in define 的错误。。
      

  11.   

    请问下15楼的。-- 批量提取结果集到 nested table
     fetch rs bulk collect into employees_tab;这一句为什么会提示bulk bind error in define 的错误呢?
      

  12.   

    这个 demo 要求 employees 表已经存在于数据库上。另外,lz 使用的 oracle 是什么版本。我在 oracle 10g 上一切 ok。
      

  13.   

    我测试的时候是把employees改成scott的emp表,知道问题出现在哪了,就是字段值的大小上。sal 这个字段我原来声明为number(7,2),但经过salary*(1+nvl(commission_pct,0)) salary 这样相乘一下,有的值就超出了number(7,2)这个范围,后来我把它改成number(18,2)就OK了。测试成功!
      

  14.   

    你的语句 其中 fetch rs bulk collect into employees_tab;
    在ORACLE9.2.0.1版本中无法执行通过 请问还有什么其他语句代替吗