데이터 베이스 MySQL 튜토리얼 PL/SQL精明的调用栈分析

PL/SQL精明的调用栈分析

Jun 07, 2016 pm 03:21 PM
pl/sql 데이터 베이스

已经给PL/SQL程序分析和问题解决提供了关键的帮助。12C开始引入的UTL_CALL_STACK包意识到改类数据的重要性并进一步增强以使PL/SQ

PL/SQL精明的调用栈分析

The three DBMS_UTILITY functions
(DBMS_UTILITY.FORMAT_CALL_STACK, DBMS_UTILITY.FORMAT_ERROR_STACK, and DBMS_UTILITY.FORMAT_ERROR_ BACKTRACE) have been crucial aids in diagnosing and resolving problems in PL/SQL code. The UTL_CALL_STACK package recognizes the importance of this data and takes a big step forward in giving PL/SQL developers access to more in-depth and useful information
12C以前的3个工具函数(DBMS_UTILITY.FORMAT_CALL_STACK,DBMS_UTILITY.FORMAT_ERROR_STACK,DBMS_UTILITY.FORMAT_ERROR_ BACKTRACE)
已经给PL/SQL程序分析和问题解决提供了关键的帮助。
12C开始引入的UTL_CALL_STACK包意识到改类数据的重要性并进一步增强以使PL/SQL开发者可以获得更多深层次的有用的信息。

–调用栈 Call Stacks :DBMS_UTILITY.FORMAT_CALL_STACK
回答了 “How did I get here?” ,我是怎么一步一步到达这里的?例如:

SQL> CREATE OR REPLACE PROCEDURE proc1
  2  IS
  3  BEGIN
  4    DBMS_OUTPUT.put_line (DBMS_UTILITY.format_call_stack);
  5  END;
  6  /

SQL> CREATE OR REPLACE PACKAGE pkg1
  2  IS
  3    PROCEDURE proc2;
  4  END pkg1;
  5  /

SQL> CREATE OR REPLACE PACKAGE BODY pkg1
  2  IS
  3    PROCEDURE proc2
  4    IS
  5    BEGIN
  6        proc1;
  7    END;
  8  END pkg1;
  9  /

SQL> CREATE OR REPLACE PROCEDURE proc3
  2  IS
  3  BEGIN
  4    FOR indx IN 1 .. 1000
  5    LOOP
  6        NULL;
  7    END LOOP;
  8
  9    pkg1.proc2;
 10  END;
 11  /

SQL> BEGIN
  2    proc3;
  3  END;
  4  /
——————— PL/SQL Call Stack ———————
object handle line number object name
000007FF7EA83240 4 procedure HR.PROC1
000007FF7E9CC3B0 6 package body HR.PKG1
000007FF7EA0A3B0 9 procedure HR.PROC3
000007FF7EA07C00 2 anonymous block

–弊端:
If you call a subprogram in a package, the formatted call stack will show only the package name, not the subprogram name and certainly not the names of nested subprograms defined within that packaged subprogram.
如果我们调用包中的子程序,那么此函数只能显示报名,压根不会显示子程序的名称更别提嵌套子程序的名称了。

If you simply want the name of the most recently executed subprogram, you will have to parse the string. This is not hard to do, but it’s more code that you have to write and maintain.
如果我们仅仅想看下最近执行的子程序名称,还得去解析冗长的字符串。虽然这并不是难事,,但无疑加重了开发者的负担。

The object handle value is, for all practical purposes, “noise.” PL/SQL developers—outside of Oracle, at least—never use it.
object handle值是个鸡肋,无实际用途。

–错误栈 Error Stacks :DBMS_UTILITY.FORMAT_ERROR_STACK Similar to SQLERRM
The DBMS_UTILITY.FORMAT_ERROR_STACK function differs from SQLERRM in two ways:

It can return an error message as long as 1,899 characters, thereby avoiding (or at least making extremely unlikely) truncation issues when the error stack gets long. (SQLERRM truncates at only 510 characters.)

You cannot pass an error code number to this function, and it cannot be used to return the message for an error code.

