Oracle存储过程(1)
来源:互联网 发布:淘宝代购 编辑:程序博客网 时间:2024/06/05 12:24
(一)存储过程的基本语法
1 CREATE OR REPLACE PROCEDURE 存储过程名
2 IS
3 BEGIN
4 NULL;
5 END;
(二)打印第一个Hello word
1.存储过程
create or replace procedure sayhelloword
as
--------说明部分
begin
dbms_output.put_line("Hello word");
end;
/
打开控制台->切换路径d: >打开oracle数据库:sqlplus scott/tiger@192.168.101:1521/orcl > 清屏 host cls > 打开控制台输出开关 :set serveroutput on
2.调用存储过程
1.exec sayhelloworld();
2.begin
sayhelloworld();
sayhelloworld();
end;
/
3.调用一个带参数的存储过程
1.create or replace procedure raisesalary(eno in number)
as
--定义一个变量保存涨前的薪水
psal emp.sal%type;
begin
--得到涨之前的薪水
select sal into psal from emp where empno = eno;
--给员工涨100
update emp set sal= sal+100 where empno = eno;
--一般不在存储过程中commit或rollback
--打印
dbms_output.put_line('涨前:'||psal||' 涨后:'||(psal+100));
end;
/
3.存储函数
Function 为命名的存储程序 ,可带参数 返回计算值
函数和过程的结构类似,但必须有一个return字句 ,用于返回函数值
创建存储函数的语法
create or replace FUNCTION 函数名(参数列表)
return 函数值类型
AS
PLSQL子程序体
create or replace function queryempincome(eno in number)
return number
as
--定义变量保存员工的薪水和奖金
psal emp.sal%type
pcommn emp.comm%type;
begin
select sal,comm into psal,pcomm from emp where empno=eno;
--直接返回收入
return psal*12+pcomm;
end
4.调试存储过程
先用sys账户登录 密码
as sysdba
再对scott进行授权 grant DEBUG CONNECT SESSION ,DEBUG ANY PROCEDURE to scott;
阅读全文
1 0
- Oracle存储过程(1)
- oracle 的存储过程(1)
- ORACLE存储过程的创建(1)
- oracle存储过程和存储函数(1)
- Oracle存储过程和存储函数(1)
- oracle 笔记1 存储过程
- oracle 存储过程例1
- oracle 存储过程基础知识1
- oracle 存储过程 笔记1
- Oracle存储过程实例1
- oracle存储过程调用1
- Oracle存储过程(转)
- Oracle存储过程(转)
- 存储过程(2)----Oracle
- oracle存储过程学习(-)-基本过程
- java oracle存储过程/函数(1):字符串数组、int数组传入存储过程
- ORACLE存储过程(二)之存储过程的调用
- Oracle存储过程笔记1:动态SQL(建表)
- Socket通信基础
- 电脑修改桌面图标
- Assets.xcassets导致的错误
- 处理SSM框架中css、js、image等加载不出来
- Maven教程【整理】-(3)-依赖机制/ 自定义到本地库
- Oracle存储过程(1)
- java之单例模式
- ARToolkit在ubuntu14.04下的完整配置
- Lintcode70 Binary Tree Level Order Traversal II solution 题解
- 2D 摄像机跟随的套路
- postMan模拟ajax请求
- Webpack基本概念Loader
- 阿里90后工程师,如何用AI程序写出双11打call歌?
- VS中通过map文件找到崩溃的代码行