存储过程运行日志记录通用模块
目标 实现记录执行存储过程的开始时间,结束时间,运行状态,错误信息等,以函数封装日志记录的方式,存储调用函数 源码 存储过程模版 CREATE OR REPLACE PROCEDURE proc_xx IS --修改标志返回值 V_AFFECT_LINE NUMBER; PROID NUMBER;BEGIN --调用更改标志函
目标
实现记录执行存储过程的开始时间,结束时间,运行状态,错误信息等,以函数封装日志记录的方式,存储调用函数源码
存储过程模版CREATE OR REPLACE PROCEDURE proc_xx IS --修改标志返回值 V_AFFECT_LINE NUMBER; PROID NUMBER; BEGIN --调用更改标志函数,将进程改为运行中'S' V_AFFECT_LINE := INSERT_LOG(PROID,'proc_xx',WIFI.GLOBAL_PARAM.STATUS_START); --逻辑处理函数调用 V_AFFECT_LINE := WIFI.func_xx(); --修改标志,成功置C V_AFFECT_LINE := WIFI.MODIFY_STATUS(PROID,WIFI.GLOBAL_PARAM.STATUS_CLOSE,''); EXCEPTION WHEN OTHERS THEN --调用更改标志函数,将进程改为出错'F' V_AFFECT_LINE := MODIFY_STATUS(PROID,WIFI.GLOBAL_PARAM.STATUS_FAILED,WIFI.GLOBAL_PARAM.LOG_EXCEPTION); END;
create or replace function func_xx return int is begin .... return 1; exception when others then set_error_log (); RETURN 0; end;
CREATE OR REPLACE FUNCTION INSERT_LOG ( proid OUT NUMBER, program_name IN VARCHAR2, status IN VARCHAR2 ) RETURN NUMBER IS ------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------------------------ --- -- -功能描述: 初始化日志 ---------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------------------------------ BEGIN INSERT INTO program_log VALUES (program_log_seq.NEXTVAL, TO_CHAR (SYSDATE, 'YYYYMMDD'), program_name, SYSDATE, NULL, status, ''); SELECT program_log_seq.CURRVAL INTO proid FROM dual; COMMIT; RETURN 1; EXCEPTION WHEN OTHERS THEN RETURN 0; END; CREATE OR REPLACE FUNCTION MODIFY_STATUS ( proId IN number, status IN varchar2, proDesc in varchar2) RETURN NUMBER IS thisDate date; BEGIN ------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------------------------ --- -- -功能描述: 修改日志表存储过程运行状态,记录开始时间 结束时间 出错信息 ---------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------------------------------ thisDate := sysdate; --更新状态 出错信息 update program_log set program_status=status, memo=proDesc where id=proId; --更新日期:如果是运行中,更新起始运行日期;如果是运行成功或者运行失败,更新结束运行日期 IF status='S' THEN update program_log set start_date=thisDate where id=proId; ELSIF status='C' THEN update program_log set end_date=thisDate where id=proId; ELSIF status='F' THEN update program_log set end_date=thisDate where id=proId; COMMIT; RAISE_APPLICATION_ERROR(-20040,'STATUS IS F'); END IF; /* ELSIF status='C' OR status='F' THEN update program_log set end_date=thisDate where id=proId; END IF;*/ commit; RETURN 1; EXCEPTION WHEN OTHERS THEN RAISE_APPLICATION_ERROR(-20041,'STATUS IS F'); RETURN 0; END; CREATE OR REPLACE PROCEDURE SET_ERROR_LOG IS BEGIN GLOBAL_PARAM.LOG_EXCEPTION := 'error desc---'||sqlerrm; commit; RAISE no_data_found; END; -- Procedure; CREATE OR REPLACE PACKAGE GLOBAL_PARAM IS LOG_EXCEPTION VARCHAR2(2000):=''; STATUS_START VARCHAR2(10):='S'; STATUS_CLOSE VARCHAR2(10):='C'; STATUS_FAILED VARCHAR2(10):='F'; END;
create table PROGRAM_LOG ( ID NUMBER not null, BATCH_NUMBER VARCHAR2(50), PROGRAM_NAME VARCHAR2(100), START_DATE DATE, END_DATE DATE, PROGRAM_STATUS VARCHAR2(20), MEMO VARCHAR2(2000) )

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Pinduoduo software provides a lot of good products, you can buy them anytime and anywhere, and the quality of each product is strictly controlled, every product is genuine, and there are many preferential shopping discounts, allowing everyone to shop online Simply can not stop. Enter your mobile phone number to log in online, add multiple delivery addresses and contact information online, and check the latest logistics trends at any time. Product sections of different categories are open, search and swipe up and down to purchase and place orders, and experience convenience without leaving home. With the online shopping service, you can also view all purchase records, including the goods you have purchased, and receive dozens of shopping red envelopes and coupons for free. Now the editor has provided Pinduoduo users with a detailed online way to view purchased product records. method. 1. Open your phone and click on the Pinduoduo icon.

