在 PostgreSQL 中执行一个字符串 Sql
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17855659/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 01:02:10 来源:igfitidea点击:
Execute a String Sql in PostgreSQL
提问by D T
In a function, I have a SELECT
query in a string, for example:
在一个函数中,我有SELECT
一个字符串查询,例如:
sql='SELECT * FROM A'
I want to execute sql
output result of: SELECT * FROM A
我想执行以下sql
输出结果:SELECT * FROM A
How can I execute the string sql
in PostgreSQL?
如何sql
在 PostgreSQL 中执行字符串?
采纳答案by user2478690
回答by Vinit Prajapati
below one works fine in postgres 8.4
下面一个在 postgres 8.4 中工作正常
UDBI=> PREPARE query as select 1 as a;
PREPARE
UDBI=> PREPARE query
UDBI=> EXECUTE query;
a
---
1
(1 row)
UDBI=>