SAP HANA AFL插件库升级后之前生成的存储过程升级方法(PAL升级方法)

在AFL库升级之后,之前创建的存储过程需要进行相应的升级,这个时候一般需要重新运行AFL_WRAPPER_GENERATOR。在前面的例子中,我们知道在重新运行该存储过程的时候,因为之前已经生成相应的存储过程,则一定会报错。如何应对这种情况?

之前已生成的实例: http://www.cnblogs.com/omygod/archive/2013/05/03/3056971.html

 

SAP HANA提供两种方法:

1. 手工删除之前的存储过程及表类型,再重新运行AFL_WRAPPER_GENERATOR。该方法在之前的文章中已有提及:

http://www.cnblogs.com/omygod/archive/2013/05/04/3059728.html

DROP PROCEDURE _SYS_AFL.PAL_TS_S;
DROP TYPE _SYS_AFL.PAL_TS_S__TT_P1;
DROP TYPE _SYS_AFL.PAL_TS_S__TT_P2;
DROP TYPE _SYS_AFL.PAL_TS_S__TT_P3;

CALL SYSTEM.AFL_WRAPPER_GENERATOR ('PAL_TS_S', 'AFLPAL', 'SINGLESMOOTH', PAL_TS_SIGNATURE);


 

2. SAP Note 1830239提供解决方法,该文主要从该方法进行探讨

SAP Note 1830239具体内容为:

Summary

Symptom


You run AFL_WRAPPER_GENERATOR and get an error like:

"SAP DBTech JDBC: [423]: liveCache error: [423] SYSTEM.AFL_WRAPPER_GENERATOR: line 35 col 1 (at pos 1718): liveCache error exception: liveCache error: registration finished with errors, see indexserver trace"

And in the indexserver trace there is a message like:

"cannot use duplicate user-defined type name - PAL_TS_S__TT_P2: line 1 col 22 (at pos 21): line 1 col 22 (at pos 21)"


Other terms


AFL error, PAL

Reason and Prerequisites


You are using AFL_WRAPPER_GENERATOR to generate a procedure to call a PAL Application Function. The procedure was already generated before in a previous call to the wrapper generator. Now you are facing duplicates.

The PAL manual describes how all tables types and the procedure itself have to be dropped manually in advance. But this step  was not perfomed (successfully).


Solution


Instead of dropping all relevant table types and the procedure manually the counter part to AFL_WRAPPER_GENERATOR called AFL_WRAPPER_ERASER can be used.

Please proceed as follows:

1. Connect to the database as user SYSTEM via Hana Studio.2. Copy the attached file afl_wrapper_eraser.txt to a sql window and execute it.3. Grant the execution of afl_wrapper_eraser to the relevant user:

           grant execute on system.afl_wrapper_eraser to ...

4. Connect as this user and run system.afl_wrapper_eraser for the procedure causing trouble.




Header Data

   
Release Status: Released for Customer
Released on: 05.04.2013  11:20:16
Master Language: English
Priority: Correction with medium priority
Category: Program error
Primary Component: BC-DB-HDB-AFL SAP HANA Application Function Library

Affected Releases

Release-Independent

 

 

该Note所阐释的方法如下:

1. 生成系统存储过程AFL_WRAPPER_ERASER。sql语句如下:

CREATE PROCEDURE afl_wrapper_eraser(IN procOrig VARCHAR(100)) LANGUAGE SQLSCRIPT
AS
v_num integer := 0;
v_sqlscript VARCHAR(32767) := '';
proc VARCHAR(32767) := UPPER(:procOrig);
CURSOR c_parameter_table_name FOR
   SELECT TABLE_NAME
        FROM "SYS"."TABLES"
        WHERE SCHEMA_NAME = '_SYS_AFL'
        AND TABLE_NAME like :proc || '__TT_P%';
BEGIN

-- proc
select count(1) into v_num from SYS.PROCEDURES where SCHEMA_NAME = '_SYS_AFL' and PROCEDURE_NAME = :proc;
if :v_num > 0 then
   v_sqlscript := 'drop procedure _SYS_AFL.' || proc;
   exec :v_sqlscript;
end if;

-- type
select count(1) into v_num from SYS.TABLES where SCHEMA_NAME = '_SYS_AFL' and TABLE_NAME like :proc || '__TT_P%';
if :v_num > 0 then
   v_sqlscript := 'drop type _SYS_AFL.';
   FOR cur_row_detail AS c_parameter_table_name DO
        v_sqlscript := :v_sqlscript || cur_row_detail.TABLE_NAME;
        exec :v_sqlscript;
        v_sqlscript := 'drop type _SYS_AFL.';
   END FOR;
end if;

END;
 
2. 如果运行该存储过程的为其他用户,我们需要对其他用户进行授权:

GRANT EXECUTE ON SYSTEM.AFL_WRAPPER_ERASER TO User1;

该方法会删除方法及相应的table type。

3. 重新运行AFL_WRAPPER_GENERATOR。

 

实例如下:

CALL SYSTEM.AFL_WRAPPER_ERASER ('PAL_TS_S');

CALL SYSTEM.AFL_WRAPPER_GENERATOR ('PAL_TS_S', 'AFLPAL', 'SINGLESMOOTH', PAL_TS_SIGNATURE);

专注于企业信息化,最近对股票数据分析较为感兴趣,可免费分享股票个股主力资金实时变化趋势分析工具,股票交流QQ群:457394862
分类: SAP HANA

本文转自沧海-重庆博客园博客,原文链接:http://www.cnblogs.com/omygod/archive/2013/05/04/3059841.html,如需转载请自行联系原作者
上一篇:外军网络空间作战简报


下一篇:开锁与网络安全的5个相通之处