本文介绍了PL / SQL问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 大家好, 我试着看看我是否可以使用触发器设置进行递归功能 INSERT并在我的触发器下进行插入函数。 所以我写了一个测试函数: 创建或替换函数testfunc()返回设置记录'' DECLARE use_t RECORD; BEGIN SELECT INTO use_t id_categorie FROM categories ORDER BY id_categorie DESC; 如果use_t.id_categorie<> 50那么 INSERT INTO categories(nom)VALUES(''''test''''); END IF; RETURN NULL; END; ''LANGUAGE plpgsql; 问题是我不能执行此功能来测试它,psql返回 以下错误: " ;错误:在上下文中调用的集值函数不能接受集合 但如果我直接写它,我的INSERT INTO就可以工作。 有人有个主意吗? 提前Thx, 问候, ----- ----------------------(播出结束)----------------------- ---- 提示4:不要杀死-9''邮政局长 解决方案 记录集返回函数不能称为: select foo(); 但是取而代之的是 select * from foo()AS foo(< columns>); 但是,因为你实际上并没有显然返回一组您可能只想更改返回类型的功能中的任何内容 。 --------------- ------------(广播结束)--------------------------- 提示4:不要杀死-9''邮政局长 记录集返回函数不称为:选择foo(); 而是选择*来自foo()AS foo(< columns>); 但是,因为你实际上并没有在函数中返回任何东西,你可能只想更改返回类型。 - -------------------------(播出结束)-------------------- ------- 提示7:别忘了增加免费空间地图设置 Hello everyone, I try to see if i can make a recursive function with a trigger set onINSERT and doing an insert under my trigger function. So i wrote a test function :CREATE OR REPLACE FUNCTION testfunc() RETURNS SETOF RECORD AS ''DECLAREuse_t RECORD;BEGIN SELECT INTO use_t id_categorie FROM categorie ORDER BY id_categorieDESC;IF use_t.id_categorie<>50 THENINSERT INTO categorie (nom) VALUES (''''test'''');END IF; RETURN NULL; END;''LANGUAGE plpgsql;The problem is that i can''t exec this function to test it, psql returnthe following error : "ERROR: set-valued function called in context that cannot accept a set" But my INSERT INTO works if i write it directly. Someone get an idea ? Thx in advance,regards, ---------------------------(end of broadcast)---------------------------TIP 4: Don''t ''kill -9'' the postmaster 解决方案 Record set returning functions aren''t called as:select foo();but instead asselect * from foo() AS foo(<columns>); However, since you''re not apparently actually returning a set of anythingin the function you may just want to change the return type. ---------------------------(end of broadcast)---------------------------TIP 4: Don''t ''kill -9'' the postmaster Record set returning functions aren''t called as:select foo();but instead asselect * from foo() AS foo(<columns>); However, since you''re not apparently actually returning a set of anythingin the function you may just want to change the return type. ---------------------------(end of broadcast)---------------------------TIP 4: Don''t ''kill -9'' the postmaster Record set returning functions aren''t called as: select foo(); but instead as select * from foo() AS foo(<columns>); However, since you''re not apparently actually returning a set of anything in the function you may just want to change the return type. ---------------------------(end of broadcast)---------------------------TIP 7: don''t forget to increase your free space map settings 这篇关于PL / SQL问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-28 03:41