`
z_kanhai
  • 浏览: 50988 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

函数的使用

 
阅读更多
create or replace function Fun_getinvclPK( cinvclasscode varchar2,cinvclasslev number)
  return varchar2 is
   fpk_invcl varchar(200) := '';
   invclass_code varchar(20):='';
   invclass_lev number :=0;
begin

   invclass_code := trim(cinvclasscode);
   invclass_code := substr(invclass_code,0,length(invclass_code)-2);
   invclass_lev := cinvclasslev-1;
   select pk_invcl into fpk_invcl from bd_invcl where invclasscode like invclass_code||'%' and invclasslev = invclass_lev;


  return fpk_invcl;
end;



create or replace function Fun_getinvclInfo( cinvclasscode varchar2,cinvclasslev number)
  return varchar2 is
   fpk_invcl varchar(200) := '';
   invclass_code varchar(20):='';
   invclass_lev number :=0;
begin

   invclass_code := trim(cinvclasscode);
   invclass_code := substr(invclass_code,0,length(invclass_code)-2);
   invclass_lev := cinvclasslev-1;
   select pk_invcl into fpk_invcl from bd_invcl where invclasscode like invclass_code||'%' and invclasslev = invclass_lev;
  
  select invclasscode into xx   from bd_invcl  where bd_invcl.pk_invcl = fpk_invcl;

  return fpk_invcl;
end;




create or replace function f1(pk bd_corp.pk_corp%type) return bd_corp.unitcode%type
as
v_unitcode bd_corp.unitcode%type;
begin
    select unitcode into v_unitcode from bd_corp where pk_corp=pk;
    return v_unitcode;
end;



create or replace function Fun_getRInfo( cpkcorp varchar2,cflag number,cpk varchar2)
  return varchar2 is
   rinfo varchar(200) := '';
   pkcorp varchar(20):='';
   pk varchar(20):='';
   flag number :=0;
begin

   pkcorp := trim(cpkcorp);
   flag := cflag;
   pk := cpk;
   --公司
   if (flag = 0) then
      select unitcode into rinfo from bd_corp where pk_corp=pkcorp and nvl(dr,0)=0;
   end if;
   if (flag = 1) then
      select unitname  into rinfo from bd_corp where pk_corp=pkcorp and nvl(dr,0)=0;
   end if;
   --商品分类
    if (flag = 3) then
      select invclasscode  into rinfo from bd_invcl where pk_corp=pkcorp and nvl(dr,0)=0 and pk_invcl = pk;
   end if;
 
  
  
  return rinfo;
end;

select Fun_getRInfo('1114',5,'') aa ,Fun_getRInfo('1004',1,'') bb from dual;



select * from bd_invcl





create or replace function Fun_getRInfo( cpkcorp varchar2,cflag number,cpk varchar2)
  return varchar2 is
   rinfo varchar(200) := '';
   pkcorp varchar(20):='';
   pk varchar(20):='';
   flag number :=0;
begin

   pkcorp := trim(cpkcorp);
   flag := cflag;
   pk := cpk;
   --公司编码
   if (flag = 0) then
      if (pkcorp=='0001') then
      unitcode='0001'
      else
      select unitcode into rinfo from bd_corp where pk_corp=pkcorp and nvl(dr,0)=0;
      end if;
     
   end if;
   --公司名称
   if (flag = 1) then
       if (pkcorp=='0001') then
       unitcode='0001'
       else
       select unitname  into rinfo from bd_corp where pk_corp=pkcorp and nvl(dr,0)=0;
       end if;
    
   end if;
   --商品分类编码
    if (flag = 2) then
      select invclasscode  into rinfo from bd_invcl where  nvl(dr,0)=0 and pk_invcl = pk;
   end if;
 
      --商品分类名称
    if (flag = 3) then
      select invclassname  into rinfo from bd_invcl where  nvl(dr,0)=0 and pk_invcl = pk;
   end if;
  
    --主计量单位编码
    if (flag = 4) then
      select shortname  into rinfo from bd_measdoc where  nvl(dr,0)=0 and pk_measdoc = pk;
   end if;
  
     --主计量单位名称
    if (flag = 5) then
      select measname  into rinfo from bd_measdoc where  nvl(dr,0)=0 and pk_measdoc = pk;
   end if;
  
      --自定义项档案列表名称
    if (flag = 6) then
      select doclistname  into rinfo from bd_defdoclist where nvl(dr,0)=0 and pk_defdoclist = pk;
   end if;
  
      --自定义项档案列表编码
    if (flag = 7) then
      select doclistcode  into rinfo from bd_defdoclist where  nvl(dr,0)=0 and pk_defdoclist = pk;
   end if;
  
      --基础数据资源表名称
    if (flag = 6) then
      select bdname   into rinfo from bd_bdinfo where nvl(dr,0)=0 and pk_bdinfo= pk;
   end if;
  
      --基础数据资源表编码
    if (flag = 7) then
      select bdcode  into rinfo from bd_bdinfo where  nvl(dr,0)=0 and pk_bdinfo= pk;
   end if;
  
  return rinfo;
end;

--商品税率
create or replace function Fun_gettptaxiInfo(ctypetaxitempk varchar2,cinvclpk varchar2,cflag number)
return varchar2 is typettinfo varchar(200) :='';
cfpk varchar2(20):='';
cinvpk varchar2(20):='';
flag number :=0;
begin
cfpk:=ctypetaxitempk;
cinvpk:=cinvclpk;
flag:=cflag;
if(flag=0) then
select unitcode into  typettinfo from bd_corp where pk_corp=(select pk_corp from zm_typetaxitem_h where pk_typetaxitem_h=cfpk and nvl(dr,0)=0) and nvl(dr,0)=0;
end if;
if(flag=1) then
select unitname into  typettinfo from bd_corp where pk_corp=(select pk_corp from zm_typetaxitem_h where pk_typetaxitem_h=cfpk and nvl(dr,0)=0) and nvl(dr,0)=0;
end if;
if(flag=2) then
select invclasscode into  typettinfo from bd_invcl where pk_invcl=cinvpk and nvl(dr,0)=0;
end if;
if(flag=3) then
select invclassname into  typettinfo from bd_invcl where pk_invcl=cinvpk and nvl(dr,0)=0;
end if;
return typettinfo ;
end;

--获取上级商品分类编码及名称
create or replace function Fun_getinvclInfo( cinvclasscode varchar2,cinvclasslev number,cflag number)
  return varchar2 is
   finvclinfo varchar(200) := '';
   invclass_code varchar(20):='';
   invclass_lev number :=0;
   flag number :=0;
begin
   invclass_code := trim(cinvclasscode);
   invclass_code := substr(invclass_code,0,length(invclass_code)-2);
   invclass_lev := cinvclasslev-1;
   if(flag=0) then
   select invclassname into finvclinfo from bd_invcl where invclasscode like invclass_code||'%' and invclasslev = invclass_lev;
   else
   finvclinfo:=invclass_code;
    end if;
 
  return finvclinfo;
end;

Fun_getRInfo(a.pk_corp, 0, '') as unitcode,Fun_getRInfo(a.pk_corp, 1, '') as unitname,Fun_getinvclInfo(a.invclasscode,a.invclasslev,0) as fatherinvclassname, Fun_getinvclInfo(a.invclasscode,a.invclasslev,1) as fatherinvclass_code

create or replace function Fun_getinvclInfo( cinvclasscode varchar2,cinvclasslev number,cflag number)
  return varchar2 is
   finvclinfo varchar(200) := '';
   invclass_code varchar(20):='';
   invclass_lev number :=0;
   flag number :=0;
begin
   invclass_code := trim(cinvclasscode);
   invclass_code := substr(invclass_code,0,length(invclass_code)-2);
   invclass_lev := cinvclasslev-1;
   if(flag=0) then
   select invclassname into finvclinfo from bd_invcl where invclasscode like invclass_code||'%' and invclasslev = invclass_lev;
   end if
   if(flag=1) then
   finvclinfo:=invclass_code;
   end if;

  return finvclinfo;
end;

create or replace function Fun_getRInfo( cpkcorp varchar2,cflag number,cpk varchar2)
  return varchar2 is
   rinfo varchar(200) := '';
   pkcorp varchar(20):='';
   pk varchar(20):='';
   flag number :=0;
begin

   pkcorp := trim(cpkcorp);
   flag := cflag;
   pk := cpk;
   --公司编码
   if (flag = 0) then
      if (pkcorp='0001') then
      rinfo :='0001';
      else
      select unitcode into rinfo from bd_corp where pk_corp=pkcorp and nvl(dr,0)=0;
      end if;

   end if;
   --公司名称
   if (flag = 1) then
       if (pkcorp='0001') then
       rinfo :='0001';
       else
       select unitname  into rinfo from bd_corp where pk_corp=pkcorp and nvl(dr,0)=0;
       end if;

   end if;
   --商品分类编码
    if (flag = 2) then
      select invclasscode  into rinfo from bd_invcl where  nvl(dr,0)=0 and pk_invcl = pk;
   end if;

      --商品分类名称
    if (flag = 3) then
      select invclassname  into rinfo from bd_invcl where  nvl(dr,0)=0 and pk_invcl = pk;
   end if;

    --主计量单位编码
    if (flag = 4) then
      select shortname  into rinfo from bd_measdoc where  nvl(dr,0)=0 and pk_measdoc = pk;
   end if;

     --主计量单位名称
    if (flag = 5) then
      select measname  into rinfo from bd_measdoc where  nvl(dr,0)=0 and pk_measdoc = pk;
   end if;

      --自定义项档案列表名称
    if (flag = 6) then
      select doclistname  into rinfo from bd_defdoclist where nvl(dr,0)=0 and pk_defdoclist = pk;
   end if;

      --自定义项档案列表编码
    if (flag = 7) then
      select doclistcode  into rinfo from bd_defdoclist where  nvl(dr,0)=0 and pk_defdoclist = pk;
   end if;

     --父级自定义项档案表名称
    if (flag = then
      select docname  into rinfo from bd_defdoc where nvl(dr,0)=0 and pk_defdoclist = pk;
   end if;

      --父级自定义项档案表编码
    if (flag = 9) then
      select doccode  into rinfo from bd_defdoc where  nvl(dr,0)=0 and pk_defdoclist = pk;
   end if; 
   
      --基础数据资源表名称
    if (flag = 10) then
      select bdname   into rinfo from bd_bdinfo where nvl(dr,0)=0 and pk_bdinfo= pk;
   end if;
  
      --基础数据资源表编码
    if (flag = 11) then
      select bdcode  into rinfo from bd_bdinfo where  nvl(dr,0)=0 and pk_bdinfo= pk;
   end if;
  
    --产品线档案名称
    if (flag = 12) then
      select prodlinename   into rinfo from bd_prodline where nvl(dr,0)=0 and pk_prodline= pk;
   end if;
  
      --产品线档案编码
    if (flag = 13) then
      select prodlinecode  into rinfo from bd_prodline where  nvl(dr,0)=0 and pk_prodline= pk;
   end if;

   --税目税率名称
    if (flag = 14) then
      select taxname   into rinfo from bd_taxitems where nvl(dr,0)=0 and pk_taxitems= pk;
   end if;
  
      --税目税率编码
    if (flag = 15) then
      select taxcode   into rinfo from bd_taxitems where  nvl(dr,0)=0 and pk_taxitems= pk;
   end if;

  return rinfo;
end;
分享到:
评论

相关推荐

    Linux C函数库参考手册完整版 含Linux C函数使用手册chm 中文pdf格式

    Linux C函数库参考手册是一套Linux C函数使用手册,这里还提供了LinuxC函数手册chm,帮助大家查找。在Linux下,使用到的C语言函数中文手册,全都有实例,如果你是大神,完全不需要,如果你对英文的手册感到头疼,...

    二代身份证相片解码函数使用说明宣贯.pdf

    "二代身份证相片解码函数使用说明宣贯.pdf" 本资源是一个关于二代身份证相片解码函数的使用说明文件,该文件提供了相应的API函数和开发指南,旨在帮助开发者快速了解和使用该函数。 一、文件概述 该文件主要介绍...

    LISP ssget 函数使用大全整理

    LISP ssget 函数使用大全整理,涵盖该函数使用的各个方面

    VB-API函数使用手册

    《VB-API函数使用手册》是一本专为VBA(Visual Basic for Applications)开发者设计的实用指南,涵盖了在VBA编程中使用API(Application Programming Interface)函数的广泛知识。API函数是Windows操作系统提供的一...

    VB-API函数使用手册_VB-API函数使用手册_

    VB-API函数使用手册,VB编程基础知识,方便编程查询

    多任务系统中的不可重函数使用注意事项

    ### 多任务系统中的不可重入函数使用注意事项 #### 前言 本文将深入探讨在多任务系统中,特别是针对STM32平台,如何合理使用不可重入函数以避免出现错误。首先,我们将明确可重入函数与不可重入函数的区别,并给出...

    HAL库+CubeMX+Stm32F405 实现串口定长收发、printf函数使用、自定义打印函数

    HAL库+CubeMX+Stm32F405 实现串口定长收发、printf函数使用、自定义打印函数 详情请看:https://lindoglog.blog.csdn.net/article/details/107463926

    linux中open函数使用

    Linux 中 open 函数使用详解 open 函数是 Linux 中一个基本的文件操作函数,它用于打开或创建文件,并返回一个文件描述符。下面是对 open 函数的详细解释。 open 函数的函数原型为:`int open(const char *path, ...

    excel 函数使用 计算方法

    ### Excel函数使用与计算方法详解 #### 一、函数与公式的概念 ##### 什么是函数? 在Excel中,函数是一种预定义的公式,用于执行特定的计算任务。它使用一个或多个参数作为输入,并返回一个结果。这些参数可以是...

    VC++ 回调函数使用实例

    这个函数将作为回调函数使用。例如,我们可以定义一个简单的回调函数原型: ```cpp typedef void (*CallbackType)(int value); ``` 这里`CallbackType`是一个函数指针类型,它接受一个整型参数并无返回值。 2. ...

    socket_recv函数使用心得.

    socket_recv 函数使用心得 在学习 socket_recv 函数时,需要了解其返回值的含义和使用场景。在阻塞模式下,当网络异常时,recv 函数返回值为-1,表示连接异常,需要关闭连接。在非阻塞模式下,如果没有数据,recv ...

    Oracle分析函数使用总结

    Oracle分析函数使用总结Oracle分析函数使用总结Oracle分析函数使用总结Oracle分析函数使用总结

    串口屏LUA例程-绘图API函数使用说明V1.0.pdf

    在本文档中,我们主要将介绍大彩LUA脚本API函数中的绘图API函数使用方法,以及使用函数的注意事项。首先,让我们来了解一下LUA语言版本,当前文档支持的LUA版本为V5.5。接下来,我们将详细讲解如何使用绘图API函数,...

    C language functionsC语言函数使用大全.rar

    本资源“C language functions C语言函数使用大全.rar”提供了关于C语言函数的详尽指南。 首先,C语言库函数是C标准库中预定义的一组功能,如数学运算、输入/输出操作、内存管理等。`C语言库函数大全.doc`文档可能...

    C语言程序使用宝典C语言函数使用

    本篇将详细讲解C语言中的函数使用,帮助你深入理解和掌握这一核心概念。 在C语言中,函数是一组相关的语句,它们执行特定任务并可能接受输入参数,也可能返回结果。函数的使用极大地提高了代码的复用性和模块化。...

    mongodb常用函数使用案例

    mongodb常用函数使用案例,主要是针对update,insert,find函数

    LIN bus_API 函数使用说明

    详细介绍了LIN的API函数的使用,包括代码的详细解读。

    EXCEL常用函数使用手册.pdf

    《EXCEL常用函数使用手册》是一份详细讲解Excel函数应用的教程,涵盖了Excel函数的各个方面,包括函数简介、数学和三角函数、逻辑函数、文本/日期/时间函数、查询与引用函数、统计函数、工程函数、财务函数、信息...

    RTOS_常用函数使用

    RTOS_常用函数使用

Global site tag (gtag.js) - Google Analytics