码迷,mamicode.com
首页 > 数据库 > 详细

oracle程序包

时间:2016-04-29 21:51:09      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:

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;

oracle程序包

标签:

原文地址:http://www.cnblogs.com/begin-zero/p/5447527.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!