当前位置:网站首页>stored procedure
stored procedure
2022-07-23 05:57:00 【J_ zyq】
1. Create and use stored procedures
grammar :
create or replalce PROCEDURE The process of ( parameter list )
as
PLSQL Subroutine body ;
eg: -- The first stored procedure : Print Hello World No parameter list
/*
Calling stored procedure :
1. exec sayHelloWorld(); -- Call only once
2. begin
sayHelloWorld();
sayHelloWorld();
-- Call it several times
end;
/
*/
create or replace procedure sayHelloWorld
as
-- The explanatory part
begin
dbms_output.put_line("Hello World");
end;
/
eg2: -- Stored procedure with parameters
--: For designated employees , rose 100 Dollar wages ; And print the salary before and after the rise
/*
How to call :
begin:
raisesalary(123);
raisesalary(321);
commit; -- Ensure that the above two calls are from the same thing
end;
/
*/
create or replace procedure raisesalary(eno in number)
-- Stored procedure with parameters , It is necessary to indicate that this parameter is an input parameter (in) Or output parameters
as
-- Define a variable to save the salary before the rise
psal emp.sal%type;
begin
-- Get the salary before the employee gets a raise
select sal into psal from emp where empno = eno;
-- Give the employee a raise 100
update emp set sal = sal + 100 where empno = eno;
-- Be careful : Generally, it is not in stored procedures or stored functions ,commit and rollback
-- Print
dbms_output.put_line(' Before rising : '||psal||' After rising : '||(psal + 100));
end;
/
边栏推荐
猜你喜欢
随机推荐
Selenium基础知识 自动登录百度网盘
About the problem of re creation after deleting the module in idea:
LINK : fatal error LNK1104: 无法打开文件“opencv_world340.lib”
来访人员基本流程
学习amber软件md的输入文件参数
测试案例:水杯,保温杯,黑板,抽纸,电梯,签到
Selenium基础知识 自动搜索
在局域网内配置LoRaWAN的私有ChirpStack
判断Set中课程是否存在,Contains方法
浅谈LoRa,LoRaWAN,NB-IoT三类物联网技术
学习amber教程A17:伞形采样,绘制丙氨酸三肽的势能面
Test case: QQ login
appium 使用
amber教程A17学习----概念篇
详解虚拟机下三种联网模式
单位审批基本流程
Millisecond upload batch attachments
SNAT与DNAT
Grasp interface automation in simple terms
测试点,第一天总结









