在plsql中新建了一个type 里面有一个只有一个参数的构造函数 外面还声明了一个变量,编译成功,但是在存储过程中调用的时候却报00307错误type代码如下:
create or replace type TYP_LEAD as object
(
-- Author : ADMINISTRATOR
-- Created : 2011-10-10 下午 10:04:01
-- Purpose :
-- Attributes
m_strLead varchar2(16),
-- m_strLeadName varchar2(10),
constructor function TYP_LD(p_strLeadCd in varchar2) return self as result,
member function IsExist return boolean )create or replace type body TYP_LEAD is
constructor function TYP_LD(p_strLeadCd in varchar2) return self as result is
begin
begin
select sb.物件cd
into m_strLead
from SB物件 sb
where sb.物件cd = p_strLeadCd;
exception
when no_data_found then
m_strLead := '';
end;
return;
end;member function IsExist return boolean is
begin
if m_strLead is null then
return false;
else
return true;
end if;
end;
end;
调用的存储过程
create or replace procedure TEST_TYP_LEAD is
targetPLSQL TYP_LEAD;
bolIsExist boolean;
begin
targetPLSQL := TYP_LEAD('001'); bolIsExist := targetPLSQL.IsExist();
if bolIsExist = true then
dbms_output.put_line('1');
else
dbms_output.put_line('0');
end if;
-- dbms_output.put_line(bolIsExist);
end TEST_TYP_LEAD;type编译成功,但是用上面的存储过程调用type的时候,总是报一个pls0307:有太多声明和“TYP_LD”相同,
如果在type中多声明一个变量(任意的一个如strLeadName )就能正常,即变量个数和构造函数中的参数个数相同时,在存储过程中调用的时候就报错
请大侠指点指点
create or replace type TYP_LEAD as object
(
-- Author : ADMINISTRATOR
-- Created : 2011-10-10 下午 10:04:01
-- Purpose :
-- Attributes
m_strLead varchar2(16),
-- m_strLeadName varchar2(10),
constructor function TYP_LD(p_strLeadCd in varchar2) return self as result,
member function IsExist return boolean )create or replace type body TYP_LEAD is
constructor function TYP_LD(p_strLeadCd in varchar2) return self as result is
begin
begin
select sb.物件cd
into m_strLead
from SB物件 sb
where sb.物件cd = p_strLeadCd;
exception
when no_data_found then
m_strLead := '';
end;
return;
end;member function IsExist return boolean is
begin
if m_strLead is null then
return false;
else
return true;
end if;
end;
end;
调用的存储过程
create or replace procedure TEST_TYP_LEAD is
targetPLSQL TYP_LEAD;
bolIsExist boolean;
begin
targetPLSQL := TYP_LEAD('001'); bolIsExist := targetPLSQL.IsExist();
if bolIsExist = true then
dbms_output.put_line('1');
else
dbms_output.put_line('0');
end if;
-- dbms_output.put_line(bolIsExist);
end TEST_TYP_LEAD;type编译成功,但是用上面的存储过程调用type的时候,总是报一个pls0307:有太多声明和“TYP_LD”相同,
如果在type中多声明一个变量(任意的一个如strLeadName )就能正常,即变量个数和构造函数中的参数个数相同时,在存储过程中调用的时候就报错
请大侠指点指点
解决方案 »
- 字段类型为NUMBER(10)时1与10000占的存储空间一样吗
- ado 连接oracle 出问题?open 处
- sqlplus 7.33的连oracle 10g的数据库只能开一个进程。
- 建立存储过程失败,语法错误?
- 9i怎么指定导出数据时的字符集?
- oracle中如何换行,高手帮忙
- oracle数据结构问题?
- 一个关于Oracle视图的问题(着急,上火!)
- ORA-01843: 无效的月份
- oracle怎么用一个表的多个字段数据更新另一个表相应的字段中
- oracle forms builder 编写一个pll库文件,请问可以调用早已经编译好的另一个pll库文件里的函数在新的一个pll库文件中吗?
- oracle 9i服务无法启动 急在线等 全部分只有这么多了
targetPLSQL := TYP_LEAD('001');你这样写是不是有问题?
也就是说不识别你写的TYP_LEAD('001'),究竟是想调用type里的变量 还是 type里的construction function,因为从你的type和type body的定义来看,调用变量和function的调用方法是一样的,都可以通过TYP_LEAD('001')来调用。(这里的TYP_LEAD既可以表示type名,也可以表示type里的方法名)
Every object type has a constructor method (constructor for short), which is a function with the same name as the object type that initializes and returns a new instance of that object type.Oracle generates a default constructor for every object type, with formal parameters that match the attributes of the object type. That is, the parameters and attributes are declared in the same order and have the same names and datatypes.
You can define your own constructor methods, either overriding a system-defined constructor, or defining a new function with a different signature.PL/SQL never calls a constructor implicitly, so you must call it explicitly.For more information, see "Defining Constructors".大概说的是每个object 类型都有个默认的构造函数,跟声明的属性是匹配的;你这个object只有一个参数时,默认的构造函数和你后来的构造函数是一样的,也就是说有两个一样的构造函数,当然有报错,你加个参数之后,默认的构造函数也变了,oracle就知道你想调那个构造函数了。
plsql中新建了一个type 里面有一个只有一个参数的构造函数 外面还声明了一个变量,编译成功,但是在存储过程中调用的时候却报00307错误type代码如下:
create or replace type TYP_LEAD as object
(
-- Author : ADMINISTRATOR
-- Created : 2011-10-10 下午 10:04:01
-- Purpose :
-- Attributes
m_strLead varchar2(16),
-- m_strLeadName varchar2(10),
constructor function TYP_LEAD(p_strLeadCd in varchar2) return self as result,
member function IsExist return boolean )create or replace type body TYP_LEAD is
constructor function TYP_LEAD(p_strLeadCd in varchar2) return self as result is
begin
begin
select sb.物件cd
into m_strLead
from SB物件 sb
where sb.物件cd = p_strLeadCd;
exception
when no_data_found then
m_strLead := '';
end;
return;
end;member function IsExist return boolean is
begin
if m_strLead is null then
return false;
else
return true;
end if;
end;
end;
调用的存储过程
create or replace procedure TEST_TYP_LEAD is
targetPLSQL TYP_LEAD;
bolIsExist boolean;
begin
targetPLSQL := TYP_LEAD('001'); bolIsExist := targetPLSQL.IsExist();
if bolIsExist = true then
dbms_output.put_line('1');
else
dbms_output.put_line('0');
end if;
-- dbms_output.put_line(bolIsExist);
end TEST_TYP_LEAD;type编译成功,但是用上面的存储过程调用type的时候,总是报一个pls0307:有太多声明和“TYP_LEAD”相同,
如果在type中多声明一个变量(任意的一个如strLeadName )就能正常,即变量个数和构造函数中的参数个数相同时,在存储过程中调用的时候就报错
请大侠指点指点