PL / SQL问题 [英] PL/SQL question

查看:80
本文介绍了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''邮政局长

解决方案

2004年4月20日星期二,Froggy / Froggy Corp.写道:

我试着看看是否可以使用触发器设置进行递归功能
INSERT在我的触发器功能下进行插入。

所以我写了一个测试函数:

创建或替换函数testfunc()返回设置记录''
DECLARE
use_t RECORD;
BEGIN

SELECT INTO use_t id_categorie FROM categories ORDER BY id_categorie
DESC;
IF use_t.id_categorie<> 50 THEN
INSERT INTO categories(nom)VALUES(''''test'''');
END IF;

返回NULL;

END;
''LANGUAGE plpgsql;

问题是我不能执行此函数来测试它,psql返回
以下错误:错误:在上下文中调用的set-valued函数无法接受set ;




记录集返回函数不能称为:

select foo();

但是取而代之的是

select * from foo()AS foo(< columns>);


但是,因为你实际上并没有显然返回一组您可能只想更改返回类型的功能中的任何内容




--------------- ------------(广播结束)---------------------------

提示4:不要杀死-9''邮政局长


2004年4月20日星期二,Froggy / Froggy Corp.写道:

我试着看看我是否可以在INSERT上设置触发器并在触发器功能下执行插入来创建递归函数。
所以我写道测试功能:

创建或替换功能testfunc()返回设置记录''
声明
use_t RECORD;
BEGIN

SELECT INTO use_t id_categorie FROM categories ORDER BY id_categorie
DESC;
如果use_t.id_categorie<> 50那么
INSERT INTO类别(nom)值(''''test'''') ;
END IF;

返回NULL;

END;
''LANGUAGE plpgsql;

问题在于我不能执行此函数来测试它,psql返回
以下错误:

错误:在上下文中调用的set-valued函数无法接受集合



记录集返回函数不被称为:

选择foo();

但是作为

select * from foo()AS foo(< columns>);


但是,因为你显然没有真正返回任何东西

在你可能只想改变的函数中返回类型。


---------------------------(广播结束) - --------------------------

提示4:不要杀掉-9的邮政局长


您好,


实际上问题似乎来自INSERT INTO。我从函数中删除了

所有东西,只保留了INSERT INTO并获得

相同的问题。


提前获得答案,

问候,


Stephan Szabo写道:


2004年4月20日星期二,Froggy / Froggy Corp.写道:

我试着看如果我可以在INSERT上设置触发器并在我的触发器功能下执行插入来创建递归函数。

所以我写了一个测试函数:

CREATE或者替换功能testfunc()返回设置记录''
声明
use_t记录;
开始

SELECT INTO use_t id_categorie FROM categories ORDER BY id_categorie
DESC;
如果use_t.id_categorie<> 50那么
插入类别(nom)值(''''test'''');
END IF;

RETURN NULL;

END;
''LANGUAGE plpgsql;

问题是我不能执行此函数来测试它,psql RET urn
以下错误:

"错误:在上下文中调用的set-valued函数,不能接受集合"



记录集返回函数不称为:
选择foo();
而是选择*来自foo()AS foo(< columns>);

但是,因为你实际上并没有在函数中返回任何东西
,你可能只想更改返回类型。




- -------------------------(播出结束)-------------------- -------

提示7:别忘了增加免费空间地图设置


Hello everyone,

I try to see if i can make a recursive function with a trigger set on
INSERT and doing an insert under my trigger function.

So i wrote a test function :
CREATE OR REPLACE FUNCTION testfunc() RETURNS SETOF RECORD AS ''
DECLARE
use_t RECORD;
BEGIN

SELECT INTO use_t id_categorie FROM categorie ORDER BY id_categorie
DESC;
IF use_t.id_categorie<>50 THEN
INSERT 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 return
the 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

解决方案

On Tue, 20 Apr 2004, Froggy / Froggy Corp. wrote:

I try to see if i can make a recursive function with a trigger set on
INSERT and doing an insert under my trigger function.

So i wrote a test function :
CREATE OR REPLACE FUNCTION testfunc() RETURNS SETOF RECORD AS ''
DECLARE
use_t RECORD;
BEGIN

SELECT INTO use_t id_categorie FROM categorie ORDER BY id_categorie
DESC;
IF use_t.id_categorie<>50 THEN
INSERT 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 return
the following error :

"ERROR: set-valued function called in context that cannot accept a set"



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 4: Don''t ''kill -9'' the postmaster


On Tue, 20 Apr 2004, Froggy / Froggy Corp. wrote:

I try to see if i can make a recursive function with a trigger set on
INSERT and doing an insert under my trigger function.

So i wrote a test function :
CREATE OR REPLACE FUNCTION testfunc() RETURNS SETOF RECORD AS ''
DECLARE
use_t RECORD;
BEGIN

SELECT INTO use_t id_categorie FROM categorie ORDER BY id_categorie
DESC;
IF use_t.id_categorie<>50 THEN
INSERT 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 return
the following error :

"ERROR: set-valued function called in context that cannot accept a set"



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 4: Don''t ''kill -9'' the postmaster


Hello,

In fact the problem seems to come from the "INSERT INTO". I delete
everything from the function and only keep the "INSERT INTO" and get the
same problem.

Thx in advance for answers,
regards,

Stephan Szabo wrote:


On Tue, 20 Apr 2004, Froggy / Froggy Corp. wrote:

I try to see if i can make a recursive function with a trigger set on
INSERT and doing an insert under my trigger function.

So i wrote a test function :
CREATE OR REPLACE FUNCTION testfunc() RETURNS SETOF RECORD AS ''
DECLARE
use_t RECORD;
BEGIN

SELECT INTO use_t id_categorie FROM categorie ORDER BY id_categorie
DESC;
IF use_t.id_categorie<>50 THEN
INSERT 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 return
the following error :

"ERROR: set-valued function called in context that cannot accept a set"



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问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