How to execute .sh file in Linux system? In Linux systems, a .sh file is a file called a Shell script, which is used to execute a series of commands. Executing .sh files is a very common operation. This article will introduce how to execute .sh files in Linux systems and provide specific code examples. Method 1: Use an absolute path to execute a .sh file. To execute a .sh file in a Linux system, you can use an absolute path to specify the location of the file. The following are the specific steps: Open the terminal

How to implement dual WeChat login on Huawei mobile phones? With the rise of social media, WeChat has become one of the indispensable communication tools in people's daily lives. However, many people may encounter a problem: logging into multiple WeChat accounts at the same time on the same mobile phone. For Huawei mobile phone users, it is not difficult to achieve dual WeChat login. This article will introduce how to achieve dual WeChat login on Huawei mobile phones. First of all, the EMUI system that comes with Huawei mobile phones provides a very convenient function - dual application opening. Through the application dual opening function, users can simultaneously

This website reported on March 7 that Dr. Zhou Yuefeng, President of Huawei's Data Storage Product Line, recently attended the MWC2024 conference and specifically demonstrated the new generation OceanStorArctic magnetoelectric storage solution designed for warm data (WarmData) and cold data (ColdData). Zhou Yuefeng, President of Huawei's data storage product line, released a series of innovative solutions. Image source: Huawei's official press release attached to this site is as follows: The cost of this solution is 20% lower than that of magnetic tape, and its power consumption is 90% lower than that of hard disks. According to foreign technology media blocksandfiles, a Huawei spokesperson also revealed information about the magnetoelectric storage solution: Huawei's magnetoelectronic disk (MED) is a major innovation in magnetic storage media. First generation ME

Do you know how to run m files in matlab? Below, the editor will bring you a tutorial on how to run m files in matlab. I hope it will be helpful to you. Let’s learn with the editor! 1. First open the matlab software and select the upper left "Open" the corner, as shown in the picture below. 2. Then select the m file to be run and open it, as shown in the figure below. 3. Press F5 in the window to run the program, as shown in the figure below. 4. We can view the running results in the command line window and workspace, as shown in the figure below. 5. You can also run the file by clicking "Run" directly, as shown in the figure below. 6. Finally, you can view the running results of the m file in the command line window and workspace, as shown in the figure below. The above is the matlab method that the editor brought to you

The programming language PHP is a powerful tool for web development, capable of supporting a variety of different programming logics and algorithms. Among them, implementing the Fibonacci sequence is a common and classic programming problem. In this article, we will introduce how to use the PHP programming language to implement the Fibonacci sequence, and attach specific code examples. The Fibonacci sequence is a mathematical sequence defined as follows: the first and second elements of the sequence are 1, and starting from the third element, the value of each element is equal to the sum of the previous two elements. The first few elements of the sequence

How to implement the WeChat clone function on Huawei mobile phones With the popularity of social software and people's increasing emphasis on privacy and security, the WeChat clone function has gradually become the focus of people's attention. The WeChat clone function can help users log in to multiple WeChat accounts on the same mobile phone at the same time, making it easier to manage and use. It is not difficult to implement the WeChat clone function on Huawei mobile phones. You only need to follow the following steps. Step 1: Make sure that the mobile phone system version and WeChat version meet the requirements. First, make sure that your Huawei mobile phone system version has been updated to the latest version, as well as the WeChat App.

In Linux systems, you can use the following command to view the contents of the log file: tail command: The tail command is used to display the content at the end of the log file. It is a common command to view the latest log information. tail [option] [file name] Commonly used options include: -n: Specify the number of lines to be displayed, the default is 10 lines. -f: Monitor the file content in real time and automatically display the new content when the file is updated. Example: tail-n20logfile.txt#Display the last 20 lines of the logfile.txt file tail-flogfile.txt#Monitor the updated content of the logfile.txt file in real time head command: The head command is used to display the beginning of the log file
