所以如果我有一个包含的存储过程选择如何抑制这些选择的结果出现?
例如,如果我有
create procedure xyz
begin
select * from table_name #I don't want this to be seen in the console.
do other stuff
end;
Run Code Online (Sandbox Code Playgroud) 我在触发器中使用动态 sql 执行 sql,因为触发器将跨多个表运行。sql将从表中选择并检查是否有结果,如果没有结果插入表中则不执行任何操作。它与第一个 psql select 一起工作,但找到的变量是 true,即使它是空的
create function test() returns trigger $Body$
execute 'select * from ' || quote_ident(TG_TABLE_NAME) || '_table1 where condition';
if not found then
insert into x values(anything);
end if;
execute 'select * from ' || quote_indent(TG_TABLE_NAME) || '_table2 where condition';
if not found then
insert into y values (values);
end if;
......
Run Code Online (Sandbox Code Playgroud)
第二个条件我确信它不会产生任何结果,但发现仍然是正确的任何解决方案可以使其工作?
有没有办法让 PSQL 中的函数调用返回 JSON 的 Web 服务并使用此 JSON 在触发器调用中在数据库中执行某些操作?