Oracle 子程序参数模式,IN,OUT,IN OUT
IN :用于传入参数。
在调用过程的时候,实参传到该过程中。
在过程内部,形参只读且不能更改。
在过程执行完毕,返回调用环境时候,实参到的值也不会改变
--带IN参数的过程,赋值。
create or replace proceduce ModeIn(
p_InParameter in number
)as v_LocalVariable number:=0;
begin
DBMS_OUTPUT.PUT('Inside ModeIn:');
if(p_InParameter is null)then --in 传入参数,实参传到该过程中。
DBMS_OUTPUT.PUT_LINE('p_InParameter is null');
else
DBMS_OUTPUT.PUT_LINE('p_InParameter='||p_InParameter);
end if; v_LocalVariable:=p_InParameter; --和法赋值,只读
-- p_InParameter:=v_LocalVariable; --不能赋值,形参只读且不能更改 DBMS_OUTPUT.PUT('At end of ModeIn:');
if(p_InParameter is null) then
DBMS_OUTPUT.PUT_LINE('p_InParameter is null');
else
DBMS_OUTPUT.PUT_LINE('p_InParameter='||p_InParameter);
end if;
end ModeIn; ----调用ModeIn过程,观察IN参数的使用
declare
v_in number :=1;
begin
DBMS_OUTPUT.PUT_LINE('Before calling ModeIn, v_in='||v_in);
ModeIn(v_in);
DBMS_OUTPUT.PUT_LINE('After calling ModeIn, v_in='||v_in);
end;
/ Before calling ModeIn, v_in=1 --实参初始值为1
Inside ModeIn:p_InParameter=1 --形参接收传入的实参值为1
At end of ModeIn:p_InParameter=1 --形参只读且不能更改,形参值为1
After calling ModeIn, v_in=1 --返回调用环境时候,实参到的值也不会改变,实参值为1
OUT参数:用于返回值。
在调用过程时候,会忽略传入的形参的值,形参像未初始化的变量,值为null。
形参可以读取和写入。
在过程执行之后,返回调用环境(只有程序正常结束时),会将形参赋值给实参。
--带OUT参数的过程,赋值。
create or replace procedure ModeOut(
p_OutParameter out number;
)as v_LocalVariable:=0;
begin
DBMS_OUTPUT.PUT('Inside ModeOut:');
if(p_OutParameter is null)then -- 在调用过程时候,会忽略传入的形参的值,形参像未初始化的变量,值为null。
DBMS_OUTPUT.PUT_LINE('p_OutParameter is null');
else
DBMS_OUTPUT.PUT_LINE('p_OutParameter='||p_OutParameter);
end if; v_LocalVariable:=p_OutParameter; --和法赋值,形参可读
p_OutParameter:=7; --形参可以读取和写入 DBMS_OUTPUT.PUT('At end of ModeOut:');
if(p_OutParameter is null) then
DBMS_OUTPUT.PUT_LINE('p_OutParameter is null');
else
DBMS_OUTPUT.PUT_LINE('p_OutParameter='||p_OutParameter);
end if; ----调用ModeOut过程,观察Out参数的使用
declare
v_out number :=1;
begin
DBMS_OUTPUT.PUT_LINE('Before calling ModeOut, v_out='||v_out);
ModeIn(v_out);
DBMS_OUTPUT.PUT_LINE('After calling ModeOut, v_out='||v_out);
end;
/ Before calling Modeout, v_out=1 --实参初始值为1
Inside ModeOut:p_OutParameter is null --在调用过程时候,会忽略传入的形参的值,形参像未初始化的变量,值为null。
At end of ModeOut:p_OutParameter=7 --形参可以读取和写入,值为改变后的7
After calling ModeOut, v_out=7 -- 返回调用环境时候,返回调用环境(只有程序正常结束时),会将形参赋值给实参。
IN OUT参数: 用于传入参数和返回值
在调用过程的时候,实参值会传递到过程中。
在过程执行之后,返回调用环境(只有程序正常结束时),会将形参复制给实参。
create or replace procedure ModeInOut(
p_InOutParameter in out number;
)as v_LocalVariable:=0;
begin
DBMS_OUTPUT.PUT('Inside ModeInOut:');
if(p_InOutParameter is null)then -- 在调用过程的时候,实参值会传递到过程中
DBMS_OUTPUT.PUT_LINE('p_InOutParameter is null');
else
DBMS_OUTPUT.PUT_LINE('p_InOutParameter='||p_InOutParameter);
end if; v_LocalVariable:=p_InOutParameter; --和法赋值,形参可读
p_InOutParameter:=8; --形参可以读取和写入 DBMS_OUTPUT.PUT('At end of ModeInOut:');
if(p_InOutParameter is null) then
DBMS_OUTPUT.PUT_LINE('p_InOutParameter is null');
else
DBMS_OUTPUT.PUT_LINE('p_InOutParameter='||p_InOutParameter);
end if; ----调用ModeInOut过程,观察In Out参数的使用
declare
v_InOut number :=1;
begin
DBMS_OUTPUT.PUT_LINE('Before calling ModeInOut, v_InOut='||v_InOut);
ModeIn(v_InOut);
DBMS_OUTPUT.PUT_LINE('After calling ModeInOut, v_InOut='||v_InOut);
end;
/ Before calling ModeInout, v_InOut=1 --实参初始值为1
Inside ModeInOut:p_InOutParameter=1 -- 在调用过程的时候,实参值会传递到过程中,形参被赋值为1
At end of ModeInOut:p_InOutParameter=8 --形参可以读取和写入,值为改变后的8
After calling ModeInOut, v_InOut=8 -- 返回调用环境时候,返回调用环境(只有程序正常结束时),会将形参赋值给实参。
Oracle 子程序参数模式,IN,OUT,IN OUT的更多相关文章
- Oracle归档模式和非归档模式
一 什么是Oracle归档模式? Oracle数据库有联机重做日志,这个日志是记录对数据库所做的修改,比如插入,删除,更新数据等,对这些操作都会记录在联机重做日志里.一般数据库至少要有2个联机重做日志 ...
- Silverlight项目笔记5:Oracle归档模式引起的异常&&表格控件绑定按钮
1.Oracle归档模式产生日志文件引起数据库异常 连接数据库失败,提示监听错误,各种检查监听配置文件,删除再添加监听,无果. sqlplus下重启数据库数据库依然无果,期间碰到多个错误提示: ORA ...
- Oracle归档模式和非归档模式的区别
一.查看oracle数据库是否为归档模式: Sql代码1.select name,log_mode from v$database; NAME LOG_MODE ------------------ ...
- Oracle归档模式与非归档模式设置
(转自:http://www.cnblogs.com/spatial/archive/2009/08/01/1536429.html) Oracle的日志归档模式可以有效的防止instance和dis ...
- oracle并行模式
参考链接:oracle并行模式(Parallel),深入理解Oracle的并行操作(原创),oracle使用并行踩过的坑 1. 语法(这个可以加到insert.delete.update.select ...
- 07 oracle 归档模式 inactive/current redo log损坏修复--以及错误ORA-00600: internal error code, arguments: [2663], [0], [9710724], [0], [9711142], [], [], [], [], [], [], []
07 oracle 归档模式 inactive/current redo log损坏修复--以及错误ORA-00600: internal error code, arguments: [2663], ...
- WebServers发布提示oracle客户端模式不一致
问题:System.InvalidOperationException: 尝试加载 Oracle 客户端库时引发BadImageFormatException.如果在安装32 位Oracle 客户端组 ...
- ORACLE归档模式和非归档模式的利与弊
转: 在Oracle数据库中,主要有两种日志操作模式,分别为非归档模式与归档模式.默认情况下,数据库采用的是非归档模式.作为一个合格的数据库管理员,应当深入了解这两种日志操作模式的特点,并且在数据库建 ...
- Oracle 专用模式(DEDICATED) 和 共享模式(SHARE) (转)
Oracle 是一门博大精深的技术.玩了2年的oracle,依旧还有很多知识点不清楚. 昨天群里的朋友提到了 DEDICATED 和 SHARE 两种模式. 不清楚,默默的做点功课了.从网上搜了点知识 ...
随机推荐
- How to create and start VirtualBox VM without GUI
Suppose you want to create and run virtual machines (VMs) on VirtualBox. However, a host machine doe ...
- elasticsearch的percolator操作
es的普通查询是通过某些条件来查询满足的文档,percolator则不同,先是注册一些条件,然后查询一条文档是否满足其中的某些条件. es的percolator特性在数据分类.数据路由.事件监控和预警 ...
- BZOJ 3329: Xorequ [数位DP 矩阵乘法]
3329: Xorequ 题意:\(\le n \le 10^18\)和\(\le 2^n\)中满足\(x\oplus 3x = 2x\)的解的个数,第二问模1e9+7 \(x\oplus 2x = ...
- 使用log4net日志组件经验分享
常见步骤: 第一:在项目中引用log4net组件. 第二:配置log4net,一般都写在web.config中. 第三:调用部分. 具体怎么配置,大家可以参考博客其它博友写的,这里我只写我 ...
- SparkSteaming运行流程分析以及CheckPoint操作
本文主要通过源码来了解SparkStreaming程序从任务生成到任务完成整个执行流程以及中间伴随的checkpoint操作 注:下面源码只贴出跟分析内容有关的代码,其他省略 1 分析流程 应用程序入 ...
- MongoDB安装篇-Win7 X64
介绍 MongoDB是一个基于分布式文件存储的数据库.由C++语言编写.旨在为WEB应用提供可扩展的高性能数据存储解决方案. MongoDB是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库 ...
- 洛谷P1171 售货员的难题【状压DP】
题目描述 某乡有n个村庄(1 输入格式: 村庄数n和各村之间的路程(均是整数). 输出格式: 最短的路程. 输入样例: 3 0 2 1 1 0 2 2 1 0 输出样例 3 说明 输入解释 3 {村庄 ...
- spring 组件@Scope(request,session)示例
上回说到, spring组件的注解Scope大约有singleton.prototype.request.session.global session 这么几种常用的场景.这里需要特别说明一下,根据源 ...
- java 中对对象的调用
java程序设计语言对对象采用的不是引用的调用,实际上对象引用进行的是值得传递.(from:核心卷1 page:123)
- 原创:实现ehcache动态创建cache,以及超期判断的具体逻辑
当前最常用的三个缓存组件:ehcache.redis.memcached 其中,ehcache与应用共同运行于JVM中,属于嵌入式组件,运行效率最高,因此常被用于实现一级缓存. 在更复杂的一些系统中, ...