假设您有一个接受单个参数的存储过程,该参数恰好是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('\1'); -- [Error Code: -1260, SQL State: IX000] It is not possible to convert between the specified types.
EXECUTE PROCEDURE test_bool_param('\0'); -- [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(\1); -- [Error Code: -202, SQL State: IX000] An illegal character has been found in the statement.
EXECUTE PROCEDURE test_bool_param(\0); -- [Error Code: -202, SQL State: IX000] An illegal character has been found in the statement.
答案 0 :(得分:1)
这些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;