zoukankan      html  css  js  c++  java
  • 【案例】ORA-00904: "WMSYS"."WM_CONCAT": 标识符无效

    手动创建Function

    以SYS用户创建包、包体、函数

    CREATE OR REPLACE TYPE WM_CONCAT_IMPL AS OBJECT
    (
    CURR_STR VARCHAR2(32767), 
    STATIC FUNCTION ODCIAGGREGATEINITIALIZE(SCTX IN OUT WM_CONCAT_IMPL) RETURN NUMBER,
    MEMBER FUNCTION ODCIAGGREGATEITERATE(SELF IN OUT WM_CONCAT_IMPL,
    P1 IN VARCHAR2) RETURN NUMBER,
    MEMBER FUNCTION ODCIAGGREGATETERMINATE(SELF IN WM_CONCAT_IMPL,
    RETURNVALUE OUT VARCHAR2,
    FLAGS IN NUMBER)
    RETURN NUMBER,
    MEMBER FUNCTION ODCIAGGREGATEMERGE(SELF IN OUT WM_CONCAT_IMPL,
    SCTX2 IN WM_CONCAT_IMPL) RETURN NUMBER
    );
    View Code

    创建类型body

    CREATE OR REPLACE TYPE BODY WM_CONCAT_IMPL
    IS
    STATIC FUNCTION ODCIAGGREGATEINITIALIZE(SCTX IN OUT WM_CONCAT_IMPL)
    RETURN NUMBER
    IS
    BEGIN
    SCTX := WM_CONCAT_IMPL(NULL) ;
    RETURN ODCICONST.SUCCESS;
    END;
    MEMBER FUNCTION ODCIAGGREGATEITERATE(SELF IN OUT WM_CONCAT_IMPL,
    P1 IN VARCHAR2)
    RETURN NUMBER
    IS
    BEGIN
    IF(CURR_STR IS NOT NULL) THEN
    CURR_STR := CURR_STR || ',' || P1;
    ELSE
    CURR_STR := P1;
    END IF;
    RETURN ODCICONST.SUCCESS;
    END;
    MEMBER FUNCTION ODCIAGGREGATETERMINATE(SELF IN WM_CONCAT_IMPL,
    RETURNVALUE OUT VARCHAR2,
    FLAGS IN NUMBER)
    RETURN NUMBER
    IS
    BEGIN
    RETURNVALUE := CURR_STR ;
    RETURN ODCICONST.SUCCESS;
    END;
    MEMBER FUNCTION ODCIAGGREGATEMERGE(SELF IN OUT WM_CONCAT_IMPL,
    SCTX2 IN WM_CONCAT_IMPL)
    RETURN NUMBER
    IS
    BEGIN
    IF(SCTX2.CURR_STR IS NOT NULL) THEN
    SELF.CURR_STR := SELF.CURR_STR || ',' || SCTX2.CURR_STR ;
    END IF;
    RETURN ODCICONST.SUCCESS;
    END;
    END;
    View Code

    创建函数

    CREATE OR REPLACE FUNCTION wm_concat(P1 VARCHAR2) RETURN VARCHAR2 AGGREGATE USING WM_CONCAT_IMPL ;

    创建同义词并授权

    create public synonym WM_CONCAT_IMPL for sys.WM_CONCAT_IMPL;
    create public synonym wm_concat for sys.wm_concat;
    grant execute on WM_CONCAT_IMPL to public;
    grant execute on wm_concat to public;
    SQL> @?/rdbms/admin/owmctab.plb
    SQL> @?/rdbms/admin/owmaggrs.plb
    SQL> @?/rdbms/admin/owmaggrb.plb

    Before Oracle Database 12c, an Invoker Rights (IR) unit always ran with the privileges of its invoker.
    If its invoker had higher privileges than its owner, then the IR unit might perform operations unintended by,
    or forbidden to, its owner. As of Oracle Database 12c, an IR unit can run with the privileges
    of its invoker only if its owner has either the INHERIT PRIVILEGES privilege on the invoker or the INHERIT ANY PRIVILEGES privilege.

    GRANT INHERIT PRIVILEGES ON USER SYS TO public;

    SQL> select owner,object_name,object_type from dba_objects where owner='WMSYS' and object_type ='FUNCTION';

    OWNER OBJECT_NAME OBJECT_TYPE
    -------------------- ---------------------------------------- -----------------------
    WMSYS WM_CONCAT FUNCTION

    SQL>

  • 相关阅读:
    聚簇索引和非聚簇索引(通俗易懂 言简意赅)
    Java-线程池专题(什么是线程池,如何使用,为什么要用)
    在Spring Boot中动态实现定时任务配置
    面试被问:如果系统 CPU 突然飙升且 GC 频繁,你该如何排查?
    深入理解volatile
    redis3.0常用命令
    redis3.0配置文件详解
    mysql max_allowed_packet 设置过小导致记录写入失败
    linux 项目部署问题
    python sokct 包详解
  • 原文地址:https://www.cnblogs.com/elontian/p/13176147.html
Copyright © 2011-2022 走看看