当前位置:网站首页>Several calling methods of Oracle stored procedure
Several calling methods of Oracle stored procedure
2022-07-18 16:09:00 【zhangbeizhen18】
Record :284
scene :Oracle Stored procedure call mode , Include PL/SQL Of SQL Call in window 、 stay PL/SQL Command window for 、 stay Procedures Select the name of the stored procedure in the menu list and right-click test 、 stay Package Bodies Select the name of the stored procedure in the menu list and right-click test 、 stay Jobs Select configured in the menu list Job Right click the stored procedure of and click Run 、Java Code call stored procedure .
edition :Oracle Database 11g
Tools :PL/SQL Developer
One 、 Case scenario
1. Based on the environment
This example environment , Use Packages and Packages bodies Manage stored procedures Procedure.
Packages and Packages bodies name :PKG_ZBZ_PORTAL
Procedure name :PRO_INSERT_INFO_ARGS
complete SQL:
-- Package definition
CREATE OR REPLACE PACKAGE PKG_ZBZ_PORTAL IS
PROCEDURE PRO_INSERT_INFO_ARGS(IN_DATE IN VARCHAR2 := NULL,
FLAG OUT NUMBER,
FAIL_INFO OUT VARCHAR2);
END PKG_ZBZ_PORTAL;
-- Inclusion body
CREATE OR REPLACE PACKAGE BODY PKG_ZBZ_PORTAL IS
PROCEDURE PRO_INSERT_INFO_ARGS(IN_DATE IN VARCHAR2 := NULL,
FLAG OUT NUMBER,
FAIL_INFO OUT VARCHAR2) IS
BEGIN
DECLARE
V_DATE DATE := TRUNC(SYSDATE - 1);
BEGIN
FLAG := 1;
FAIL_INFO := '';
IF (IN_DATE IS NOT NULL) THEN
V_DATE := TO_DATE(IN_DATE, 'YYYYMMDD');
END IF;
INSERT INTO B_LOG_INFO
SELECT SEQ_DEMO_ID.NEXTVAL,V_DATE,
SYSDATE,'1',' Successful implementation ',50,'DUAL'
FROM DUAL;
COMMIT;
EXCEPTION
WHEN OTHERS THEN
FLAG := 0;
FAIL_INFO := ' This time : ' || IN_DATE || ' Output results : FLAG = ' || FLAG ||
' Abnormal information : ' || SQLERRM;
ROLLBACK;
END;
END PRO_INSERT_INFO_ARGS;
END PKG_ZBZ_PORTAL;Note the following tests , Stored procedures or packages must be compiled , That is to say .

2.SQL Call the stored procedure in the window
stay PL/SQL Developer Tools , Menu path in turn : file -> newly build ->SQL window , You can enter SQL Window .
scene : After the stored procedure is submitted , Directly in SQL Window execution , Call stored procedures to verify and test stored procedures .
DECLARE
FLAG NUMBER;
FAIL_INFO VARCHAR2(512);
BEGIN
PKG_ZBZ_PORTAL.PRO_INSERT_INFO_ARGS( '20220710',
FLAG,FAIL_INFO);
dbms_output.put_line('FLAG=' || FLAG);
dbms_output.put_line('FAIL_INFO=' || FAIL_INFO);
END;3. Call the stored procedure in the command window
stay PL/SQL Developer Tools , Menu path in turn : file -> newly build -> Command window , That is, you can enter the command window .
scene : After the stored procedure is submitted , Execute directly in the command window , Call stored procedures to verify and test stored procedures .
var FLAG NUMBER;
var FAIL_INFO VARCHAR2(512);
exec PKG_ZBZ_PORTAL.PRO_INSERT_INFO_ARGS( '20220710',:FLAG,:FAIL_INFO);4.Procedures In the menu list Calling stored procedure
stay PL/SQL Developer Tools , In the left object navigation window , Menu path in turn :Users-> User name ->Objects->Procedures, Select the stored procedure to be tested , Right click to select , Click test , Enter the test window , Fill in parameters according to requirements ( If there is any input ). Be careful , The premise of the test menu is that the stored procedure must be compiled and submitted first .
scene : After the stored procedure is submitted , Directly in Procedures Select the stored procedure in the menu list , Call stored procedures to verify and test stored procedures .

