gpt4 book ai didi

mysql - Scriptella 中的特殊字符,jexl

转载 作者:行者123 更新时间:2023-11-29 03:41:30 24 4
gpt4 key购买 nike

我想从数据库中提取一个文本字段并将其插入到其他数据库中。因此,在提取时,我在选择测试时使用了 REPLACE(message_text,'\'', '"')。我给了我一个错误。我从我的 select 语句中更改了它,并在启动全局变量时执行了它。etl.globals['message_text'] = message_text;

我仍然在插入语句中遇到错误

insert into lcs_al_user_likes(user_id,liked_user_id,post_content,loop_id) values('${etl.globals['posted_by']}','${etl.globals['liked_user_id']}','${etl.gl‌​obals['message_text']}',?batchLoopCounter); 

*您的 SQL 语法有错误,请检查与您的 MySQL 服务器版本对应的手册,了解在第 1 行的 'message_text']}')' 附近使用的正确语法*

我认为它没有获取全局变量。我这么说是因为当我使用 log 打印它的值时,它只是给了我

${etl.globals['message_text']}

作为输出。所以请帮帮我。

<query connection-id="lcsDBConnection"> 
SELECT forum_topic_post_id AS forum_topic_post_id, posted_by AS posted_by,message_text as message_text FROM lcs_tbl_forum_topic_post WHERE like_count>0 LIMIT ?batchSize OFFSET ?queryCounter ;
<script connection-id="jexl">
etl.globals['forum_topic_post_id'] = forum_topic_post_id;
etl.globals['posted_by'] = posted_by;
etl.globals['message_text'] = message_text.replace('\'', '"');
</script>

最佳答案

看起来问题出在 INSERT 语句中,你应该使用 prepared 语句参数转义:

INSERT INTO lcs_al_user_likes(user_id,liked_user_id,post_content,loop_id) values(?{etl.globals['posted_by']},?{etl.globals['liked_user_id']},?{etl.gl‌​obals['message_text']},?batchLoopCounter); 

顺便说一句,据我了解,您最初的问题是引号破坏了插入语句,因此在这种情况下,如果使用 ?{parameter} 语法,您根本不需要使用 replace(...) 函数。

关于mysql - Scriptella 中的特殊字符,jexl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13346521/

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