相当于 sap 中的 oracle 类型布尔值

Equivalent of oracle type boolean in sap

我在从 ABAP 调用存储过程时遇到问题。 我使用标准 ABAP class cl_sql_statement 及其方法 execute_procedure 和 set_param。例如,被调用过程只有一个布尔输入参数。

CREATE OR REPLACE PROCEDURE print_boolean (
  p_in_flag   BOOLEAN
) IS

A​​BAP 代码段

DATA: ld_e_bool type char5,
      ld_o_stat type ref to cl_sql_statement,
      ld_r_data type ref to data.
***************************
ld_e_bool = 'FALSE'.
get references of ld_e_bool into ld_r_data. 
ld_o_stat->set_param(DATA_REF = ld_r_data).
ld_o_stat->execute_procedure( 'print_boolean' ).
********************************************

调用后,我发现了一个异常,内容类似于:'wrong number or types of arguments'。也许我需要除 char5 之外的另一种类型...任何帮助将不胜感激。

一些观察: JDBC 驱动程序不支持将 BOOLEAN 参数传递给 PL/SQL 存储过程(建议用第二个 PL/SQL 过程包装 PL/SQL 过程)。但我不想使用上述选项,因为已经有很多 packages/SP 可用。

讨论布尔类型在 Oracle 数据库字段中的使用的 Oracle documentation is unclear on how PL/SQL boolean values are actually represented. There is also a question(此处不相关,但提供了一些背景知识)。

来自 PL/SQL 文档:

The BOOLEAN datatype takes no parameters. Only the values TRUE, FALSE, and NULL can be assigned to a BOOLEAN variable.

You cannot insert the values TRUE and FALSE into a database column. You cannot select or fetch column values into a BOOLEAN variable. Functions called from a SQL query cannot take any BOOLEAN parameters. Neither can built-in SQL functions such as TO_CHAR; to represent BOOLEAN values in output, you must use IF-THEN or CASE constructs to translate BOOLEAN values into some other type, such as 0 or 1, 'Y' or 'N', 'true' or 'false', and so on.

鉴于此,我知道您不想这样做,您可能需要更改传递给存储过程的参数类型(例如,使用单个字符或整数),然后使用逻辑来将其视为布尔值。

在 SAP 文档中说:

Almost all SQL statements that are valid for the addressed database system can be included between EXEC and ENDEXEC

也许如果我尝试在本节中放入本机 pl/sql 代码,我会得到结果...

编辑:我把这段代码剪下来没问题。

EXEC SQL.
   BEGIN
     print_boolean(TRUE); 
   END;
ENDEXEC.

但是有一个问题。此 sql 语句只有静态形式。