Re: [SQL] Trigger for updating view with join

2013-09-03 Thread Dmitry Morozovsky
Heh, it's me spamming you again :) now -- asking for comments. > > create trigger fsl_update instead of insert or update on fsl ... > > > > but till now did not succeed in it. Quick googlink did not help either. > > Argh. My google-fu is definitely low in the night ;) > > for the record: it'

Re: [SQL] Trigger for updating view with join

2013-09-03 Thread Dmitry Morozovsky
On Wed, 4 Sep 2013, Dmitry Morozovsky wrote: > Dear colleagues, > > I'm running Pg 9.1 and have schema like the following: [snip] > I understand I should use smth like > > create trigger fsl_update instead of insert or update on fsl ... > > but till now did not succeed in it. Quick googlink

Re: [SQL] Trigger triggered from a foreign key

2012-10-22 Thread Jasen Betts
On 2012-10-19, Victor Sterpu wrote: > I have this trigger that works fine. The trigger prevents the deletion > of the last record. > But I want skip this trigger execution when the delete is done from a > external key. > How can I do this? perhaps you have to use a rule instead of a trigger? -

Re: [SQL] Trigger triggered from a foreign key

2012-10-19 Thread David Johnston
> -Original Message- > From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql- > ow...@postgresql.org] On Behalf Of Victor Sterpu > Sent: Friday, October 19, 2012 2:15 PM > To: pgsql-sql@postgresql.org > Subject: [SQL] Trigger triggered from a foreign key > > I have this trigger that works

Re: [SQL] [TRIGGER] Returning values from BEFORE UPDATE trigger, without using them

2010-07-27 Thread Torsten Zühlsdorff
Tom Lane schrieb: =?ISO-8859-15?Q?Torsten_Z=FChlsdorff?= writes: I have defined an BEFORE UPDATE trigger. The trigger catch every update, change some columns of the new row, make an insert of the new row and returns null to abort the update. Why in the world would you do that? Just return t

Re: [SQL] [TRIGGER] Returning values from BEFORE UPDATE trigger, without using them

2010-07-27 Thread Tom Lane
=?ISO-8859-15?Q?Torsten_Z=FChlsdorff?= writes: > I have defined an BEFORE UPDATE trigger. The trigger catch every update, > change some columns of the new row, make an insert of the new row and > returns null to abort the update. Why in the world would you do that? Just return the modified row

Re: [SQL] [TRIGGER] Returning values from BEFORE UPDATE trigger, without using them

2010-07-26 Thread Torsten Zühlsdorff
Hey Dmitriy, thanks for your reply. I think, its would be better to use rule on update instead of the trigger in such case as you. I've played the whole weekend with the rule-system, but it didn't work for my case. I have a dynamic trigger, which takes cares about revision of rows for every

Re: [SQL] [Trigger] Help needed with NEW.* and TG_TABLE_NAME

2010-05-17 Thread Torsten Zühlsdorff
Jasen Betts schrieb: On 2010-05-11, Torsten Zühlsdorff wrote: Hello, i have a problem with a trigger written in pl/pgsql. It looks like this: CREATE OR REPLACE FUNCTION versionize() RETURNS TRIGGER AS $$ BEGIN NEW.revision := addContentRevision (OLD.content_id, OLD.revision); /* not

Re: [SQL] [Trigger] Help needed with NEW.* and TG_TABLE_NAME

2010-05-13 Thread Jasen Betts
On 2010-05-11, Torsten Zühlsdorff wrote: > Hello, > > i have a problem with a trigger written in pl/pgsql. > > It looks like this: > > CREATE OR REPLACE FUNCTION versionize() > RETURNS TRIGGER > AS $$ > BEGIN > >NEW.revision := addContentRevision (OLD.content_id, OLD.revision); > >/* not w

Re: [SQL] [Trigger] Help needed with NEW.* and TG_TABLE_NAME

2010-05-11 Thread silly sad
On 05/11/10 18:26, Torsten Zühlsdorff wrote: Tom Lane schrieb: =?ISO-8859-15?Q?Torsten_Z=FChlsdorff?= writes: NEW.revision := addContentRevision (OLD.content_id, OLD.revision); /* not working line, just a stub: EXECUTE 'INSERT INTO ' || TG_TABLE_NAME || ' SELECT $1 ' USING NEW; */ RETU

Re: [SQL] [Trigger] Help needed with NEW.* and TG_TABLE_NAME

2010-05-11 Thread Stuart
Torsten, Usually, the “insert ... (select ...)” has the select portion enclosed in parenthesis. Don't know if solution is that simple but did not see it in your examples. It may be worth a try. Stuart - Original message - > Hello, > > i have a problem with a trigger written in pl/pgs

Re: [SQL] [Trigger] Help needed with NEW.* and TG_TABLE_NAME

