Postgre cannot insert multiple commands into a prepared statement

悲剧...

FireDAC连接Postgre数据库, 使用默认的属性, 一次执行多条SQL的时候, 会报"cannot insert multiple commands into a prepared statement"这样的错误

到网上查了一下(百度), 什么信息都找不到, 然后又google, 找到很多国外的信息 (此句纯粹为了鄙视百度...各位看官可以忽略)

搜啊搜, 大概的意思是, Postgre有2种模式 一种是只能执行一句SQL, 另外一种是支持多SQL批量执行的, 查找过程就忽略的, 总之是各种猜测

最后发现Postgre对于执行模式的接口有2个: PQexec和PQexecParams 这个可以在Postgre的帮助文档31.3.1 中找到相关资料

其中PQexec就是支持多个SQL同时执行的, 而PQexecParams则是只支持一句SQL, 他们的区别在于是否支持SQL变量参数值

而firedac默认是使用PQexecParams接口来执行的, 所以就会报那个错误, 如果想以PQexec方式执行, 方法如下:

1.FDConnection.ExecSQL

2.设置FDQuery.ResourceOptions.DirectExecute := True;

问题解决

时间: 2024-10-17 18:36:10

Postgre cannot insert multiple commands into a prepared statement的相关文章

YII insert multiple records into a table

$values = array(array(1,2),array(3,4),array(5,6),); $nbValues = count($values); $sql = 'INSERT INTO table_name (col_name1, col_name2) VALUES '; for ($i=0; $i < $nbValues; $i++) { $sql .= '(:col1_'.$i.', :col2_'.$i.')'; if ($i !== ($nbValues-1)) $sql

Xcode10升级问题:Multiple commands produce Info.plist

升级到Xcode10以后,编译过程遇到的第一个问题就是类似于这样的: Multiple commands produce '/Users/jiaxiaoyan/Library/Developer/Xcode/DerivedData/LJShell-emaksjqtieseunfuiotagpjkluwp/Build/Products/Debug-iphonesimulator/Lianjia_Beike_SecondHand_Private/Lianjia_HomeLink_House_Priv

iOS_bug_ Showing Recent Messages :-1: Multiple commands produce &#39;/Users……

今天看到一个好的demo,然后运行了一下,出现了一个问题: 然后在stakeoverflow上面找到一个答案 大致是Xcode10以后出现的问题,需要修改一下项目的名字才能解决 iOS_bug_ Showing Recent Messages :-1: Multiple commands produce '/Users-- 原文地址:https://www.cnblogs.com/yinjiangtao/p/9925730.html

A prepared statement is generated from a nonconsta

Findbugs报错: A prepared statement is generated from a nonconstant String The code creates an SQL prepared statement from a nonconstant String. If unchecked, tainted data from a user is used in building this String, SQL injection could be used to make

Postgresql:prepared statement &quot;S_1&quot; already exists

近期由于业务需要和一些json的存储查询需要,把新的应用切到pgsql上来,刚刚切好,是可以正常使用的,但是偶尔会来一下 java连接pgsql 偶尔出现 这个错. org.postgresql.util.PSQLException: ERROR: prepared statement "S_1" already exists 检查sql语句,几乎没问题,又看设置,实在找不到哪里有问题 百度网上的资料太少了,干脆我写一篇,方便以后遇到此问题的朋友 解决问题,不用翻来覆去找了 经过仔细查

postgre数据库插入错误:prepared statement &ldquo;S_1&rdquo;already exist, 解决办法

在使用kettle工具(数据迁移软件)在postgre数据库中插入记录时,出现如下错误,解决办法: 在/etc/pgsql/pgbouncer.ini中修改配置,设置 server_reset_query = DISCARD ALL

Vim tips——Working with external commands

A common sequence of events when editing files is to make a change and then need to test by executing the file you edited in a shell. If you're using vim, you could suspend your session (ctrl-Z), and then run the command in your shell. That's a lot o

INSERT ... ON DUPLICATE KEY UPDATE Syntax

If you specify ON DUPLICATE KEY UPDATE, and a row is inserted that would cause a duplicate value in a UNIQUE index or PRIMARY KEY, MySQL performs an UPDATE of the old row. For example, if column a is declared as UNIQUE and contains the value 1, the f

Patterns for Asynchronous MVVM Applications: Commands

Stephen Cleary Download the Code Sample This is the second article in a series on combining async and await with the established Model-View-ViewModel (MVVM) pattern. Last time, I showed how to data bind to an asynchronous operation, and I developed a