• oracle pl/sql语言 中的函数


    模式:

    create or replace function 函数名(参数名 参数类型,...) return 返回值类型

    is

      变量定义

    begin

      函数内容

      return 返回变量;

    end 函数名;

    /

    show err;

    举例:

    create or replace function func_branchshow(p_rownum number,p_rowmax number,p_field varchar2,p_returntype number default 1) return varchar2
    is
     /*函数功能:在输出中分行显示较大字段(不能在一行显示的字段,分行来显示)
       参数说明:
             p_rownum     行号(第几行)
             p_rowmax     行长度(行显示的最大字节数)
             p_field      输入的字段内容
             p_returntype   通过参数控制输出
                            p_returntype=1 输出本行显示的内容
                            p_returntype=0 输出除已显示的内容外,尚未显示的内容
          函数更新(版本)
             v20080730         新增函数用于重庆市预购商品房买卖合同登记备案证明 “买方”的输出
     */
     v_field0 varchar2(4000) default '';
     v_field1 varchar2(4000) default '';
     v_return   varchar2(4000) default '';
    begin
     if p_field is null then
      return null;
     end if;
     select substr(p_field,0,p_rowmax) into v_field1 from dual;
     select substr(p_field,p_rowmax+1) into v_field0 from dual;
     if p_returntype=1 then
      v_return:=v_field1;
     elsif p_returntype=0 then
      v_return:=v_field0;
     end if;
     return v_return;
    end func_branchshow;
    /
    show err;

  • 相关阅读:
    【转】Linux目录结构FHS
    单链表是否有环并如何找到环入口
    【转】linux dd 的简单应用
    DataSet、ExecuteScalar、ExecuteReader
    解决Excel只验证前8行字符串的长度
    SQL Server UPSERT equivalent
    用通配符替换字符串
    从内存中查询表字段定义的长度大小
    C#判断一个字符串是否为整数
    page life cycle of master page with content page
  • 原文地址:https://www.cnblogs.com/BradMiller/p/1743956.html
Copyright © 2020-2023  润新知