要不这样?
create or replace function MaxId(TableName IN varchar2,FieldName IN varchar2)
return number
as
type t_cursor is ref cursor;
v_cur t_cursor; SqlString varchar2(1000);
MId number;begin
SqlString := 'select nvl(max('||FieldName||') ,0) from '||TableName;
open v_cur for SqlString into MId;
close v_cur;
MId:=MId +1;
return MId;
end;
create or replace function MaxId(TableName IN varchar2,FieldName IN varchar2)
return number
as
type t_cursor is ref cursor;
v_cur t_cursor; SqlString varchar2(1000);
MId number;begin
SqlString := 'select nvl(max('||FieldName||') ,0) from '||TableName;
open v_cur for SqlString into MId;
close v_cur;
MId:=MId +1;
return MId;
end;
create or replace function MaxId1(TableName IN varchar2,FieldName IN varchar2)
return number
as
SqlString varchar2(1000);
MId number;
begin
SqlString := 'select nvl(max('||FieldName||') ,0) from '||TableName;
execute immediate sqlstring into mid;
MId:=MId +1;
return MId;
end;