关于procedure or function 返回的记录集不能select的问题!!!
现在有这么一个问题:
统计一批记录,然后再返回统计的记录集回来;现在的是问题是怎么通过select之类的语句来出其结果?!或者有什么更加好的方法!?
附我现在写的一段:
create or replace package myp is
type r_my_record is record (a1 ....);
type t_my_table is table of r_my_record ...;
....
create or replace package body myp is
function myf(param char(2)) return t_my_table is
i integer := 0;
a integer;
b integer;
...
mytable t_my_table;
cursor c_my is select aa from bb;
begin
open cursor;
loop
fetch cursor into a;
select sum(*) into b from bb where no=a;
....
mytable(i).a := a;
....
i := i + 1;
end loop;
return mytable;
end;
end;
当我created后,我用select myp.myf('0') from dual;来执行说无效的类型!!?!(主要是返回来的mytable select不能识别!)
不知道哪位高人知道!?或者有什么更妙的方法!?请多指点!谢谢!!!
统计一批记录,然后再返回统计的记录集回来;现在的是问题是怎么通过select之类的语句来出其结果?!或者有什么更加好的方法!?
附我现在写的一段:
create or replace package myp is
type r_my_record is record (a1 ....);
type t_my_table is table of r_my_record ...;
....
create or replace package body myp is
function myf(param char(2)) return t_my_table is
i integer := 0;
a integer;
b integer;
...
mytable t_my_table;
cursor c_my is select aa from bb;
begin
open cursor;
loop
fetch cursor into a;
select sum(*) into b from bb where no=a;
....
mytable(i).a := a;
....
i := i + 1;
end loop;
return mytable;
end;
end;
当我created后,我用select myp.myf('0') from dual;来执行说无效的类型!!?!(主要是返回来的mytable select不能识别!)
不知道哪位高人知道!?或者有什么更妙的方法!?请多指点!谢谢!!!
...全文
相关推荐
oracle的存储过程如何返回结果集
过程返回记录集下面是一个简单的示例,展示如何创建一个存储过程来返回结果集:```sqlCREATE OR REPLACE PACKAGE pkg_testAS TYPE myrctype IS REF
MySQL 5.7 create VIEW or FUNCTION or PROCEDURE
函数 (Function)函数类似于存储过程,但返回一个值,而不是执行一系列操作。在MySQL中,使用`CREATE FUNCTION`创建自定义函数。
MySQL中创建procedure,function,trigger
这里的 `RETURNS type` 指定了函数的返回类型,必须与返回值的类型相同,否则会报错。
Oracle 存储过程返回结果集.doc
本篇文档主要介绍了如何通过存储过程返回结果集,分为两种方式:过程返回记录集和函数返回记录集。1. 过程返回记录集:在Oracle中,可以通过OUT参数来让存储过程返回一个结果集。
Oracle_存储过程的基本语法
,存储过程还可以返回记录集。


