gpt4 book ai didi

mysql - mysql函数中的ibatis和定界符

转载 作者:行者123 更新时间:2023-11-29 03:06:20 26 4
gpt4 key购买 nike

我尝试使用 Big DBA Head 中的以下示例在 ibatis 迁移脚本中。

delimiter //
drop function if exists true_function //
create function true_function(p_param int) returns int
deterministic
sql security invoker
return true
//

drop function if exists get_next_value//
create function get_next_value(p_name varchar(30)) returns int
deterministic
sql security invoker
begin
declare current_val integer;

update mysql.sequences
set value = value + 1
where name = p_name
and true_function((@current_val := mysql.sequences.value) is not null);

return @current_val;
end//
delimiter ;

但是 ibatis 抛出这个错误:

...Error executing: delimiter // drop function if exists get_next_value_test // create function get_next_value_test(p_name varchar(30)) returns int deterministic sql security invoker begin
declare current_val integer . Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'delimiter //...

我已经尝试设置 allowMultiQueries 和 send_full_script 但没有成功。你有什么想法让这个脚本执行吗?

谢谢,

最佳答案

我遇到了同样的问题...

以下站点似乎提供了此问题的答案。

https://github.com/mybatis/migrations/issues/49

当然,它使用 MyBatis 而不是 iBatis,但考虑到 iBatis 已经“退休”,这可能是一个很好的举措。

替换的基本答案

delimiter //

-- @DELIMITER //

然后替换

delimiter ;

-- @DELIMITER ;

关于mysql - mysql函数中的ibatis和定界符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14607288/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com