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 16 1621
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
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
On Wed, 21 Apr 2004, Froggy / Froggy Corp. wrote: 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.
A function like:
create function fz1() returns void as '
begin
INSERT INTO categorie (nom) VALUES (''test'');
RETURN;
end;' language 'plpgsql';
seems to work for me, what are you trying precisely?
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives? http://archives.postgresql.org
On Wed, 21 Apr 2004, Froggy / Froggy Corp. wrote: 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.
A function like:
create function fz1() returns void as '
begin
INSERT INTO categorie (nom) VALUES (''test'');
RETURN;
end;' language 'plpgsql';
seems to work for me, what are you trying precisely?
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives? http://archives.postgresql.org
> 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.
Given that this is supposed to be a trigger function, what's
your 'create trigger' statement look like?
Part of the problem may be how your 'return null' is being handled,
and that can be related to when the trigger fires.
--
Mike Nolan
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
> 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.
Given that this is supposed to be a trigger function, what's
your 'create trigger' statement look like?
Part of the problem may be how your 'return null' is being handled,
and that can be related to when the trigger fires.
--
Mike Nolan
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
--- Mike Nolan <no***@gw.tssi.com> wrote: 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.
Given that this is supposed to be a trigger function, what's your 'create trigger' statement look like?
Part of the problem may be how your 'return null' is being handled,
AFAIK, returning null from a trigger function causes
the whole operation (insert, update or delete) to be
aborted, so the transaction is rolled back, including
the insert inside the function. You want to return
NEW instead.
and that can be related to when the trigger fires. -- Mike Nolan
---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend
__________________________________
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25¢ http://photos.yahoo.com/ph/print_splash
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)
--- Mike Nolan <no***@gw.tssi.com> wrote: 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.
Given that this is supposed to be a trigger function, what's your 'create trigger' statement look like?
Part of the problem may be how your 'return null' is being handled,
AFAIK, returning null from a trigger function causes
the whole operation (insert, update or delete) to be
aborted, so the transaction is rolled back, including
the insert inside the function. You want to return
NEW instead.
and that can be related to when the trigger fires. -- Mike Nolan
---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend
__________________________________
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25¢ http://photos.yahoo.com/ph/print_splash
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)
I allways get the same error :
ERROR: set-valued function called in context that cannot accept a set
It seems to not accept the "(''test'')". Maybe i made a mistake by
adding the plpgsql langage, but i follow the documentation about that.
If i try to change the insert by "INSERT INTO categorie (id_categorie)
VALUES (''test'');" i got an error msg that "test" is not an integer.
(id_categorie is the primary key of the table).
thx in advance,
regards,
Jeff Eckermann wrote: --- Mike Nolan <no***@gw.tssi.com> wrote: 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.
Given that this is supposed to be a trigger function, what's your 'create trigger' statement look like?
Part of the problem may be how your 'return null' is being handled,
AFAIK, returning null from a trigger function causes the whole operation (insert, update or delete) to be aborted, so the transaction is rolled back, including the insert inside the function. You want to return NEW instead.
and that can be related to when the trigger fires. -- Mike Nolan
---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend __________________________________ Do you Yahoo!? Yahoo! Photos: High-quality 4x6 digital prints for 25¢ http://photos.yahoo.com/ph/print_splash
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html
I allways get the same error :
ERROR: set-valued function called in context that cannot accept a set
It seems to not accept the "(''test'')". Maybe i made a mistake by
adding the plpgsql langage, but i follow the documentation about that.
If i try to change the insert by "INSERT INTO categorie (id_categorie)
VALUES (''test'');" i got an error msg that "test" is not an integer.
(id_categorie is the primary key of the table).
thx in advance,
regards,
Jeff Eckermann wrote: --- Mike Nolan <no***@gw.tssi.com> wrote: 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.
Given that this is supposed to be a trigger function, what's your 'create trigger' statement look like?
Part of the problem may be how your 'return null' is being handled,
AFAIK, returning null from a trigger function causes the whole operation (insert, update or delete) to be aborted, so the transaction is rolled back, including the insert inside the function. You want to return NEW instead.
and that can be related to when the trigger fires. -- Mike Nolan
---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend __________________________________ Do you Yahoo!? Yahoo! Photos: High-quality 4x6 digital prints for 25¢ http://photos.yahoo.com/ph/print_splash
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html
> AFAIK, returning null from a trigger function causes the whole operation (insert, update or delete) to be aborted, so the transaction is rolled back, including the insert inside the function. You want to return NEW instead.
That's true on a 'before insert' trigger. An 'after insert' trigger
can return NULL because the insert that triggered it has already
taken place and the value returned by the trigger function is ignored.
That's why it was important to ask the original poster what kind of
trigger it was 'before insert' or 'after insert'.
--
Mike Nolan
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives? http://archives.postgresql.org
> AFAIK, returning null from a trigger function causes the whole operation (insert, update or delete) to be aborted, so the transaction is rolled back, including the insert inside the function. You want to return NEW instead.
That's true on a 'before insert' trigger. An 'after insert' trigger
can return NULL because the insert that triggered it has already
taken place and the value returned by the trigger function is ignored.
That's why it was important to ask the original poster what kind of
trigger it was 'before insert' or 'after insert'.
--
Mike Nolan
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives? http://archives.postgresql.org
The function should be called as "select * from function_name (xyz)"
rather than "select from function_name (xyz)", I would guess.
Rory
On 21/04/04, Froggy / Froggy Corp. (fr****@froggycorp.com) wrote: I allways get the same error :
ERROR: set-valued function called in context that cannot accept a set
--
Rory Campbell-Lange
<ro**@campbell-lange.net>
<www.campbell-lange.net>
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match
The function should be called as "select * from function_name (xyz)"
rather than "select from function_name (xyz)", I would guess.
Rory
On 21/04/04, Froggy / Froggy Corp. (fr****@froggycorp.com) wrote: I allways get the same error :
ERROR: set-valued function called in context that cannot accept a set
--
Rory Campbell-Lange
<ro**@campbell-lange.net>
<www.campbell-lange.net>
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mohammed Mazid |
last post by:
Can anyone please help me on how to move to the next and previous
question?
Here is a snippet of my code:
Private Sub cmdNext_Click()
End Sub
Private Sub cmdPrevious_Click()
showrecord
|
by: Stevey |
last post by:
I have the following XML file...
<?xml version="1.0"?>
<animals>
<animal>
<name>Tiger</name>
<questions>
<question index="0">true</question>
<question index="1">true</question>
</questions>
|
by: nospam |
last post by:
Ok, 3rd or is it the 4th time I have asked this question on Partial Types,
so, since it seems to me that Partial Types is still in the design or
development stages at Microsoft, I am going to ask...
|
by: Ekqvist Marko |
last post by:
Hi,
I have one Access database table including questions and answers. Now
I need to give answer id automatically to questionID column. But I
don't know how it is best (fastest) to do?
table...
|
by: glenn |
last post by:
I am use to programming in php and the way session and post vars are past
from fields on one page through to the post page automatically where I can
get to their values easily to write to a...
|
by: Rider |
last post by:
Hi, simple(?) question about asp.net configuration..
I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm
first start application the follow message shown.
=========
Server...
|
by: Jeff |
last post by:
In the function below, can size ever be 0 (zero)?
char *clc_strdup(const char * CLC_RESTRICT s)
{
size_t size;
char *p;
clc_assert_not_null(clc_strdup, s);
size = strlen(s) + 1;
|
by: spibou |
last post by:
In the statement "a *= expression" is expression assumed to be
parenthesized ? For example if I write "a *= b+c" is this the same
as "a = a * (b+c)" or "a = a * b+c" ?
|
by: Allan Ebdrup |
last post by:
Hi,
I'm trying to render a Matrix question in my ASP.Net 2.0 page, A matrix
question is a question where you have several options that can all be rated
according to several possible ratings (from...
|
by: Zhang Weiwu |
last post by:
Hello!
I wrote this:
..required-question p:after {
content: "*";
}
Corresponding HTML:
<div class="required-question"><p>Question Text</p><input /></div>
<div...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |