当前位置:网站首页>ORACLE EBS中消息队列fnd_msg_pub、fnd_message在PL/SQL中的应用
ORACLE EBS中消息队列fnd_msg_pub、fnd_message在PL/SQL中的应用
2022-07-02 06:24:00 【贤时间】
EBS 中集成的FND_MSG处理很方便的在form中很方便的弹窗、提示消息之外,在写PL/SQL包的时候,也可以方便的进行借用来进行错误信息的收集。并且这个是基于session的,不同于客户化的log日志表。
原理及用法说明
图片1(IBY_UNIQ_ACCOUNT):
图片2(AFDICT- DATABASE STATS):
实例代码:
DECLARE
x_msg_count NUMBER;
x_msg_data VARCHAR2(3000);
v_msg_index_out NUMBER;
v_data VARCHAR2(1000);
BEGIN
fnd_msg_pub.Initialize;--或者 fnd_message.CLEAR;
fnd_message.set_name('IBY', 'IBY_UNIQ_ACCOUNT'); --设置消息名称
fnd_msg_pub.add; --添加到Global Area
fnd_message.set_name('FND', 'AFDICT- DATABASE STATS'); --设置消息名称
fnd_message.set_token('UPDATES', 'Steven123'); --设置消息内容中变量的值
fnd_message.set_token('INSERTS', 'Steven321'); --设置消息内容中变量的值
fnd_msg_pub.add; --添加到Global Area
--当x_msg_count 为1时,直接输出x_msg_data,否则需要循环输出
fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false, p_count => x_msg_count, p_data => x_msg_data);
dbms_output.put_line('x_msg_count:' || x_msg_count);
dbms_output.put_line('x_msg_data:' || x_msg_data);
FOR k IN 1 .. x_msg_count
LOOP
fnd_msg_pub.get(p_msg_index => k,
p_encoded => fnd_api.g_false,
p_data => v_data,
p_msg_index_out => v_msg_index_out);
dbms_output.put_line('(' || v_msg_index_out || ')->' || v_data);
END LOOP;
fnd_msg_pub.delete_msg();
END;
输出信息:
x_msg_count:2
x_msg_data:
(1)->外部银行帐户已存在
(2)->已更新 Steven123 信息,并已插入 Steven321 信息。
由上面可以看出fnd_message.set_name(APPLICATION => , NAME => ); 这个过程第一个参数是填入应用简称,第2个填入预先定义好的错误消息代码。
fnd_message.set_token(‘UPDATES’, ‘Steven123’) 就是把消息定义中的&XXX 给替换成实际的值。
存储过程二次封装
输出的时候一般用下面这个存储过程输出:
PROCEDURE log_message_list_p IS
l_msg_index NUMBER;
l_msg_data VARCHAR2(2000);
-------------------------------输出消息队列里面的消息-----------------------
BEGIN
IF (fnd_msg_pub.count_msg > 0) THEN
log_p('Error Message Stack :');
log_p('----------------------------------------');
FOR i IN 1 .. fnd_msg_pub.count_msg LOOP
fnd_msg_pub.get(p_msg_index => i,
p_encoded => fnd_api.g_false,
p_data => l_msg_data,
p_msg_index_out => l_msg_index);
log_p(l_msg_data);
END LOOP;
log_p('format_error_stack:' || chr(10) ||
dbms_utility.format_error_stack);
log_p('format_call_stack:' || chr(10) ||
dbms_utility.format_call_stack);
log_p('format_error_backtrace:' || chr(10) ||
dbms_utility.format_error_backtrace);
END IF;
EXCEPTION
WHEN OTHERS THEN
NULL;
END log_message_list_p;
在请求中的应用
如果用到EBS请求中的话,还可以这样用:
PROCEDURE main_p(errbuf OUT VARCHAR2,
retcode OUT VARCHAR2,
p_period_num_from IN VARCHAR2,
p_period_num_to IN VARCHAR2) IS
l_return_status VARCHAR2(30);
l_msg_data VARCHAR2(2000);
l_msg_count NUMBER;
------------------------------调用输出程序------------------
BEGIN
retcode := '0';
--............................
--业务处理逻辑代码XXXXX
--调用标准API
--...........................
EXCEPTION
WHEN fnd_api.g_exc_error THEN
log_message_list_p;
retcode := '1';
fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
p_count => l_msg_count,
p_data => l_msg_data);
IF l_msg_count > 1 THEN
l_msg_data := fnd_msg_pub.get_detail(p_msg_index => fnd_msg_pub.g_first,
p_encoded => fnd_api.g_false);
END IF;
errbuf := l_msg_data;
WHEN fnd_api.g_exc_unexpected_error THEN
log_message_list_p;
retcode := '2';
fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
p_count => l_msg_count,
p_data => l_msg_data);
IF l_msg_count > 1 THEN
l_msg_data := fnd_msg_pub.get_detail(p_msg_index => fnd_msg_pub.g_first,
p_encoded => fnd_api.g_false);
END IF;
errbuf := l_msg_data;
WHEN OTHERS THEN
log_p(dbms_utility.format_error_stack ||
dbms_utility.format_error_backtrace);
fnd_msg_pub.add_exc_msg(p_pkg_name => g_pkg_name,
p_procedure_name => 'MAIN_P',
p_error_text => substrb(SQLERRM, 1, 240));
log_message_list_p;
retcode := '2';
errbuf := SQLERRM;
END main_p;
参考资料
http://blog.itpub.net/25684327/viewspace-694126/
https://imdjkoch.wordpress.com/tag/fnd_message-set_token/
https://docs.oracle.com/cd/E18727_01/doc.121/e12897/T302934T462354.htm
边栏推荐
- Latex warning: citation "*****" on page y undefined on input line*
- Sentry construction and use
- Sqli labs customs clearance summary-page2
- Laravel8中的find_in_set、upsert的使用方法
- Latex error: the font size command \normalsize is not defined problem solved
- Build FRP for intranet penetration
- table 组件指定列合并行方法
- ORACLE 11.2.0.3 不停机处理SYSAUX表空间一直增长问题
- SQL injection closure judgment
- JS judge whether the object is empty
猜你喜欢

UEditor . Net version arbitrary file upload vulnerability recurrence

uniapp引入本地字体

sqli-labs通關匯總-page2

SQLI-LABS通关(less18-less20)

Queue (linear structure)

Cve - 2015 - 1635 (ms15 - 034) réplication de la vulnérabilité d'exécution de code à distance

Go package name

PHP Session原理简析

SQL注入闭合判断

In depth study of JVM bottom layer (V): class loading mechanism
随机推荐
oracle EBS标准表的后缀解释说明
[Zhang San learns C language] - deeply understand data storage
Take you to master the formatter of visual studio code
CSRF攻击
Eggjs -typeorm treeenity practice
搭建frp进行内网穿透
外币记账及重估总账余额表变化(下)
Latex compilation error I found no \bibstyle &\bibdata &\citation command
图解Kubernetes中的etcd的访问
2021-07-17C#/CAD二次开发创建圆(5)
Stack (linear structure)
ModuleNotFoundError: No module named ‘jieba. analyse‘; ‘ jieba‘ is not a package
Thinkphp5中一个字段对应多个模糊查询
Basic knowledge of software testing
js判断数组中对象是否存在某个值
pySpark构建临时表报错
ORACLE APEX 21.2安装及一键部署
In depth study of JVM bottom layer (II): hotspot virtual machine object
The default Google browser cannot open the link (clicking the hyperlink does not respond)
pm2简单使用和守护进程