嗨,我想創建一個只一行返回多個值功能:甲骨文PLSQL返回一行類型
create or replace TYPE foo_type AS OBJECT (
col1 NUMBER ,
col2 VARCHAR2(150 BYTE)
);
CREATE FUNCTION foo_function() RETURN foo_type
as
row_type foo_type;
select
b1, -- NUMBER TYPE
b2 -- VARCHAR2(150 BYTE) TYPE
into
row_type
from
table_xxx
where
rownum=1; --Only one row!
return row_type;
END foo_function;
如果我編譯收到的:ORA-00947不夠值
我已經試過:
select
b1, -- NUMBER TYPE
b2 -- VARCHAR2(150 BYTE) TYPE
into
row_type.col1,
row_type.col2
from
table_xxx
where
rownum=1; --Only one row!
而且功能編譯但是當ID運行:
select foo_function() from dual;
甲骨文回報:ORA-06530引用未初始化的複合
答案是確定的,但關於'你將它定義爲在數據庫級別的對象,我不能同意你的觀點,所以這個對象即使是子程序級別定義的類型變量也必須初始化。 – Seyran