–错误回溯 Error Backtraces :DBMS_UTILITY.FORMAT_ERROR_BACKTRACE
returns a formatted string that displays a stack of programs and line numbers tracing back to the line on which the error was originally raised.

12c: UTL_CALL_STACK package
Name Description
BACKTRACE_DEPTH Returns the number of backtrace items in the backtrace
BACKTRACE_LINE Returns the line number of the unit at the specified backtrace depth
BACKTRACE_UNIT Returns the name of the unit at the specified backtrace depth
CONCATENATE_SUBPROGRAM Returns a concatenated form of a unit-qualified name
DYNAMIC_DEPTH Returns the number of subprograms in the call stack, including SQL, Java, and other non-PL/SQL contexts invoked along the way—for example, if A calls B calls C calls B, this stack, written as a line with dynamic depths underneath it, will look like this:

A B C B
4 3 2 1

ERROR_DEPTH Returns the number of errors in the call stack
ERROR_MSG Returns the error message of the error at the specified error depth
ERROR_NUMBER Returns the error number of the error at the specified error depth
LEXICAL_DEPTH Returns the lexical nesting level of the subprogram at the specified dynamic depth
OWNER Returns the owner name of the unit of the subprogram at the specified dynamic depth
UNIT_LINE Returns the line number of the unit of the subprogram at the specified dynamic depth
SUBPROGRAM Returns the unit-qualified name of the subprogram at the specified dynamic depth

본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

뜨거운 기사 태그

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

Go 언어는 데이터베이스의 추가, 삭제, 수정 및 쿼리 작업을 어떻게 구현합니까? Go 언어는 데이터베이스의 추가, 삭제, 수정 및 쿼리 작업을 어떻게 구현합니까? Mar 27, 2024 pm 09:39 PM

Go 언어는 데이터베이스의 추가, 삭제, 수정 및 쿼리 작업을 어떻게 구현합니까?

PHP에서 MySQLi를 사용하여 데이터베이스 연결을 설정하는 방법에 대한 자세한 튜토리얼 PHP에서 MySQLi를 사용하여 데이터베이스 연결을 설정하는 방법에 대한 자세한 튜토리얼 Jun 04, 2024 pm 01:42 PM

PHP에서 MySQLi를 사용하여 데이터베이스 연결을 설정하는 방법에 대한 자세한 튜토리얼

Hibernate는 어떻게 다형성 매핑을 구현합니까? Hibernate는 어떻게 다형성 매핑을 구현합니까? Apr 17, 2024 pm 12:09 PM

Hibernate는 어떻게 다형성 매핑을 구현합니까?

iOS 18에는 손실되거나 손상된 사진을 검색할 수 있는 새로운 '복구된' 앨범 기능이 추가되었습니다. iOS 18에는 손실되거나 손상된 사진을 검색할 수 있는 새로운 '복구된' 앨범 기능이 추가되었습니다. Jul 18, 2024 am 05:48 AM

iOS 18에는 손실되거나 손상된 사진을 검색할 수 있는 새로운 '복구된' 앨범 기능이 추가되었습니다.

MySQL과 PL/SQL의 유사점과 차이점 비교 MySQL과 PL/SQL의 유사점과 차이점 비교 Mar 16, 2024 am 11:15 AM

MySQL과 PL/SQL의 유사점과 차이점 비교

HTML이 데이터베이스를 읽는 방법에 대한 심층 분석 HTML이 데이터베이스를 읽는 방법에 대한 심층 분석 Apr 09, 2024 pm 12:36 PM

HTML이 데이터베이스를 읽는 방법에 대한 심층 분석

MySQL 데이터베이스 관리 시스템의 기본 원리 분석 MySQL 데이터베이스 관리 시스템의 기본 원리 분석 Mar 25, 2024 pm 12:42 PM

MySQL 데이터베이스 관리 시스템의 기본 원리 분석

Go WebSocket은 데이터베이스와 어떻게 통합됩니까? Go WebSocket은 데이터베이스와 어떻게 통합됩니까? Jun 05, 2024 pm 03:18 PM

Go WebSocket은 데이터베이스와 어떻게 통합됩니까?

See all articles