postgresql - 我需要在 postgresql 中使用表名作为变量
问题描述
我创建了一个函数,我需要为不同的表多次调用,但是当尝试使用表名作为函数中的输入变量时,它给了我一个错误。我读到如果使用“执行”语句是可能的,但是我不知道如何应用它
我的代码是:
CREATE OR REPLACE FUNCTION cta_tiempos7 (nomLD text, nomRe text, subst text, out FIM) AS $$
declare
resta_ok int;
cie_res int;
t_abi timestamp;
t_cie timestamp;
t_fuera interval;
t_switc interval;
tiempos Record;
cur_evento Cursor for select nombre, señal as signal, estampa from subst
where nombre in (nomLD, nomRe) and señal in ('Indicacion 52 Cerrado', 'Indicacion 52 abierto');
begin
.
.
.
.
.
end;
$$ language 'plpgsql';
解决方案
推荐阅读
- activemq-artemis - 使用过滤器时未路由的消息会发生什么情况?
- leaflet - 多边形消失
- ruby-on-rails - 如何在rails中的另一个表单中提交表单
- php - PHP Symfony createFormBuilder ::add 类型必须为字符串或 null,给定数组
- r - 如何将许多 .csv 文件合并到 R 中,不包括前三行?
- intellij-idea - IntelliJ Idea:缺少TestNG运行配置
- python - 有没有办法在 tkinter GUI 中动态获取条件输入,而不是从控制台获取它们?
- sql - 如果查询在 sql server 中没有返回任何内容,则插入 NULL
- jenkins - 在 Jenkinsfile 中访问 Jenkins 管道定义
- c++ - 有没有办法过滤掉 Arrow::Array 和一些谓词?