作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
假设您有一个接受单个参数的现有存储过程,该参数恰好是 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.
最佳答案
这些 EXECUTE PROCEDURE
调用确实成功了:
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;
关于stored-procedures - 如何将 boolean 数据类型作为参数传递给存储过程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51389277/
我是一名优秀的程序员,十分优秀!