PL/SQL warnings 1
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PL/SQL warnings 1相关的知识,希望对你有一定的参考价值。
PL/SQL编程在默认下不启用warning,可以通过手动启用会话级、程序级、系统全局级PL/SQLwarning功能。
PL/SQLwarning categories
SEVERE 严格的
PERFORMANCE 性能警告
INFORMAIONAL 参考警告
pl/sql warnings parameter
SQL> show parameters plsql_warnings NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ plsql_warnings string DISABLE:ALL
pl/sql warning 主要用于pl/sql编译过程中触发的警告问题,警告和错误不同,有警告也可以继续运行。
测试案例:
Create test table: [email protected]>create table test1( id varchar2(20) constraint pk_id primary key, str1 clob); Table created. [email protected]>INSERT INTO test1 SELECT rownum, text FROM all_source; 103948 rows created. Create PL/SQL procedure: CREATE OR REPLACE FUNCTION get_test1_text ( v_id NUMBER ) RETURN VARCHAR2 IS v_str test1.str1%type; BEGIN SELECT str1 INTO v_str FROM test1 WHERE id = v_id; RETURN v_str; EXCEPTION WHEN NO_DATA_FOUND THEN RETURN ‘No value found‘; END; / [email protected]>alter session set plsql_warnings=‘ENABLE:ALL‘; Session altered. [email protected]>CREATE OR REPLACE FUNCTION get_test1_text ( v_id NUMBER ) RETURN VARCHAR2 2 IS 3 v_str test1.str1%type; 4 BEGIN 5 SELECT str1 INTO v_str FROM test1 WHERE id = v_id; 6 RETURN v_str; 7 EXCEPTION 8 WHEN NO_DATA_FOUND THEN RETURN ‘No value found‘; 9 END; 10 / SP2-0806: Function created with compilation warnings [email protected]>show err Errors for FUNCTION GET_TEST1_TEXT: LINE/COL ERROR -------- ----------------------------------------------------------------- 1/1 PLW-05018: unit GET_TEST1_TEXT omitted optional AUTHID clause; default value DEFINER used 5/42 PLW-07204: conversion away from column type may result in sub-optimal query plan
通过警告可以确定相应的问题。
如何确定warning的category
[email protected]>SELECT dbms_warning.get_category(7024) FROM dual 2 ; DBMS_WARNING.GET_CATEGORY(7024) -------------------------------------------------------------------------------- PERFORMANCE [email protected]>SELECT dbms_warning.get_category(5018) FROM dual; DBMS_WARNING.GET_CATEGORY(5018) -------------------------------------------------------------------------------- SEVERE
本文出自 “DBA的天空” 博客,请务必保留此出处http://kevinora.blog.51cto.com/9406404/1742972
以上是关于PL/SQL warnings 1的主要内容,如果未能解决你的问题,请参考以下文章