[GENERAL] trigger question

2007-01-18 Thread Furesz Peter
Hello, I have a table named foobar and I don't want to allow from DELETE or UPDATE its rows. I have a table as described below: foobar(foobar_id, value, is_deleted); I don't want to allow directly delete or modify the table's rows. I plan to make an on before update or delete trigger and on

[GENERAL] Trigger Question

2007-03-14 Thread Jason Lee
I'm trying to write a trigger that updates a date_changed field on a record anytime that record is updated. I have a function written, and the trigger created, but everytime I update the record, I get a recursion limit error. It appears that the action performed by my trigger is causing the trigg

[GENERAL] trigger question

2005-08-16 Thread Apu Islam
I have a trigger which is not working properly. The error I get is parse error at $1. I am putting the code here for someone to see and comment on. (p/s the double quotes are actually two single quotes) best regards, -apu CREATE FUNCTION cust_call_update() RETURNS TRIGGER AS ' DECLARE

[GENERAL] Trigger Question

2005-01-05 Thread Terry Lee Tucker
Greetings: Is there any way to pass dynamic data into a trigger function? I think the answer is no, but just in case... TIA -- Work: 1-336-372-6812 Cell: 1-336-363-4719 email: [EMAIL PROTECTED] ---(end of broadcast)--- TIP 9: the planner will i

[GENERAL] trigger question

2000-06-27 Thread mikeo
hi, i've created a function as follows: drop function rates_hist_function(); CREATE function rates_hist_function() returns opaque as 'BEGIN if ( old.rt_valid <> ''P'' or new.rt_valid not in (''Y'',''N'')) then new.rt_timestamp = n

[GENERAL] Trigger question

2004-08-26 Thread Daniel Schuchardt
Hi list, i'm a bit confused. I have a table with a trigger after insert. It is possible that this trigger will do inserts in the same table, but is the after insert trigger fired again in this case? (I would need this) e.g. USER INSERT BEFORE TRIGGER AFTER TRIGGER ->DECIDES TO INSERT X ROWS IN T

Re: [GENERAL] trigger question

2007-01-18 Thread A. Kretschmer
am Tue, dem 16.01.2007, um 18:35:56 +0100 mailte Furesz Peter folgendes: > Hello, > > I have a table named foobar and I don't want to allow from DELETE or > UPDATE its rows. > > I have a table as described below: > foobar(foobar_id, value, is_deleted); > > I don't want to allow directly delet

Re: [GENERAL] trigger question

2007-01-19 Thread Lenorovitz, Joel
I ran into a similar problem and the solution I came up with (which admittedly feels like a kludge) was to temporarily disable the triggers on the table being modified while an update was made and then re-enabling them immediately after the update. I am sure there is potential for problems with t

Re: [GENERAL] trigger question

2007-01-26 Thread Furesz Peter
Hello, maybe I have found a better solution. In PostgreSQL 8.2 this current solution is not working properly, because I got "too many triggers on table tablename" error. This is the first thing. The second problem that if something go wrong between the disable and re-enable the trigger, the trigge

Re: [GENERAL] Trigger Question

2007-03-14 Thread Richard Huxton
Jason Lee wrote: I'm trying to write a trigger that updates a date_changed field on a record anytime that record is updated. I have a function written, and the trigger created, but everytime I update the record, I get a recursion limit error. [snip] declare begin update unit_specification

Re: [GENERAL] Trigger Question

2007-03-14 Thread Terry Lee Tucker
On Wednesday 14 March 2007 11:15, Jason Lee wrote: > I'm trying to write a trigger that updates a date_changed field on a > record anytime that record is updated. I have a function written, and > the trigger created, but everytime I update the record, I get a > recursion limit error. It appears t

Re: [GENERAL] Trigger Question

2007-03-14 Thread Alban Hertroys
Jason Lee wrote: > I'm trying to write a trigger that updates a date_changed field on a > record anytime that record is updated. I have a function written, and > the trigger created, but everytime I update the record, I get a > recursion limit error. It appears that the action performed by my Yo