2010-05-11 Thread Torsten Zühlsdorff
Tom Lane schrieb: =?ISO-8859-15?Q?Torsten_Z=FChlsdorff?= writes: NEW.revision := addContentRevision (OLD.content_id, OLD.revision); /* not working line, just a stub: EXECUTE 'INSERT INTO ' || TG_TABLE_NAME || ' SELECT $1 ' USING NEW; */ RETURN NULL; This seems like the

Re: [SQL] [Trigger] Help needed with NEW.* and TG_TABLE_NAME

2010-05-11 Thread Tom Lane
=?ISO-8859-15?Q?Torsten_Z=FChlsdorff?= writes: >NEW.revision := addContentRevision (OLD.content_id, OLD.revision); >/* not working line, just a stub: >EXECUTE 'INSERT INTO ' || TG_TABLE_NAME || ' SELECT $1 ' USING NEW; >*/ >RETURN NULL; This seems like the hard way. Why do

Re: [SQL] Trigger on select :-(

2010-03-11 Thread Jaime Casanova
On Mon, Mar 1, 2010 at 9:10 PM, Ray Madigan wrote: > > What I want to do is when I do a SELECT on the Catalog and deliver the > result to the user, I want to check to see if the FooKey is in the users > ToDo table and set the value of a column isToDo to true or false depending > on if the FooKey e

Re: [SQL] Trigger on select :-(

2010-03-11 Thread Garrett Murphy
Are you able to set up a SELECT query to get the result you want? If you are, it's as simple as putting "CREATE VIEW viewname AS ", followed by your query. Garrett Murphy _ From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On

Re: [SQL] trigger failed to identify the partions

2009-09-09 Thread Richard Huxton
Sridhar Reddy Ratna wrote: > > cmd := 'INSERT INTO ' || dateTable || > EXECUTE cmd; > RETURN NEW; > If I changed the RETURN NEW to RETURN NULL its inserting only one row. Yes. RETURN NEW allows the insert to procede normally so you end up with the two rows. > But to work wi

Re: [SQL] trigger failed to identify the partions

2009-09-09 Thread Sridhar Reddy Ratna
Sridhar ratna -Original Message- From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On Behalf Of Richard Huxton Sent: Wednesday, September 09, 2009 3:35 PM To: Sridhar Reddy Ratna Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] trigger failed to

Re: [SQL] trigger failed to identify the partions

2009-09-09 Thread Richard Huxton
Sridhar Reddy Ratna wrote: > > dateTable := coll_fp_subdtls_01; > > ELSE > > dateTable := coll_fp_subdtls_02; > ERROR: column "coll_fp_subdtls_01" does not exist > > ERROR: column "coll_fp_subdtls_01" does not exist I think you mi

Re: [SQL] trigger before delete question

2009-04-21 Thread Tom Lane
Sigrid Thijs writes: > I've bumped into a problem with a trigger before delete that I do not > immediately understand. I have made a simple example that also illustrates > the issue, but in reality the database structure is more complex. The reason it doesn't work is that the delete from member c

Re: [SQL] Trigger/Function - one solution - was constraint question (I think)

2008-12-04 Thread Rafael Domiciano
I would develop like this (No so many changes, it is basically a small trigger) create or replace function compound_rows_range_check() returns trigger as $body$ DECLARE BAYNO int4; BEGIN -- First Verification = if changing compound or row fail IF (old.co_id <> new.co_id or old.cr_id <>

Re: [SQL] Trigger/Function - one solution - was constraint question (I think)

2008-12-04 Thread Gary Stainburn
I have managed to develop one solution using functions and triggers. Has anyone got a better solution? Gary create unique index "compound_bays_unique_index" on compound_bays using btree (co_id,cr_id,cb_id); create or replace function compound_rows_range_check() returns trigger as $proc$ DECLA

Re: [SQL] trigger parameters, what am I doing wrong ??

2008-10-10 Thread Bart Degryse
With some version (but I don't remember which) I had the same problem. I solved it by assigning TG_ARGV[0] to a variable and use the variable in the RAISE NOTICE. >>> Tom Lane <[EMAIL PROTECTED]> 2008-10-09 19:22 >>> "Marcin Krawczyk" <[EMAIL PROTECTED]> writes: > And here's what RAISE NOTICE lo

Re: [SQL] trigger parameters, what am I doing wrong ??

2008-10-09 Thread Tom Lane
"Marcin Krawczyk" <[EMAIL PROTECTED]> writes: > And here's what RAISE NOTICE looks like : NOTICE: TG_ARGV = , > TG_NARGS = 0, par = > What's wrong with it ?? I'm running 8.1.4 Works for me: regression=# insert into test_table values(1); INSERT 0 1 regression=# update test_table set f1 = 2; NOTI

Re: [SQL] Trigger Procedure Error: NEW used in query that is not in a rule

2008-09-17 Thread Raphael Bauduin
On Wed, Sep 17, 2008 at 5:45 PM, hubert depesz lubaczewski <[EMAIL PROTECTED]> wrote: > On Wed, Sep 17, 2008 at 05:08:39PM +0200, Raphael Bauduin wrote: >> Would you have a little example on how you would do it? > > show us what you have done - it will be easier to find/fix/explain than > to write

Re: [SQL] Trigger Procedure Error: NEW used in query that is not in a rule

2008-09-17 Thread Raphael Bauduin
HI, On Sat, Aug 11, 2007 at 9:07 PM, hubert depesz lubaczewski <[EMAIL PROTECTED]> wrote: > On Sat, Aug 11, 2007 at 02:45:09AM -0500, Javier Fonseca V. wrote: >> I think that it's working alright except for the next line: > > doing this in plpgsql is very complicated (or even impossible assuming >

Re: [SQL] trigger for TRUNCATE?

2008-01-14 Thread Peter Childs
On 11/01/2008, Simon Riggs <[EMAIL PROTECTED]> wrote: > > On Fri, 2008-01-11 at 08:24 +, Richard Huxton wrote: > > > I've always considered TRUNCATE to be DDL rather than DML. I mentally > > group it with DROP TABLE rather than DELETE> > > DDL/DML probably isn't the right split, since its then

Re: [SQL] trigger for TRUNCATE?

2008-01-11 Thread Bruce Momjian
Added to TODO: > * Add ability to trigger on TRUNCATE > > http://archives.postgresql.org/pgsql-sql/2008-01/msg00050.php --- Simon Riggs wrote: > On Fri, 2008-01-11 at 08:24 +, Richard Huxton wrote: > > > I've always

Re: [SQL] trigger for TRUNCATE?

2008-01-11 Thread Simon Riggs
On Fri, 2008-01-11 at 08:24 +, Richard Huxton wrote: > I've always considered TRUNCATE to be DDL rather than DML. I mentally > group it with DROP TABLE rather than DELETE> DDL/DML probably isn't the right split, since its then arguable as to which group of commands it belongs in. I see we

Re: [SQL] trigger for TRUNCATE?

2008-01-11 Thread Erik Jones
On Jan 11, 2008, at 2:24 AM, Richard Huxton wrote: Tom Lane wrote: Alvaro Herrera <[EMAIL PROTECTED]> writes: My thinking is that a TRUNCATE trigger is a per-statement trigger which doesn't have access to the set of deleted rows (Replicator uses it that way -- we replicate the truncate act

Re: [SQL] trigger for TRUNCATE?

2008-01-11 Thread Richard Huxton
Tom Lane wrote: Alvaro Herrera <[EMAIL PROTECTED]> writes: My thinking is that a TRUNCATE trigger is a per-statement trigger which doesn't have access to the set of deleted rows (Replicator uses it that way -- we replicate the truncate action, and replay it on the replica). In that way it would

Re: [SQL] trigger for TRUNCATE?

2008-01-10 Thread Chris Browne
[EMAIL PROTECTED] (Tom Lane) writes: > Alvaro Herrera <[EMAIL PROTECTED]> writes: >> Gerardo Herzig escribió: >>> Yes, the TRUNCATE statement is not sql ansi, maybe is a more low level >>> thing than i think. > >> TRUNCATE currently does not fire triggers, but that doesn't mean it's >> impossible

Re: [SQL] trigger for TRUNCATE?

2008-01-10 Thread Simon Riggs
Alvaro Herrera wrote: > My thinking is that a TRUNCATE trigger is a per-statement trigger which > doesn't have access to the set of deleted rows. > In that way it would be different from a per-statement trigger for > DELETE. Completely agree. A truncate trigger should run a different function

Re: [SQL] trigger for TRUNCATE?

2008-01-10 Thread Tom Lane
Alvaro Herrera <[EMAIL PROTECTED]> writes: > My thinking is that a TRUNCATE trigger is a per-statement trigger which > doesn't have access to the set of deleted rows (Replicator uses it that > way -- we replicate the truncate action, and replay it on the replica). > In that way it would be differen

Re: [SQL] trigger for TRUNCATE?

2008-01-10 Thread Gerardo Herzig
Tom Lane wrote: Alvaro Herrera <[EMAIL PROTECTED]> writes: Gerardo Herzig escribió: Yes, the TRUNCATE statement is not sql ansi, maybe is a more low level thing than i think. TRUNCATE currently does not fire triggers, but that doesn't mean it's impossible to do it. I thin

Re: [SQL] trigger for TRUNCATE?

2008-01-10 Thread Alvaro Herrera
Tom Lane escribió: > Alvaro Herrera <[EMAIL PROTECTED]> writes: > > Gerardo Herzig escribi�: > >> Yes, the TRUNCATE statement is not sql ansi, maybe is a more low level > >> thing than i think. > > > TRUNCATE currently does not fire triggers, but that doesn't mean it's > > impossible to do it. I

Re: [SQL] trigger for TRUNCATE?

2008-01-10 Thread Tom Lane
Alvaro Herrera <[EMAIL PROTECTED]> writes: > Gerardo Herzig escribió: >> Yes, the TRUNCATE statement is not sql ansi, maybe is a more low level >> thing than i think. > TRUNCATE currently does not fire triggers, but that doesn't mean it's > impossible to do it. I think it would be fairly easy to

Re: [SQL] trigger for TRUNCATE?

2008-01-10 Thread Alvaro Herrera
Gerardo Herzig escribió: > Yes, the TRUNCATE statement is not sql ansi, maybe is a more low level > thing than i think. TRUNCATE currently does not fire triggers, but that doesn't mean it's impossible to do it. I think it would be fairly easy to add support for that. Currently, Mammoth Replica

Re: [SQL] trigger for TRUNCATE?

2008-01-10 Thread Gerardo Herzig
Pavel Stehule wrote: On 08/01/2008, Chris Browne <[EMAIL PROTECTED]> wrote: [EMAIL PROTECTED] (Gerardo Herzig) writes: Hi all. Acording to the docs, TRUNCATE will not fire a DELETE trigger on the table being truncated. There is a way to capture a TRUNCATE in any way? I think th

Re: [SQL] trigger for TRUNCATE?

2008-01-08 Thread Pavel Stehule
Hello theoretically you can have trigger on any statement, but I am not sure about conformance with std. But, you can wrap TRUNCATE statement into some procedure, and then call this procedure with some other actions. Regards Pavel Stehule On 08/01/2008, Chris Browne <[EMAIL PROTECTED]> wrote: >

Re: [SQL] trigger for TRUNCATE?

2008-01-08 Thread Chris Browne
[EMAIL PROTECTED] (Gerardo Herzig) writes: > Hi all. Acording to the docs, TRUNCATE will not fire a DELETE trigger > on the table being truncated. > There is a way to capture a TRUNCATE in any way? I think there's some sort of "to do" on that... It ought to be not *too* difficult (I imagine!) to

Re: [SQL] Trigger definition . . . puzzled

2007-12-13 Thread Rolf A. de By
Ouch, that hurts! It suddenly dawns on me . . . Big difference on table that you specify and table where it actually takes effect. Confusing at first. Thanks a million, Tom. "Rolf A. de By" <[EMAIL PROTECTED]> writes: Yes, this is an inheritance set-up. But actually no: I am executing al

Re: [SQL] Trigger definition . . . puzzled

2007-12-13 Thread Tom Lane
"Rolf A. de By" <[EMAIL PROTECTED]> writes: > Yes, this is an inheritance set-up. But actually no: I am executing all > my data changes against the parent table, and want the trigger on that > parent table to fire for an insert on the parent table as it does. But > I also want the trigger to f

Re: [SQL] Trigger definition . . . puzzled

2007-12-13 Thread Rolf A. de By
Thanks Tom, Yes, this is an inheritance set-up. But actually no: I am executing all my data changes against the parent table, and want the trigger on that parent table to fire for an insert on the parent table as it does. But I also want the trigger to fire when an update on the parent table

Re: [SQL] Trigger definition . . . puzzled

2007-12-13 Thread Tom Lane
"Rolf A. de By" <[EMAIL PROTECTED]> writes: > Thanks for that. There is some misunderstanding here. For this example, > I had taken the sting out of my trigger function and turned it into a > much more concise no-op, with warnings. The actual code of my original > trigger function is irrelevan

Re: [SQL] Trigger definition . . . puzzled

2007-12-12 Thread Rolf A. de By
Erik, Thanks for that. There is some misunderstanding here. For this example, I had taken the sting out of my trigger function and turned it into a much more concise no-op, with warnings. The actual code of my original trigger function is irrelevant. The no-op trigger function displays the

Re: [SQL] Trigger definition . . . puzzled

2007-12-12 Thread Erik Jones
On Dec 12, 2007, at 3:38 PM, Rolf A. de By wrote: Greetings list, Running pg 8.2.3. on a windows machine, I have become blind in a trigger definition puzzle, so hope that somebody may help me understand where I goof. I have a base table i_s that has three tables that inherit from it,

Re: [SQL] Trigger to change different row in same table

2007-09-04 Thread PostgreSQL Admin
chester c young wrote: > how are you preventing recursion? > > That could be the problem, suggestions? ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] Trigger Procedure Error: NEW used in query that is not in a rule

2007-08-11 Thread hubert depesz lubaczewski
On Sat, Aug 11, 2007 at 02:45:09AM -0500, Javier Fonseca V. wrote: > I think that it's working alright except for the next line: doing this in plpgsql is very complicated (or even impossible assuming that any table can have the same trigger). i would rather suggest using pl/perl - writing somethin

Re: [SQL] Trigger Procedure Error: NEW used in query that is not in a rule

2007-08-11 Thread Javier Fonseca V.
Yes Tom, you're right, but the real problem is that I need to use an EXECUTE statement because my table name is dynamic. In your example, you used logt as a static table name, and that doesn't need an EXECUTE statement. So I think that I'll have to rewrite a Trigger Procedure for each table and t

Re: [SQL] Trigger Procedure Error: NEW used in query that is not in a rule

2007-08-11 Thread Pavel Stehule
2007/8/11, Tom Lane <[EMAIL PROTECTED]>: > "Pavel Stehule" <[EMAIL PROTECTED]> writes: > > NEW is only plpgsql variable. It isn't visible on SQL level. > > Correct, but: > > > You cannot use new.*, you can: > > execute 'INSERT ...' || 'VALUES(' || new.a || ',' || new.b > > You're both overthin

Re: [SQL] Trigger Procedure Error: NEW used in query that is not in a rule

2007-08-11 Thread Tom Lane
"Pavel Stehule" <[EMAIL PROTECTED]> writes: > NEW is only plpgsql variable. It isn't visible on SQL level. Correct, but: > You cannot use new.*, you can: > execute 'INSERT ...' || 'VALUES(' || new.a || ',' || new.b You're both overthinking the problem. In recent releases (at least since 8.

Re: [SQL] Trigger Procedure Error: NEW used in query that is not in a rule

2007-08-11 Thread Pavel Stehule
NEW is only plpgsql variable. It isn't visible on SQL level. You cannot use new.*, you can: execute 'INSERT ...' || 'VALUES(' || new.a || ',' || new.b regards Pavel 2007/8/11, Javier Fonseca V. <[EMAIL PROTECTED]>: > > > Hello. > > I'm doing a Trigger Procedure in pl/pgSQL. It makes some k

Re: [SQL] trigger firing order

2007-06-15 Thread chester c young
> > does the post trigger on A wait until post trigger on B is > executed? -> > this seems intuitive to me. > > How can it wait until the trigger on B is executed if the trigger on > B doesn't > actually get triggered until someone updates B and it's the trigger > on A > doing the update? trigge

Re: [SQL] trigger firing order

2007-06-15 Thread Gregory Stark
"chester c young" <[EMAIL PROTECTED]> writes: > tables A and B: a post row trigger on A cause updates on B which has > its own post row trigger. > > does the post trigger on A wait until post trigger on B is executed? - > this seems intuitive to me. How can it wait until the trigger on B is execu

Re: [SQL] Trigger with Stored Procedure [Client Points]

2006-08-31 Thread Aaron Bono
On 8/31/06, Ezequias Rodrigues da Rocha <[EMAIL PROTECTED]> wrote: Bono,I must check each insert on my Points(each shop generate a new line on Points table).When I insert  the  record  on points  I must  see the field Value(on points table already) and update the Client.Points field based in some

Re: [SQL] Trigger with Stored Procedure [Client Points]

2006-08-31 Thread Aaron Bono
On 8/30/06, Ezequias Rodrigues da Rocha <[EMAIL PROTECTED]> wrote: Hi list,I have a table like this:Points-Idoperationvalueand another two tables like thisClient    Rule    -

Re: [SQL] Trigger on Insert to Update only newly inserted fields?

2006-08-31 Thread Aaron Bono
On 8/28/06, Henry Ortega <[EMAIL PROTECTED]> wrote: Here's what I am doing:I have this table:employee   payrate     effective     tstamp   end_date (to be updated by trigger)jdoe   1000 04-01-2006    2006-03-10 13:39: 07.614945jdoe

Re: [SQL] Trigger on Insert to Update only newly inserted fields?

2006-08-29 Thread Michael Fuhr
On Mon, Aug 28, 2006 at 11:53:36AM -0400, Henry Ortega wrote: > CREATE FUNCTION updated_end_date() RETURNS trigger AS ' > BEGIN >update table set end_date=(select effective-1 from table t2 where > t2.employee=table.employee and t2.effective>table.effective order by > t2.effective limit 1); >

Re: [SQL] Trigger on Insert to Update only newly inserted fields?

2006-08-28 Thread Henry Ortega
Here's what I am doing:I have this table:employee   payrate     effective     tstamp   end_date (to be updated by trigger)jdoe   1000 04-01-2006    2006-03-10 13:39: 07.614945jdoe   1500 04-01-2006    2006-03-12 15:

Re: [SQL] Trigger on Insert to Update only newly inserted fields?

2006-08-28 Thread Michael Fuhr
On Mon, Aug 28, 2006 at 10:02:32AM -0400, Henry Ortega wrote: > I have a On Insert Trigger that updates one of the columns in that same > table. > > Is there a way for the trigger to run only for the newly inserted records? > Instead of all records in the database? Row-level INSERT and UPDATE trig

Re: [SQL] trigger needs to check in multiple tables.

2006-08-18 Thread Michael Fuhr
On Fri, Aug 18, 2006 at 07:17:27PM +0200, Jacobo Garca wrote: > I'm running a simple query inside a function that is associated with a > trigger: > >SELECT tipo INTO tipocuenta FROM producto WHERE codigo_cuenta= > NEW.codigo_destino; > > I am getting this error when running the code on pgadmi

Re: [SQL] Trigger, record "old" is not assigned yet

2006-07-13 Thread Aaron Bono
On 7/13/06, Adrian Klaver <[EMAIL PROTECTED]> wrote: For plpgsql use TG_OP. See link below.http://www.postgresql.org/docs/8.1/interactive/plpgsql-trigger.htmlOn Thursday 13 July 2006 03:50 pm, Daniel Caune wrote: > Hi, I've created a trigger BEFORE INSERT OR UPDATE on a table and, indeed,> when

Re: [SQL] Trigger, record "old" is not assigned yet

2006-07-13 Thread Adrian Klaver
For plpgsql use TG_OP. See link below. http://www.postgresql.org/docs/8.1/interactive/plpgsql-trigger.html On Thursday 13 July 2006 03:50 pm, Daniel Caune wrote: > Hi, > > > > I've created a trigger BEFORE INSERT OR UPDATE on a table and, indeed, > when the trigger is raised before insertion the re

Re: [SQL] trigger to enforce FK with nulls?

2006-04-12 Thread Stephan Szabo
On Wed, 12 Apr 2006, George Young wrote: > [PostgreSQL 8.1.3 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.0.1] > > I'm starting to use lots of foreign key constraints to keep my > data clean. In one case, however, I need to allow null values > for the key. E.g.: > > create table opset_steps

Re: [SQL] trigger to enforce FK with nulls?

2006-04-12 Thread Alvaro Herrera
George Young wrote: > Since foreign keys per se can't do this, I presume the way > is to use triggers, though I have not used triggers before. Says who? Just don't specify NOT NULL on the referencing column. -- Alvaro Herrerahttp://www.CommandPrompt.com/ The Pos

Re: [SQL] Trigger/Sequence headache

2006-02-17 Thread rlee0001
Stephen, You don't need to use a seperate batch to clean up the table. As Stephan pointed out, you can call nextval after you determine that the new row isn't a duplicate. In case you misunderstood what Stephan had suggested let me try to explain what is happening. When PostgreSQL receives an IN

Re: [SQL] Trigger/Sequence headache

2006-02-14 Thread Markus Schaber
Hi, Stephen, Foster, Stephen wrote: > That's what I thought was going to be the answer. I was just hoping I > was making a mistake somehow. It's no big deal but I like things > organized and hate giant holes. > > Ok, one more thing for one of the batch jobs. No problem I have a > cleanup routi

Re: [SQL] Trigger/Sequence headache

2006-02-12 Thread Foster, Stephen
Lee Foster/ -Original Message- From: Stephan Szabo [mailto:[EMAIL PROTECTED] Sent: Sunday, February 12, 2006 5:11 PM To: Foster, Stephen Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] Trigger/Sequence headache On Sun, 12 Feb 2006, Foster, Stephen wrote: > This is going to be one of those stupi

Re: [SQL] Trigger/Sequence headache

2006-02-12 Thread Stephan Szabo
On Sun, 12 Feb 2006, Foster, Stephen wrote: > This is going to be one of those stupid problems of mine. I have an > insert trigger setup to verify that duplicate or repeating information > isn't storage in the table. If trigger function finds the information > as a duplicate it returns a NULL a

Re: [SQL] Trigger efficiency

2006-02-06 Thread Craig Servin
I do not know of a way to make your trigger run less often, but you could only have it do the insert if something changes. This is what we do: CREATE or replace FUNCTION UPDATE_SERVER_HST() RETURNS TRIGGER AS ' begin if (OLD.ADD_DATE is distinct from NEW.ADD_DATE or OLD.HOSTNAME

Re: [SQL] Trigger on a column

2006-02-06 Thread Richard Huxton
Josep Sanmartí wrote: Hi, readding around I just found this: The CREATE TRIGGER statement in PostgreSQL implements a subset of the SQL99 standard. (There are no provisions for triggers in SQL92.) The following functionality IS MISSING: * SQL99 allows triggers to fire on updates to specific col

Re: [SQL] Trigger on a column

2006-02-06 Thread Josep Sanmartí
Hi, readding around I just found this: The CREATE TRIGGER statement in PostgreSQL implements a subset of the SQL99 standard. (There are no provisions for triggers in SQL92.) The following functionality IS MISSING: * SQL99 allows triggers to fire on updates to specific columns (e.g., AFTER UPDA

Re: [SQL] Trigger / rule question

2005-11-20 Thread Joost Kraaijeveld
Hi Peter, On Sun, 2005-11-20 at 12:08 +0100, Peter Eisentraut wrote: > Joost Kraaijeveld wrote: > > 1. Does an insert, update or delete statement return before or after > > an "After" trigger (is such a trigger or rule synchronous or > > a-synchronous? > > Synchronous > > > 2. Is there a concept

Re: [SQL] Trigger / rule question

2005-11-20 Thread Peter Eisentraut
Joost Kraaijeveld wrote: > 1. Does an insert, update or delete statement return before or after > an "After" trigger (is such a trigger or rule synchronous or > a-synchronous? Synchronous > 2. Is there a concept of a rule or trigger that fails? > If so, if a trigger or rule fails, does the inser

Re: [SQL] trigger between to different database

2005-08-14 Thread Michael Fuhr
On Mon, Aug 08, 2005 at 09:41:22PM +0300, Haris Saybasili wrote: > > I have two databasese: database1 and database2. I want to set a > trigger on a table of database1 which will insert some values to a > table of database2. You could use contrib/dblink but you wouldn't have transaction semantics.

Re: [SQL] trigger between to different database

2005-08-14 Thread Kenneth Gonsalves
On Tuesday 09 Aug 2005 12:11 am, Haris Saybasili wrote: > Hi everybody, > > I have two databasese: database1 and database2. I want to set a > trigger on a table of database1 which will insert some values to a > table of database2. > > Is it possible with postgresql? How can I find detailed informat

Re: [SQL] Trigger on select?

2005-08-03 Thread Karsten Hilbert
On Tue, Aug 02, 2005 at 05:54:59PM -0700, Chris Travers wrote: > >Hey, anyone know if it is possible to fire a trigger before a select? > >I'm considering creating some tables which contain data summarized > >from other tables as kind of a cache mechanism. The hope is I can > >speed up some q

Re: [SQL] Trigger on select?

2005-08-02 Thread Chris Travers
Kyle Bateman wrote: Hey, anyone know if it is possible to fire a trigger before a select? I'm considering creating some tables which contain data summarized from other tables as kind of a cache mechanism. The hope is I can speed up some queries that get executed a lot (and are kind of slow)

Re: [SQL] trigger/rule question

2005-05-06 Thread Ramakrishnan Muralidharan
MAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Enrico Weigelt Sent: Monday, May 02, 2005 9:02 AM To: pgsql-sql Subject: Re: [SQL] trigger/rule question * Ramakrishnan Muralidharan <[EMAIL PROTECTED]> wrote: Hi, > Going through you mail, I assume that you are updating the mtime >

Re: [SQL] trigger/rule question

2005-05-02 Thread Christoph Haller
Enrico Weigelt wrote: > > * Christoph Haller <[EMAIL PROTECTED]> wrote: > > Hi, > > > I assume this still refers to > > [SQL] RULE for mtime recording > > from last Friday. > > ehm, yeah. I forgot that I've already asked this stuff ... > hmmpf. seems I'm not getting younger ;-) > > > > I gave

Re: [SQL] trigger/rule question

2005-05-01 Thread Enrico Weigelt
* Christoph Haller <[EMAIL PROTECTED]> wrote: Hi, > I assume this still refers to > [SQL] RULE for mtime recording > from last Friday. ehm, yeah. I forgot that I've already asked this stuff ... hmmpf. seems I'm not getting younger ;-) > I gave it another thought and > I am now having somet

Re: [SQL] trigger/rule question

2005-05-01 Thread Enrico Weigelt
* Ramakrishnan Muralidharan <[EMAIL PROTECTED]> wrote: Hi, > Going through you mail, I assume that you are updating the mtime > only after inserting the record. An "normal" update (=done by an application or user) should also update the mtime. But there's an replication subsystem, whi

Re: [SQL] trigger/rule question

2005-04-29 Thread Ramakrishnan Muralidharan
Hi, Going through you mail, I assume that you are updating the mtime only after inserting the record. It is always possible to check the mtime filed value of the inserted record and take action based on it in the trigger. Is it possible to send me detail about the trigger? Regards, R.

Re: [SQL] trigger/rule question

2005-04-28 Thread Christoph Haller
Enrico Weigelt wrote: > > Hi folks, > > for database synchronization I'm maintaining an mtime field in > each record and I'd like to get it updated automatically on > normal writes (insert seems trivial, but update not), but it > must remain untouched when data is coming in from another node > (t

Re: [SQL] Trigger with parameters

2005-03-21 Thread Richard Huxton
[EMAIL PROTECTED] wrote: CREATE TRIGGER products_codes_checkfieldvalue BEFORE INSERT OR UPDATE ON main.products_codes FOR EACH ROW EXECUTE PROCEDURE trigger_system_checkfieldvalue('main','products_codes'); --- ERROR: function trigger_system_checkfieldvalue() does not exist But the functio

Re: [SQL] Trigger

2005-02-22 Thread Pavel Rabel
It requires a bit more work in PostgreSQL to create a trigger. From the documentation: "It is not currently possible to write a SQL-language trigger function. Trigger functions can be written in C or in some of the available procedural languages." I guess you will prefer to write the trigger in

Re: [SQL] Trigger

2005-02-22 Thread Eugen Gass
OW EXECUTE PROCEDURE synchronize(); Best Regards Eugen -Ursprüngliche Nachricht- Von: Pavel Rabel [mailto:[EMAIL PROTECTED] Gesendet: Mittwoch, 16. Februar 2005 21:43 An: Eugen Gass Cc: pgsql-sql@postgresql.org Betreff: Re: [SQL] Trigger It requires a bit more work in PostgreSQL to create

Re: [SQL] Trigger

2005-02-16 Thread Michael Fuhr
On Wed, Feb 16, 2005 at 02:44:30PM +0100, Eugen Gass wrote: > > I'm trying to create a trigger on PostgreSQL See the "Server Programming" part of the documentation (substitute the appropriate version of PostgreSQL in the links): http://www.postgresql.org/docs/8.0/static/server-programming.html h

Re: [SQL] trigger status

2004-11-03 Thread Michael Fuhr
On Wed, Nov 03, 2004 at 08:57:35AM -0600, hook wrote: > What's the easy way to tell if a trigger has fired??? Tell from where? You could log messages from the trigger (e.g., with RAISE INFO in PL/pgSQL), but that might not be what you're talking about. What are you trying to do? -- Michael Fu

Re: [SQL] Trigger and function not on speaking terms

2004-08-05 Thread Kevin Davis
You need to define fn_foo w/o params per Doc Section 19.9. Your intent as expressed in the trigger def (args) can then be fulfilled through special top level vars. On Mon, 2004-08-02 at 16:20, Jeff Boes wrote: > Hmm, this is puzzling me: > > create or replace function fn_foo(text) returns trigger

Re: [SQL] Trigger and function not on speaking terms

2004-08-02 Thread Richard Poole
On Mon, Aug 02, 2004 at 04:20:15PM -0400, Jeff Boes wrote: > It would seem my trigger definition is trying to find fn_foo(), when I > mean for it to call fn_foo(TEXT). Triggers have to be declared to take no arguments; they find the rows on which they operate in magical ways. (For PL/PgSQL trigg

Re: [SQL] Trigger and function not on speaking terms

2004-08-02 Thread Stephan Szabo
On Mon, 2 Aug 2004, Jeff Boes wrote: > Hmm, this is puzzling me: > > create or replace function fn_foo(text) returns trigger as ' > begin ># Do some stuff with $1 > end; > ' language 'plpgsql'; > > CREATE FUNCTION > > create table bar (aaa text); > > CREATE TABLE > > create trigger trg_bar > a

Re: [SQL] Trigger functions with dynamic SQL

2004-07-26 Thread Andreas Haumer
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi! I have solved the problem! Tom Lane wrote: > Andreas Haumer <[EMAIL PROTECTED]> writes: > >>I just can't figure out where and how many quotation marks >>I have to place in my function. > > > It's messy all right. The "dollar quoting" feature in

Re: [SQL] Trigger functions with dynamic SQL

2004-07-24 Thread Tom Lane
Andreas Haumer <[EMAIL PROTECTED]> writes: > I just can't figure out where and how many quotation marks > I have to place in my function. It's messy all right. The "dollar quoting" feature in 7.5 should make it a lot less painful, since you can stop having to double and re-double quote marks. If

Re: [SQL] Trigger functions with dynamic SQL

2004-07-24 Thread Andreas Haumer
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi! Many thanks for your reply! Tom Lane wrote: > Andreas Haumer <[EMAIL PROTECTED]> writes: > >>It seems I would have to use EXECUTE on dynamically constructed >>PL/PGSQL statements in order to have my trigger function recognize >>the parameters giv

Re: [SQL] Trigger functions with dynamic SQL

2004-07-24 Thread Tom Lane
Andreas Haumer <[EMAIL PROTECTED]> writes: > It seems I would have to use EXECUTE on dynamically constructed > PL/PGSQL statements in order to have my trigger function recognize > the parameters given to the trigger in TG_ARGV[] Yup, that's exactly right. plpgsql isn't designed for this; it's des

Re: [SQL] Trigger problem

2004-06-09 Thread Jan Wieck
On 6/8/2004 2:57 PM, Mike Rylander wrote: kasper wrote: Hi guys Im tryint to make a trigger that marks a tuble as changed whenever someone has updated it my table looks something like this create table myTable ( ... changed boolean; ) now ive been working on a trigger and a sp that looks li

Re: [SQL] Trigger problem

2004-06-09 Thread Stephan Szabo
On Tue, 8 Jun 2004, kasper wrote: > Im tryint to make a trigger that marks a tuble as changed whenever someone > has updated it > > my table looks something like this > > create table myTable ( > ... > changed boolean; > ) > > now ive been working on a trigger and a sp that looks like thi

Re: [SQL] Trigger problem

2004-06-09 Thread Mike Rylander
kasper wrote: > Hi guys > > Im tryint to make a trigger that marks a tuble as changed whenever someone > has updated it > > my table looks something like this > > create table myTable ( > ... > changed boolean; > ) > > now ive been working on a trigger and a sp that looks like this, bu

Re: [SQL] trigger function building

2004-05-26 Thread Manuel Sugawara
hook <[EMAIL PROTECTED]> writes: > What's the proper way to include the suport files for building 'C' trigger > functions in to the normal PostgreSQL install? > > > I.E. / > "make install "does not include internal/postgres_fe.h, executor/spi.h > nor commands/trigger.h in to /usr/local/pgsql

  1   2   >