zoukankan      html  css  js  c++  java
  • oracle 调用存储过程和方法

    1,oracle调用存储过程

    /*例1*/
    CREATE OR REPLACE PROCEDURE test1 
    IS 
    BEGIN 
     NULL; 
    END; 
    
    begin
    test1();
    end;
    
    
    /*例2*/
    CREATE OR REPLACE PROCEDURE test2
    ( p1 IN nvarchar2 )
    as 
    BEGIN 
     dbms_output.put_line(p1);
    END; 
    
    
    
    
    declare
    msg NVARCHAR2(2000);
    begin
    test2(p1 => '肖建');
    end;
    
    
    
    
    /*例3*/
    CREATE OR REPLACE PROCEDURE test3
    (
           p1 IN nvarchar2 , 
           p2 out nvarchar2 
    )
    IS 
    BEGIN 
     p2 := p1;
    END; 
    
    declare
    msg NVARCHAR2(2000);
    begin
    test3(p1 => 'xxx',p2 =>msg);
    dbms_output.put_line(msg);
    end;

    2,oracle调用方法

    create or replace function fun01
    (
        inParam in nvarchar2,
        outParam out nvarchar2,
       inAndOutParam in out nvarchar2
    )
    return nvarchar2 as f_result nvarchar2(200);     
    begin
        outParam := inparam;
        inAndOutParam := 'Hello World'; 
        f_result := outParam || inAndOutParam;
        return f_result; 
    end;
    
    
    
    declare
    msg1 NVARCHAR2(2000);
    msg2 NVARCHAR2(2000);
    msg3 NVARCHAR2(2000);
    
    begin
    msg1 := '';
    msg2 := '';
    msg3 := fun01('5',msg1,msg2);
    end;
    
    
    
    CREATE OR REPLACE FUNCTION fun02 
    (
           num1 IN NUMBER, 
           num2 IN NUMBER
    )  
    RETURN NUMBER  
    AS  
        num3 number;  
        num4 number;  
        num5 number;  
    BEGIN  
        num3 := num1 + num2;  
        num4 := num1 * num2;  
        num5 := num3 * num4;  
        RETURN num5;  
    END;  
  • 相关阅读:
    9.jQuery工具方法
    8.jQuery遍历索引的方法
    7.jQuery中位置坐标图形相关方法
    CentOS安装log.io
    centos7搭建frps内网穿透服务
    docker showdoc安装
    【测试基础】等价类、边界值的概念及划分
    3-14 Pandas绘图
    3-13 索引进阶
    3-12 字符串操作
  • 原文地址:https://www.cnblogs.com/xcj26/p/3129337.html
Copyright © 2011-2022 走看看