5.Package or Package Bodies Call the stored procedure in the menu list
stay PL/SQL Developer Tools , In the left object navigation window , Menu path in turn :Users-> User name ->Objects->Package or Package Bodies, Select the stored procedure to be tested , Right click to select , Click test , Enter the test window , Fill in parameters according to requirements ( If there is any input ). Be careful , The premise of the test menu is that the stored procedure must be compiled and submitted first .
scene : After the stored procedure is submitted , Directly in Package or Package Bodies Select the stored procedure in the menu list , Call stored procedures to verify and test stored procedures .
5.1 Right click the package name , Menu selection : Check the description and body . That is, enter the stored procedure in the package .

5.2 Right click the stored procedure name , Choose a test , Enter the test window .

6.Jobs Menu list Calling stored procedure
stay PL/SQL Developer Tools , In the left object navigation window , Menu path in turn :Users-> User name ->Objects->Jobs, Select the job Mission , Right click to select , Click on the run .
scene : After the stored procedure is submitted , Directly in Jobs Select the stored procedure in the menu list , Call stored procedures to verify and test stored procedures .

7.Java Calling stored procedures in code
This example refers to :https://blog.csdn.net/zhangbeizhen18/article/details/100127703
scene :
Use Java Code calls oracle Stored procedure , This example USES JdbcTemplate Template class operation .
above , thank .
2022 year 7 month 12 Japan
边栏推荐
- Autojs learning - sound transformer template
- Address assignment of global variables, local variables, static variables and constants
- High resolution network (Part 2): backbone and key detector of mmpose code explanation
- Tutorial on the principle and application of database system (019) -- MySQL configuration file
- 【重识云原生】第四章云网络4.9.4.2节——智能网卡实现
- One of the reasons why deepin wine qq/ wechat Chinese is displayed as a box
- 1388.3n pizza dynamic planning
- Niuke - Huawei question bank (81~90)
- 【二叉树】两棵二叉搜索树中的所有元素
- FPGA 20个例程篇:8.SD卡任意地址的读写
猜你喜欢

GPU accelerated opencv Library & reconfigure and generate opencv CUDA version using cmake and vs2019

1388. 3n 块披萨 动态规划

Oracle存储过程的几种调用方式

Web page making (II)

NFT trading platform competition pattern: what is the core competitiveness?

Autojs learning - Application List

#kubeadm安装Kubernetes 1.15最佳实践#

【初始C语言】/*字符函数和字符串函数模拟实现详解*/
![[untitled] pseudo class selector and box model](/img/4d/eb5f429d4841baf6d88ad6eb7a5611.png)
[untitled] pseudo class selector and box model

【无标题】伪类选择器和盒模型
随机推荐
What does SPK interface mean
面试问到加密接口 如何测试 怎么解密 该怎么回答呢
Load balancing LVS cluster details
[initial C language] / * detailed explanation of the simulation of character functions and string functions*/
Defi中的关键 智能合约是什么?
Autojs learning - sound transformer template
Comprehensively analyze the liquidity problems and solutions of NFT
Deepin wine QQ/微信中文显示为方块的原因之一
##负载均衡LVS集群详解##
1388.3n pizza dynamic planning
logback不同的包(业务日志)输出到不同日志文件
A collection of dichotomous (dichotomous answers) questions
高等数学---第八章隐函数偏导数与全微分
query string、formData和request payload的区别
剑指 Offer 09. 用两个栈实现队列
精度提升方法:自适应Tokens的高效视觉Transformer框架(已开源)
基于GPU加速的Opencv库 & 利用cmake和vs2019重新配置并生成Opencv-cuda版本
C语言实训通讯录(静态和动态版本)
Tutorial on the principle and application of database system (019) -- MySQL configuration file
为健康增值,为时代赋能|仙乐健康发布年度可持续发展报告