您当前的位置: 首页 >  oracle

wespten

暂无认证

  • 1浏览

    0关注

    899博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Oracle函数与存储过程和程序包

wespten 发布时间:2018-08-19 08:23:13 ,浏览量:1

函数一般是工具性的,存储过程一般是DML的复杂操作

函数有返回类型 return

create function getBookCount return number as
begin
  declare book_count number;
  begin
    select count(*) into book_count from t_book;
    return book_count;
  end;
end getBookCount;

set serveroutput on;
begin
  dbms_output.put_line('表t_book有'|| getBookCount() ||'条数据');
end;

有参数的函数

execute 执行字符串

create function getTableCount(table_name varchar2) return number as
begin
  declare recore_count number;
  query_sql varchar2(300);
  begin
    query_sql:='select count(*) from ' || table_name;
    execute immediate query_sql into recore_count;
    return recore_count;
  end;
end getTableCount;


begin
  dbms_output.put_line('表有'|| getTableCount('t_bookType') ||'条数据');
end;

存储过程

In 只进不出

out 只出不进

in out 可进可出

判断操作,如果书名存在则不往

关注
打赏
1665965058
查看更多评论
立即登录/注册

微信扫码登录

0.0464s