当前位置:网站首页>Kingbasees plug-in DBMS of Jincang database_ UTILITY
Kingbasees plug-in DBMS of Jincang database_ UTILITY
2022-06-25 11:07:00 【Thousands of sails pass by the side of the sunken boat_】
1. DBMS_UTILITY System package overview
DBMS_UTILITY The system package provides some subroutines with general functions .
DBMS_UTILITY The system package does not support PG Pattern .
2. DBMS_UTILITY System package subprogram
DBMS_UTILITY The subroutines and brief introduction contained in the system package are shown in the following table :
surface 1 DBMS_UTILITY Package subprogram
| Subroutines | brief introduction |
FORMAT_CALL_STACK function | Returns the current call stack . |
FORMAT_ERROR_STACK function | Returns the current error stack . |
FORMAT_ERROR_BACKTRACE function | Returns the current error backtracking information . |
GET_TIME function | Return a timestamp . |
2.1. FORMAT_CALL_STACK function
This function can return the current call stack information , Include the address of the calling object , The line number of the call and the name of the call object , It can be used in functions 、 Stored procedure or trigger, etc PL/SQL In the object , Used to help debug PL/SQL Program .
grammar :
DBMS_UTILITY.FORMAT_CALL_STACK() RETURN TEXT;
DBMS_UTILITY.FORMAT_CALL_STACK(FORMAT TEXT) RETURN TEXT;
At present, the address of the calling object is the address of the function or procedure oid value , If it is a built-in function or procedure, it is the corresponding package oid value .
Instructions :
FORMAT: Specify the display mode of the call stack information , There were 'o', 'p', 's' Three models . The default usage mode is 'p' Pattern , Output 8 Bit effective length decimal number output object address information .
- among 'o' Parameters will be '%8x%8d%s' Format print object address , Call line number , Object name , As the sample 2 Shown .
- among 'p' Parameters will be '%8d%8d%s' Format print object address , Call line number , Object name , As the sample 3 Shown .
- among 's' Parameters will be '%d,%d,%s' Format print object address , Call line number , Object name , As the sample 4 Shown .
Example :
\set SQLTERM /
CREATE OR REPLACE FUNCTION checkCallStack() RETURNS TEXT AS
stack TEXT;
BEGIN
SELECT dbms_utility.format_call_stack() INTO stack ;
RETURN stack;
END;
/
\set SQLTERM ;
call checkCallStack();
checkcallstack
--------------------------------------------------------------------
----- PL/SQL Call Stack ----- +
object line object +
handle number name +
14575 30 package body sys.dbms_utility.format_call_stack+
16387 4 function public.checkcallstack
(1 row)
2.2. FORMAT_ERROR_STACK function
This function is used to return the error stack of the current program when an exception occurs , If there is no exception in the program , Then return to NULL.
grammar :
DBMS_UTILITY.FORMAT_ERROR_STACK() RETURN TEXT;
2.3. FORMAT_ERROR_BACKTRACE function
This function is used to return the error backtrace stack when the current program has an exception , If there is no exception in the program , Then return to NULL.
grammar :
DBMS_UTILITY.FORMAT_ERROR_BACKTRACE() RETURN TEXT;
Example :
\set SQLTERM /
CREATE OR REPLACE PROCEDURE p01() AS
i INT := 0;
BEGIN
i = i/0;
END;
/
\set SQLTERM ;
\set SQLTERM /
CREATE OR REPLACE PROCEDURE p02() AS
detail TEXT;
stack TEXT;
BEGIN
p01();
EXCEPTION
WHEN DIVISION_BY_ZERO THEN
detail = dbms_utility.format_error_stack();
stack = dbms_utility.format_error_backtrace();
DBMS_OUTPUT.PUT_LINE('FORMAT_ERROR_STACK IS:');
DBMS_OUTPUT.PUT_LINE(detail);
DBMS_OUTPUT.PUT_LINE('FORMAT_ERROR_BACKTRACE IS:');
DBMS_OUTPUT.PUT_LINE(stack);
END;
/
\set SQLTERM ;
CALL p02();
FORMAT_ERROR_STACK IS:
division by zero
at "public.p01", line 4
FORMAT_ERROR_BACKTRACE IS:
at "public.p01", line 4
at "public.p02", line 5
2.4. GET_TIME function
This function is used to return a timestamp , This timestamp is not a standard system timestamp , The unit is centisecond ( One hundredth of a second ). Usually in PL/SQL Program starts The function is called once at the end of and , Then subtract the previous number from the latter number , To determine the execution time of the current program .
grammar :
DBMS_UTILITY.GET_TIME() RETURN NUMBER;
Instructions :
The return value of the function is in -2147483648 To 2147483647 Between , The specific value depends on the machine and system . When the function is called , Applications You need to consider the sign of the return value . for example , Both calls are negative numbers , Or the first call is negative , The second call is a positive number .
Example :
\set SQLTERM /
CREATE OR REPLACE PROCEDURE TestGetTime() AS
t1 PLS_INTEGER;
t2 PLS_INTEGER;
BEGIN
t1 := dbms_utility.get_time();
perform pg_sleep(3);
t2 := dbms_utility.get_time();
RAISE NOTICE 'sleeped: % sec.', (t2 - t1) / 100;
END;
/
\set SQLTERM ;
call TestGetTime();
NOTICE: sleeped: 3 sec.
边栏推荐
- Previous string inversion topic
- COSCon'22 讲师征集令
- Es learning
- 《天天数学》连载52:二月二十日
- June 24, 2022: golang multiple choice question, what does the following golang code output? A:1; B:3; C:4; D: Compilation failed. package main import ( “fmt“ ) func mai
- Oracle彻底卸载的完整步骤
- 中國信通院沈瀅:字體開源協議——OFL V1.1介紹及合規要點分析
- Ouverture de l'inscription | le troisième marathon des hackers de pagaie est arrivé comme prévu.
- 金仓数据库 KingbaseES 插件DBMS_OUTPUT
- CSRF attack
猜你喜欢

CSRF attack

Detailed explanation of Android interview notes handler

Open source invites you to participate in the openssf Open Source Security Online Seminar

Nuxtjs actual combat case

Binder explanation of Android interview notes

Shen Ying, China Academy of communications and communications: font open source protocol -- Introduction to ofl v1.1 and analysis of key points of compliance

Compilation of learning from Wang Shuang (1)

SystemVerilog(十三)-枚举数据类型

无心剑中译伊玛·拉扎罗斯《新巨人·自由女神》

Network remote access using raspberry pie
随机推荐
仿真与烧录程序有哪几种方式?(包含常用工具与使用方式)
视频会议一体机的技术实践和发展趋势
OODA工作法
GaussDB 如何统计用户sql的响应时间
Network remote access using raspberry pie
Android之Kotlin语法详解与使用
What are the functions of arm64 assembly that need attention?
GCC related
16 enterprise architecture strategies
How gaussdb counts the response time of user SQL
Detailed explanation of Android interview notes handler
每日3題(3)-檢查整數及其兩倍數是否存在
FPGA displays characters and pictures based on VGA
3 Questions par jour (3) - vérifier l'existence d'entiers et de leurs doubles
A five-year technical Er, based on the real experience of these years, gives some suggestions to the fresh students
Gaussdb cluster maintenance case set - slow SQL execution
報名開啟|飛槳黑客馬拉松第三期如約而至,久等啦
一个数学难题,难倒两位数学家
金仓数据库 KingbaseES 插件force_view
XSS attack