标签:
create or replace package my_package as
function getTableCount(table_name varchar2) return number;
procedure addbook(bookName in varchar2,bookTypeId in number,n1 out number);
end my_package;
create or replace package body my_package as
procedure addbook(bookName in varchar2,bookTypeId in number,n1 out number) as
begin
declare maxId number;
n number;
begin
select count(*) into n from t_book where name1=bookName;
select count(*) into n1 from t_book;
if n>0 then
return;
end if;
select max(id) into maxId from t_book;
insert into t_book values(maxId+1,bookName,bookTypeId);
commit;
end;
end addbook;
function getTableCount(table_name varchar2) return number as
begin
declare sql_query varchar2(300);
t_count number;
begin
sql_query:=‘select count(*) from ‘||table_name;
execute immediate sql_query into t_count;
return t_count;
end;
end getTableCount;
end my_package;
标签:
原文地址:http://www.cnblogs.com/begin-zero/p/5447527.html