要隐藏警告的语法:where条件中使用的字段可能包含空值 [英] Pragma to Hide Warning: the field used in the where condition may contain null values

查看:486
本文介绍了要隐藏警告的语法:where条件中使用的字段可能包含空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种编译指示,可用于隐藏在select的WHERE条件下使用的字段在数据库中可能包含NULL值时生成的编译器警告。

I'm looking for a pragma I can use to hide the compiler warning generated when a field used in the WHERE condition of a select may contain NULL values in the database.

已阅读SAP注释1088403,我知道这里可能存在问题,但是由于我使用的是范围,而不是WHERE子句中的单个值,因此无法应用此处建议的解决方案。无论哪种情况,这都是从未发现有缺陷的遗留代码(据我们所知),不久就会被替换。

Having read SAP note 1088403, I am aware of the possible issues here but I cannot apply the solutions suggested there since I'm using a range, not a single value in the WHERE clause. In either case this is legacy code that was never found to be defective (as far as we know) and will be replaced before long.

但是当我重写其他代码时程序部分,我想使用 pragma 禁用此警告。有人可以告诉我我可以为此使用什么编译指示吗?

However while I'm rewriting other sections of the program, I'd like to disable this warning with a pragma. Could anyone tell me what pragma I'd be able to use for this?

示例选择:

SELECT d~matnr d~werks d~lgort d~bdmng k~maktx
INTO CORRESPONDING FIELDS OF TABLE itab
FROM resb AS d
INNER JOIN makt AS k ON d~matnr = k~matnr
WHERE
    k~spras = syst-langu
    AND d~werks = p_werks
    AND d~matnr IN s_matnr
    AND d~bwart IN r_bwart.

请注意,此后我使用动态where子句替换了该选择,它也隐藏了警告因为编译器显然无法检查基于文本的位置。

Note that I've since replaced this select with one using a dynamic where clause which also hides the warning since the compiler obviously can't check a text-based where.

推荐答案

如果您使用以下命令对程序运行扩展语法检查在此代码段中,您会看到它明确指出并没有抑制这种情况的方法(强调我的意思):

If you run the extended syntax check over a program with this snippet in, you will see that it specifically states there is no pragma to suppress this (emphasis mine):

程序:< program_name>行:< row>

语法检查警告

在WHERE条件下使用的字段 BWART可能包含NULL值。

内部消息代码:MESSAGE GYT

不能使用杂注或伪注释抑制

Program: <program_name> Row: <row>
Syntax check warning
The field "BWART" used in the WHERE condition may contain NULL values.
Internal message code: MESSAGE GYT
Cannot be suppressed using a pragma or pseudo-comment

这篇关于要隐藏警告的语法:where条件中使用的字段可能包含空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