我正在使用PostgreSQL,并且我使用dblink特性来更新远程数据库上的数据。我的项目使用iBATIS来处理数据库。
我需要运行带参数的查询语句,但问题是db_link需要用引号括起来。而iBATIS不理解它..
我有iBATIS sql:
SELECT
dblink_exec(
'host=192.168.20.60 port=5432 user=clk dbname=clkdb_wms password=clk',
'UPDATE m_user_profile
first_name = #4#,
last_name = #5# ,
mobile_no = #6#
WHERE user_id = CAST(#3# AS numeric)'
);但是由于sql是用引号括起来的,iBATIS找不到要替换的参数。
我有什么解决方案吗?
发布于 2017-02-28 16:40:48
格式化会有帮助吗?Smth喜欢:
SELECT
dblink_exec(
'host=192.168.20.60 port=5432 user=clk dbname=clkdb_wms password=clk',
format('UPDATE m_user_profile
first_name = %L,
last_name = %L ,
mobile_no = %s
WHERE user_id = CAST(%s AS numeric)',#4#,#5#,#6#,#3#)
);https://stackoverflow.com/questions/42503143
复制相似问题