I'm developing this app where I have to call a function written in PL/SQL that returns a boolean. As I understand, bool is not a type in SQL, but in PL/SQL, so what will the return type for the function be?
我正在开发这个应用程序,我必须调用一个用PL / SQL编写的函数来返回一个布尔值。据我所知,bool不是SQL中的类型,但在PL / SQL中,函数的返回类型是什么?
command.Parameters.Add("P_RETURN", OracleType.???);
(For the record: I have no control over the PL/SQL end of things, so I am not able to rewrite the function)
(对于记录:我无法控制PL / SQL的结尾,所以我无法重写该功能)
2 个解决方案
#1
You could call the SYS.diutil.bool_to_int
function with the result of calling your function. For example:
您可以使用调用函数的结果调用SYS.diutil.bool_to_int函数。例如:
SYS.diutil.bool_to_int(your_function(...))
From the documentation:
从文档:
bool_to_int
: translates 3-valued BOOLEAN TO NUMBER FOR USE IN sending BOOLEAN parameter / RETURN VALUES BETWEEN pls v1 (client) AND pls v2. since sqlnet has no BOOLEAN bind variable TYPE, we encode booleans AS false = 0, true = 1, NULL = NULL FOR network transfer AS NUMBERbool_to_int:将3值BOOLEAN转换为NUMBER FOR USE IN发送BOOLEAN参数/返回值在pls v1(客户端)和pls v2之间。由于sqlnet没有BOOLEAN绑定变量TYPE,我们编码布尔值AS false = 0,true = 1,NULL = NULL用于网络传输AS NUMBER
#2
You have to convert the PL/SQL only BOOLEAN type to a SQL supported type. I know, this is painful : welcome to the Oracle world. Here is Steven Feuerstein reusable way to deal with it.
您必须将PL / SQL only BOOLEAN类型转换为SQL支持的类型。我知道,这很痛苦:欢迎来到Oracle世界。以下是Steven Feuerstein可重复使用的方法。
As a side note, BOOLEANs are considered useless in SQL (by Oracle anyway).
作为旁注,BOOLEAN在SQL中被认为是无用的(无论如何都是Oracle)。
#1
You could call the SYS.diutil.bool_to_int
function with the result of calling your function. For example:
您可以使用调用函数的结果调用SYS.diutil.bool_to_int函数。例如:
SYS.diutil.bool_to_int(your_function(...))
From the documentation:
从文档:
bool_to_int
: translates 3-valued BOOLEAN TO NUMBER FOR USE IN sending BOOLEAN parameter / RETURN VALUES BETWEEN pls v1 (client) AND pls v2. since sqlnet has no BOOLEAN bind variable TYPE, we encode booleans AS false = 0, true = 1, NULL = NULL FOR network transfer AS NUMBERbool_to_int:将3值BOOLEAN转换为NUMBER FOR USE IN发送BOOLEAN参数/返回值在pls v1(客户端)和pls v2之间。由于sqlnet没有BOOLEAN绑定变量TYPE,我们编码布尔值AS false = 0,true = 1,NULL = NULL用于网络传输AS NUMBER
#2
You have to convert the PL/SQL only BOOLEAN type to a SQL supported type. I know, this is painful : welcome to the Oracle world. Here is Steven Feuerstein reusable way to deal with it.
您必须将PL / SQL only BOOLEAN类型转换为SQL支持的类型。我知道,这很痛苦:欢迎来到Oracle世界。以下是Steven Feuerstein可重复使用的方法。
As a side note, BOOLEANs are considered useless in SQL (by Oracle anyway).
作为旁注,BOOLEAN在SQL中被认为是无用的(无论如何都是Oracle)。