gpt4 book ai didi

postgresql - 在 postgreSQL 中执行查询字符串

转载 作者:行者123 更新时间:2023-11-29 12:56:55 25 4
gpt4 key购买 nike

我在变量中有一个查询字符串

假设Select Now();我想像 SQL 一样执行它。我用

Execute 'Select Now()';

但是它抛出一个异常

prepared statement "SELECT now()" does not exist

并且不允许我执行它。

有什么办法吗?

最佳答案

你把 plpgsql EXECUTE 搞砸了:

t=# do $$ begin execute 'select now()'; end; $$;
DO

和 SQLEXECUTE

t=# prepare example as select now();
PREPARE
t=# execute example;
now
-------------------------------
2016-12-01 10:30:15.782433+00
(1 row)

关于postgresql - 在 postgreSQL 中执行查询字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40908096/

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