ORACLE存储过程的
BEGIN
INSERT INTO TMP_UP(ZZCJ,ZZJHRQ,GXNAME,ABILITY,MARK)
后面接调用另外的存储过程 这个存储过程返回一个数据集,改怎么写
我是这么写的
up_analysisdraw(这里是参数)
提示我ora-00947 没有足够的值
END; 临时表是建立好的 5个字段没问题 up_analysisdraw这个存储过程返回的数据集也是5个字段的 没什么问题啊 谁能告诉我 问题出在哪 不要找网上那些啊 根本解决不了这个问题
BEGIN
INSERT INTO TMP_UP(ZZCJ,ZZJHRQ,GXNAME,ABILITY,MARK)
后面接调用另外的存储过程 这个存储过程返回一个数据集,改怎么写
我是这么写的
up_analysisdraw(这里是参数)
提示我ora-00947 没有足够的值
END; 临时表是建立好的 5个字段没问题 up_analysisdraw这个存储过程返回的数据集也是5个字段的 没什么问题啊 谁能告诉我 问题出在哪 不要找网上那些啊 根本解决不了这个问题
(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 这个临时表里
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;
返回的是一个数据集 多行的 我改怎么取值 还是用游标吗 能不能给我写点东西
我好参照下 再有就是难道就没有不有游标的方法吗 insert into tmp_up(zzcj,zzjhrq,gxname,ability,)
select gd,rq,num,stype,RESULTSET from dual;
你这里SELETE的不就是变量吗 然后一条一条的插入 还就必须有游标啊
A这个存储过程
begin
b(参数1,参数2); 这就实现了A存储过程调用B存储过程了啊
end;
SQL SERVER 可以 实现 INSERT INTO 临时表 exec 过程名 参数1,参数2
把存储过程返回的数据集插入到临时表里
我就想问 这种方式ORACLE如何能实现 最好有代码的 简略的也可以啊
/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
/
另外 你用了 : 没问题可能就处在这
=>标识要传参
:标识需要引用的值给你个例子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
fetch rs bulk collect into employees_tab;这一句为什么会提示bulk bind error in define 的错误呢?
在ORACLE9.2.0.1版本中无法执行通过 请问还有什么其他语句代替吗