我是Oracle的初学者,我声明了以下对象类型:
create or replace
TYPE behzadtype AS OBJECT
( /* TODO enter attribute and method declarations here */
SESSIONID Number
)
我希望在我的存储过程中使用这个对象:
CREATE OR REPLACE PROCEDURE PROCEDURE1 AS
behzadtype t1;
BEGIN
t1.SESSIONID:=12;
DBMS_OUTPUT.PUT_LINE('THE VALUES OF P_K ARE' || t1.SESSIONID);
END PROCEDURE1;
但是,在编译过程中,我得到了以下错误:
错误(2,14):PLS-00201:必须声明标识符'T1‘
我怎么写正确的程序?谢谢大家。
发布于 2015-07-03 02:40:58
当您在PL/SQL中声明变量时,首先声明变量的名称,然后是它的数据类型。
在您的示例中,您已经将behzadtype的变量声明为t1类型,然后尝试在代码正文中使用一个名为t1的变量。看起来,您希望将变量t1声明为behzadtype。
此外,您还不能为这样的对象赋值--您必须首先将其初始化为一个对象。
我觉得你想要的是:
create or replace type behzadtype as object
(sessionid number);
/
create or replace procedure procedure1 as
t1 behzadtype;
begin
t1 := behzadtype(12);
dbms_output.put_line('THE VALUES OF P_K ARE' || t1.sessionid);
end procedure1;
/
begin
procedure1;
end;
/
THE VALUES OF P_K ARE12
drop type behzadtype;
drop procedure procedure1;
https://stackoverflow.com/questions/31204499
复制