这怎么可能?:如果我用文字“MT202”替换message_format_name,查询将按预期工作。否则,它返回2行而不是预期的1 - 就像该条件被注释掉一样。
由于某些奇怪的原因,传入存储过程中的参数值似乎不等于ms.message_format_name中的值。
如果您需要更多详细信息,请与我们联系。 谢谢!
set define off;
create or replace PROCEDURE insert_mapping(
interface_name IN VARCHAR2,
message_format_name IN VARCHAR2,
determined_field_type IN VARCHAR2,
source_field IN VARCHAR2,
mapping_key IN VARCHAR2,
mapping_key_value1 IN VARCHAR2,
mapping_key_value2 IN VARCHAR2 DEFAULT NULL,
return_val OUT sys_refcursor)
AS
BEGIN
dbms_output.put_line('interface_name = ' || interface_name);
dbms_output.put_line('message_format_name = ' || message_format_name);
dbms_output.put_line('determined_field_type = ' || determined_field_type);
dbms_output.put_line('source_field = ' || source_field);
/* INSERT
INTO payments.multi_value_lookup_mapping
(
pk_multi_value_lkp_mapping,
fk_pk_multi_value_lookup_confg,
mapping_key,
mapping_key_value1,
mapping_key_value2,
created_by,
created_dt,
update_by,
update_dt
)*/
OPEN return_val FOR
SELECT payments.seq_multi_value_lookup_map.nextval,
mvlc.pk_multi_value_lookup_config,
mapping_key,
mapping_key_value1,
mapping_key_value2,
50000,
SYSDATE,
50000,
SYSDATE
FROM payments.multi_value_lookup_config mvlc, payments.message_source ms
WHERE (ms.pk_message_source = mvlc.fk_pk_message_source
AND ms.interface_name = interface_name
AND ms.message_format_name = message_format_name /*'MT202'*/
AND mvlc.mapping_column_name = source_field
AND mvlc.lookup_category_type = determined_field_type
);
END insert_mapping;
答案 0 :(得分:4)
这不是Oracle错误。首先,您应该从不在FROM
子句中使用逗号。您总是使用明确的JOIN
语法。
但这不是你的具体问题。可变分辨率和范围是。
如果在查询中有interface_name
之类的引用,那么Oracle会首先查找具有该名称的列。它永远不会看到变量。将变量命名为区别对象,因此最终得到的代码更像是:
. . .
FROM payments.multi_value_lookup_config mvlc JOIN
payments.message_source ms
ON ms.pk_message_source = mvlc.fk_pk_message_source
WHERE ms.interface_name = v_interface_name
ms.message_format_name = v_message_format_name /*'MT202'*/
mvlc.mapping_column_name = v_source_field
mvlc.lookup_category_type = v_determined_field_type