Re: [GENERAL] Trigger Question

2007-03-14 Thread Jason Lee
: Richard Huxton [mailto:[EMAIL PROTECTED] > Sent: Wednesday, March 14, 2007 10:38 AM > To: Jason Lee > Cc: pgsql-general@postgresql.org > Subject: Re: [GENERAL] Trigger Question > > Jason Lee wrote: > > I'm trying to write a trigger that updates a date_changed &g

Re: [GENERAL] trigger question

2005-08-16 Thread Michael Fuhr
On Tue, Aug 16, 2005 at 07:19:38PM -0500, Apu Islam wrote: > I have a trigger which is not working properly. > The error I get is parse error at $1. I am putting the code here for > someone to see and comment on. When do you get the error? When you create the function, or when the trigger calls i

Re: [GENERAL] trigger question

2005-08-17 Thread Michael Fuhr
[Please copy the mailing list on replies so others can contribute to and learn from the discussion.] On Wed, Aug 17, 2005 at 08:17:43PM -0500, Apu Islam wrote: > However, I still get the error.. here is a sample very trim down version. > I think the "hour" is the problem child. Anyone can give me

Re: [GENERAL] Trigger Question

2005-01-05 Thread Michael Fuhr
On Wed, Jan 05, 2005 at 02:56:27PM -0500, Terry Lee Tucker wrote: > > Is there any way to pass dynamic data into a trigger function? I think the > answer is no, but just in case... What do you mean by "dynamic data"? What problem are you trying to solve? -- Michael Fuhr http://www.fuhr.org/~mf

Re: [GENERAL] Trigger Question

2005-01-05 Thread Terry Lee Tucker
When I assign a value to a certain column in a table A, I want to be able to assign a value in table A to table B and then to assign a value in table B to table C. I was wanting to do this from the trigger level in an AFTER UPDATE trigger to ensure it gets done. I would like to be able to pass t

Re: [GENERAL] Trigger Question

2005-01-05 Thread Michael Fuhr
On Wed, Jan 05, 2005 at 03:25:08PM -0500, Terry Lee Tucker wrote: > When I assign a value to a certain column in a table A, I want to be able to > assign a value in table A to table B and then to assign a value in table B to > table C. What do you mean by "assign a value to a certain column"?

Re: [GENERAL] Trigger Question

2005-01-05 Thread Terry Lee Tucker
1) INSERT INTO logs (carr_code, ..., ..., ...) VALUES('ABCDEFG', ..., ...); logs is table A in my question 2) logs_insert fires (This is a AFTER INSERT trigger) 3) in this trigger, I need to do the following: update avlds set carr_code = new.carr_code where avlds.recid = ??;

Re: [GENERAL] Trigger Question

2005-01-05 Thread Alex Turner
Maybe what you want is a stored procedure, not a trigger. A trigger will only have the data that is available from the insert operation, and the rest of the row that was modified (It really can't have anything else if you think about it) Stored procedures are an exellent way to guarantee atomic a

Re: [GENERAL] Trigger Question

2005-01-05 Thread Thomas Braad Toft
Terry Lee Tucker wrote: 1) INSERT INTO logs (carr_code, ..., ..., ...) VALUES('ABCDEFG', ..., ...); logs is table A in my question 2) logs_insert fires (This is a AFTER INSERT trigger) 3) in this trigger, I need to do the following: update avlds set carr_code = new.carr_code where avlds

Re: [GENERAL] Trigger Question

2005-01-05 Thread Terry Lee Tucker
Now why didn't I think of that? That's exactly what I need to do. Thanks to all who responded ;o) On Wednesday 05 January 2005 05:09 pm, Alex Turner saith: > Maybe what you want is a stored procedure, not a trigger. A trigger > will only have the data that is available from the insert operation,

Re: [GENERAL] Trigger Question

