我建立一个存储过程:
功能:根据用户输入的tempid号和templevel,找出temp表中相匹配的最大tempid.
create or replace procedure mytemp
( mylevel in number,
myid in char,
maxid out char
)
as
begin
select max(tempid) into maxid from temp where tempid like myid||'%' and templevel=mylevel;
end mytemp;
建立完改存储过程后,我在sql*plus中调用该存储过程:
declare
mymaxid char;
begin
mytemp(2,'100',mymaxid);
end;
程序报错为:PL/SQL: 数字或值错误 : 字符串缓冲区太小
我想是不是我得temp表里tempid的字段类型是varchar2(15),而存储过程中用的是char类型的原因,但是如果我把存储过程改为:
create or replace procedure mytemp
( mylevel in number,
myid in varchar2(15),
maxid out varchar2(15)
)
as
begin
select max(tempid) into maxid from temp where tempid like myid||'%' and templevel=mylevel;
end mytemp;
系统又报错为:有编译错误.
问题2:varchar2类型的字段能不能用max()函数?
百思不得其解,望各位大虾指点