create or replace FUNCTION getMaxID(table_name varchar2(30),maxid varchar2(10))
as
myID int;
myCount int;
begin
select count(*) into myCount from SYS_TABLEMAXID where TABLE_NAME=table_name;
if myCount := 0 then
insert into SYS_TABLEMAXID values(table_name,2);
maxid := 1;
else
select TABLE_MAXID into myID from SYS_TABLEMAXID where TABLE_NAME=table_name;
update SYS_TABLEMAXID set TABLE_MAXID = ID+1 where TABLE_NAME=table_name;
maxid=ID;
end if;
END getMaxID;
as
myID int;
myCount int;
begin
select count(*) into myCount from SYS_TABLEMAXID where TABLE_NAME=table_name;
if myCount := 0 then
insert into SYS_TABLEMAXID values(table_name,2);
maxid := 1;
else
select TABLE_MAXID into myID from SYS_TABLEMAXID where TABLE_NAME=table_name;
update SYS_TABLEMAXID set TABLE_MAXID = ID+1 where TABLE_NAME=table_name;
maxid=ID;
end if;
END getMaxID;
as
myID int;
myCount int;
begin
select count(*) into myCount from SYS_TABLEMAXID where TABLE_NAME=table_name;
if myCount = 0 then
insert into SYS_TABLEMAXID values(table_name,2);
maxid := 1;
else
select TABLE_MAXID into myID from SYS_TABLEMAXID where TABLE_NAME=table_name;
update SYS_TABLEMAXID set TABLE_MAXID = ID+1 where TABLE_NAME=table_name;
end if;
END getMaxID;
改成create or replace PROCEDURE getMaxID(table_name varchar2(30),maxid varchar2(10))
改成getMaxID(table_name in varchar2(30),maxid in varchar2(10))
是输入还是输出参数
as
...
as
as
myID int;
myCount int;
begin
select count(*) into myCount from SYS_TABLEMAXID where TABLE_NAME=table_name;
if myCount = 0 then
insert into SYS_TABLEMAXID values(table_name,2);
maxid:= 1;
else
select TABLE_MAXID into myID from SYS_TABLEMAXID where TABLE_NAME=table_name;
update SYS_TABLEMAXID set TABLE_MAXID = ID+1 where TABLE_NAME=table_name;
maxid:=ID;
end if;
end;
比如select table_name from user_tables