2005-01-05 Thread Michael Fuhr
On Wed, Jan 05, 2005 at 05:35:18PM -0500, Terry Lee Tucker wrote: > On Wednesday 05 January 2005 05:09 pm, Alex Turner saith: > > > > Maybe what you want is a stored procedure, not a trigger. > > Now why didn't I think of that? That's exactly what I need to do. This is a good example of why it's b

Re: [GENERAL] trigger question

2000-06-27 Thread Tom Lane
mikeo <[EMAIL PROTECTED]> writes: > CREATE function rates_hist_function() > returns opaque > as 'BEGIN >if ( old.rt_valid <> ''P'' or new.rt_valid not in (''Y'',''N'')) > i get this error: > ERROR: record old is unassigned yet >

Re: [GENERAL] trigger question

2000-06-27 Thread mikeo
At 10:33 AM 6/27/00 -0400, Tom Lane wrote: >mikeo <[EMAIL PROTECTED]> writes: >> CREATE function rates_hist_function() >> returns opaque >> as 'BEGIN >>if ( old.rt_valid <> ''P'' or new.rt_valid not in (''Y'',''N'')) > > >> i get th

Re: [GENERAL] trigger question

2000-06-27 Thread Tom Lane
mikeo <[EMAIL PROTECTED]> writes: > in oracle, the triggers were smart enough to know not to reference > an old value on insert in an "insert or update" trigger procedure, > apparently. > this is the original oracle trigger that works fine > with the same insert statement: > CREATE OR REPLACE T

Re: [GENERAL] trigger question

2000-07-03 Thread Anatoly K. Lasareff
> "m" == mikeo <[EMAIL PROTECTED]> writes: m> At 11:27 AM 6/27/00 -0400, Tom Lane wrote: >> mikeo <[EMAIL PROTECTED]> writes: >>> in oracle, the triggers were smart enough to know not to reference >>> an old value on insert in an "insert or update" trigger procedure, >>> apparently. >>

[GENERAL] Trigger question: ROW or STATEMENT?

2006-01-25 Thread Patrick Hatcher
Attempting to do my first trigger and I'm confused about which FOR EACH I should use: ROW or STATEMENT. I import about 80K rows into an existing table each day. If I do a STATEMENT, will the changes only happen on the new 80K rows I inserted or will it be for all rows in the table - currently ab

Re: [GENERAL] Trigger question: ROW or STATEMENT?

2006-01-25 Thread Doug McNaught
Patrick Hatcher <[EMAIL PROTECTED]> writes: > Attempting to do my first trigger and I'm confused about which FOR EACH I > should use: ROW or STATEMENT. I import about 80K rows into an existing > table each day. If I do a STATEMENT, will the changes only happen on the > new 80K rows I inserted or

Re: [GENERAL] Trigger question: ROW or STATEMENT?

2006-01-25 Thread Patrick Hatcher
01/25/06 11:45 AM <[EMAIL PROTECTED]> cc pgsql-general@postgresql.org

Re: [GENERAL] Trigger question: ROW or STATEMENT?

2006-01-25 Thread Doug McNaught
Patrick Hatcher <[EMAIL PROTECTED]> writes: > Here is the trigger the way it is currently written. I add some additional > information from another table: If you're modifying each row before it goes in, it should definitely be a FOR EACH ROW trigger. -Doug ---(end of br

Re: [GENERAL] Trigger question: ROW or STATEMENT?

2006-01-25 Thread Patrick Hatcher
Subject Re: [GENERAL] Trigger question: ROW

Re: [GENERAL] Trigger question: ROW or STATEMENT?

2006-01-25 Thread Michael Fuhr
On Wed, Jan 25, 2006 at 02:47:45PM -0800, Patrick Hatcher wrote: > Would I gain any advantage by changing to it to fire after the insert? If you're modifying the row then the trigger must fire before the insert. An after trigger can abort the operation by raising an error and it can perform actio

Re: [GENERAL] Trigger question: ROW or STATEMENT?

2006-01-26 Thread Patrick Hatcher
Subject Re: [GENERAL] Trigger question: