如何将布尔数据类型作为存储过程的参数传递?

How do you pass a boolean data type as a parameter for a stored procedure?

假设您有一个接受单个参数的现有存储过程,该参数恰好是 the BOOLEAN Informix data type:

test_bool_param(BOOLEAN)

对于这样的存储过程,EXECUTE PROCEDURE 语句会是什么样子?

这是我尝试过但失败了的方法:

EXECUTE PROCEDURE test_bool_param('true'); -- [Error Code: -1260, SQL State: IX000]  It is not possible to convert between the specified types.
EXECUTE PROCEDURE test_bool_param('false');-- [Error Code: -1260, SQL State: IX000]  It is not possible to convert between the specified types.
EXECUTE PROCEDURE test_bool_param('TRUE'); -- [Error Code: -1260, SQL State: IX000]  It is not possible to convert between the specified types.
EXECUTE PROCEDURE test_bool_param('FALSE');-- [Error Code: -1260, SQL State: IX000]  It is not possible to convert between the specified types.
EXECUTE PROCEDURE test_bool_param(true);   -- [Error Code:  -201, SQL State: 42000]  A syntax error has occurred.
EXECUTE PROCEDURE test_bool_param(false);  -- [Error Code:  -201, SQL State: 42000]  A syntax error has occurred.
EXECUTE PROCEDURE test_bool_param(TRUE);   -- [Error Code:  -201, SQL State: 42000]  A syntax error has occurred.
EXECUTE PROCEDURE test_bool_param(FALSE);  -- [Error Code:  -201, SQL State: 42000]  A syntax error has occurred.
EXECUTE PROCEDURE test_bool_param(1);      -- [Error Code:  -674, SQL State: IX000]  Routine (test_bool_param) can not be resolved.
EXECUTE PROCEDURE test_bool_param(0);      -- [Error Code:  -674, SQL State: IX000]  Routine (test_bool_param) can not be resolved.
EXECUTE PROCEDURE test_bool_param('');   -- [Error Code: -1260, SQL State: IX000]  It is not possible to convert between the specified types.
EXECUTE PROCEDURE test_bool_param('[=11=]');   -- [Error Code: -1260, SQL State: IX000]  It is not possible to convert between the specified types.
EXECUTE PROCEDURE test_bool_param('t');    -- [Error Code: -1260, SQL State: IX000]  It is not possible to convert between the specified types.
EXECUTE PROCEDURE test_bool_param('f');    -- [Error Code: -1260, SQL State: IX000]  It is not possible to convert between the specified types.
EXECUTE PROCEDURE test_bool_param('T');    -- [Error Code: -1260, SQL State: IX000]  It is not possible to convert between the specified types.
EXECUTE PROCEDURE test_bool_param('F');    -- [Error Code: -1260, SQL State: IX000]  It is not possible to convert between the specified types.
EXECUTE PROCEDURE test_bool_param(t);      -- [Error Code:  -201, SQL State: 42000]  A syntax error has occurred.
EXECUTE PROCEDURE test_bool_param(f);      -- [Error Code:  -201, SQL State: 42000]  A syntax error has occurred.
EXECUTE PROCEDURE test_bool_param(T);      -- [Error Code:  -201, SQL State: 42000]  A syntax error has occurred.
EXECUTE PROCEDURE test_bool_param(F);      -- [Error Code:  -201, SQL State: 42000]  A syntax error has occurred.
EXECUTE PROCEDURE test_bool_param();     -- [Error Code:  -202, SQL State: IX000]  An illegal character has been found in the statement.
EXECUTE PROCEDURE test_bool_param([=11=]);     -- [Error Code:  -202, SQL State: IX000]  An illegal character has been found in the statement.

这些 EXECUTE PROCEDURE 调用 do 实际上成功了:

EXECUTE PROCEDURE test_bool_param('t');     -- Result set fetched - SUCCESS
EXECUTE PROCEDURE test_bool_param('f');     -- Result set fetched - FAILURE
EXECUTE PROCEDURE test_bool_param('T');     -- Result set fetched - SUCCESS
EXECUTE PROCEDURE test_bool_param('F');     -- Result set fetched - FAILURE

但仅当存储过程中的任何检查也与 't''f''T''F' 之一进行比较时:

CREATE PROCEDURE test_bool_param
(in_param BOOLEAN)
RETURNING VARCHAR(8)
IF (in_param = 't') THEN
        RETURN 'SUCCESS';
ELSE
        RETURN 'FAILURE';
END IF;
END PROCEDURE;