【发布时间】:2017-10-18 12:50:00
【问题描述】:
https://www.postgresql.org/docs/current/static/libpq-exec.html
在PQprepare旁边:
该函数从 查询字符串,它必须包含单个 SQL 命令。 stmtName 可以 "" 创建一个未命名的语句,在这种情况下,任何预先存在的 未命名的语句被自动替换;否则是一个错误 如果当前会话中已经定义了语句名称。
还有:
与PQexecPrepared一起使用的准备好的语句也可以由 执行 SQL
PREPARE语句。
现在https://www.postgresql.org/docs/current/static/sql-prepare.html
PREPARE name [ ( data_type [, ...] ) ] AS 语句
和:
name 给这个特定的准备好的语句的任意名称。它 在单个会话中必须是唯一的,并且随后用于 执行或解除分配先前准备好的语句。
问题:
我不能使用 SQL 语句PREPARE 创建未命名的预准备语句吗?静默可重复使用,其余的一切......
t=# prepare ""(int) as select $1,now();
ERROR: zero-length delimited identifier at or near """"
LINE 1: prepare ""(int) as select $1,now();
并省略名称:
ERROR: syntax error at or near "as"
或者我遗漏了一些非常明显的东西?..
【问题讨论】:
标签: postgresql prepared-statement