473,626 Members | 3,365 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trigger isn't fired

Hi,
I created a trigger function and a trigger with that function on a table. It
is an "after insert or update or delete" trigger, in which I want to modify
a second table regardless of the current modifications.

Everything seems to be good on modifying the table, no error messages. After
the modifications the second table isn't modified at all. Should anybody
suggest me what I'm doing wrong? Does a trigger functon send error messages
if it fails?

My statements:
--------------
CREATE OR REPLACE FUNCTION trg_upd_prod_in stock() RETURNS trigger AS '
BEGIN
perform ''update t_products set
getup_instock=g et_stock_getup( ''||quote_liter al(NEW.producti d)||'',1) where
id=''||quote_li teral(NEW.produ ctid);
RETURN NEW;
END;
' LANGUAGE plpgsql;

GRANT ALL ON FUNCTION trg_upd_prod_in stock() TO public;

CREATE TRIGGER t_stockchanges_ trigger AFTER INSERT OR UPDATE OR DELETE ON
t_stockchanges
FOR EACH ROW EXECUTE PROCEDURE trg_upd_prod_in stock();

Many thanks,
-- Csaba Együd

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.707 / Virus Database: 463 - Release Date: 2004. 06. 15.

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #1
4 1229
On Sat, 26 Jun 2004, [iso-8859-2] Együd Csaba wrote:
Hi,
I created a trigger function and a trigger with that function on a table. It
is an "after insert or update or delete" trigger, in which I want to modify
a second table regardless of the current modifications.

Everything seems to be good on modifying the table, no error messages. After
the modifications the second table isn't modified at all. Should anybody
suggest me what I'm doing wrong? Does a trigger functon send error messages
if it fails?

My statements:
--------------
CREATE OR REPLACE FUNCTION trg_upd_prod_in stock() RETURNS trigger AS '
BEGIN
perform ''update t_products set
getup_instock=g et_stock_getup( ''||quote_liter al(NEW.producti d)||'',1) where
id=''||quote_li teral(NEW.produ ctid);


I don't think this is going to do what you want. Are you sure you didn't
want EXECUTE rather than PERFORM?

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #2
Hi Stephan,
it was the problem, but not realy understand the reason. The documentetion
sais that perform doesn't porvide the return value and I thought I do not
need that. But I read absently, and didn't realized that the query to
perform must be a SELECT.

Thank you for opening my eyes. :) Now the trigger does its task. Thank you
very much.

Best regards,
-- Csaba Együd

-----Original Message-----
From: pg************* ****@postgresql .org
[mailto:pg****** ***********@pos tgresql.org]On Behalf Of Stephan Szabo
Sent: 2004. június 26. 22:32
To: Együd Csaba
Cc: Pg***********@P ostgresql.Org (E-mail)
Subject: Re: [GENERAL] Trigger isn't fired
On Sat, 26 Jun 2004, [iso-8859-2] Együd Csaba wrote:
Hi,
I created a trigger function and a trigger with that

function on a table. It
is an "after insert or update or delete" trigger, in which

I want to modify
a second table regardless of the current modifications.

Everything seems to be good on modifying the table, no

error messages. After
the modifications the second table isn't modified at all.

Should anybody
suggest me what I'm doing wrong? Does a trigger functon

send error messages
if it fails?

My statements:
--------------
CREATE OR REPLACE FUNCTION trg_upd_prod_in stock() RETURNS

trigger AS '
BEGIN
perform ''update t_products set

getup_instock=g et_stock_getup( ''||quote_liter al(NEW.producti d)
||'',1) where
id=''||quote_li teral(NEW.produ ctid);


I don't think this is going to do what you want. Are you
sure you didn't
want EXECUTE rather than PERFORM?

---------------------------(end of
broadcast)---------------------------
TIP 8: explain analyze is your friend

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.707 / Virus Database: 463 - Release Date: 2004. 06. 15.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.707 / Virus Database: 463 - Release Date: 2004. 06. 15.

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postg resql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #3
In article <016601c45c14$1 36a9570$230a0a0 a@compaq>,
Együd Csaba <cs*****@vnet.h u> writes:
Hi Stephan,
it was the problem, but not realy understand the reason. The documentetion
sais that perform doesn't porvide the return value and I thought I do not
need that. But I read absently, and didn't realized that the query to
perform must be a SELECT. Thank you for opening my eyes. :) Now the trigger does its task.


Does it really? You're using NEW.productid, which should be undefined
for a DELETE trigger.
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #4
Yes, yes you are right. :)
I had already modified that (using TG_OP variable) before I posted the
letter just didn't mentioned.
By the way the trigger does its task. Rally. :)

Thanks,
-- Csaba
-----Original Message-----
From: pg************* ****@postgresql .org
[mailto:pg****** ***********@pos tgresql.org]On Behalf Of Harald Fuchs
Sent: 2004. június 27. 12:12
To: pg***********@p ostgresql.org
Subject: Re: [GENERAL] Trigger isn't fired
In article <016601c45c14$1 36a9570$230a0a0 a@compaq>,
Együd Csaba <cs*****@vnet.h u> writes:
Hi Stephan,
it was the problem, but not realy understand the reason.

The documentetion
sais that perform doesn't porvide the return value and I

thought I do not
need that. But I read absently, and didn't realized that

the query to
perform must be a SELECT.

Thank you for opening my eyes. :) Now the trigger does its task.


Does it really? You're using NEW.productid, which should be undefined
for a DELETE trigger.
---------------------------(end of
broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.712 / Virus Database: 468 - Release Date: 2004. 06. 27.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.712 / Virus Database: 468 - Release Date: 2004. 06. 27.

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5277
by: Franklin Bowen | last post by:
Are there any limitations or gotchas to updating the same table which fired a trigger from within the trigger? Some example code below. Hmmm.... This example seems to be working fine so it must be something with my specific schema/code. We're working on running a SQL trace but if anybody has any input, fire away. Thanks!
2
10630
by: M Wells | last post by:
Hi All, I'm a relatively newbie to SQL Server 2000, having come from a MySQL background. I'm creating my first Trigger statement on a table, and I'd like to know how I go about performing an update on the row that was changed when the trigger was fired. To explain, I have 2 columns, one which contains a member number, the
6
6546
by: Scott CM | last post by:
I have a multi-part question regarding trigger performance. First of all, is there performance gain from issuing the following within a trigger: SELECT PrimaryKeyColumn FROM INSERTED opposed to: SELECT * FROM INSERTED
7
2045
by: Lucio Chiessi | last post by:
Hi for all on this... I'm using MS SQL Server 7.0 SP4 in some customers to store some data from an aplication developed by me. I created an trigger to run on update. When I run an update command on it's table and the where condition returns only one row, the trigger is executed ok, but if where condition returns more than one rows, the trigger don't run. I don't know what happens there...
1
2077
by: Graeme Hinchliffe | last post by:
Hiya, Not had much experience with tiggers under postgres but am liking them so far. My problem is this. I am writing an updates system, postgres holds the master copy of the database, any changes made to this are logged in an updates table which is monitored by a daemon, which if any updates are spotted propigates them to the remote servers. I have written an initial trigger that spots any changes made to the
8
2616
by: Frank van Vugt | last post by:
Hi, If during a transaction a number of deferred triggers are fired, what will be their execution order upon the commit? Will they be executed in order of firing or alfabetically or something entirely different? The docs only mention regular triggers being executed alfabetically.
1
1557
by: Daniel Schuchardt | last post by:
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
2
2987
by: jcandersen | last post by:
Hi. I need to make a trigger which fires when after an UPDATE is done on table A in database X. The trigger must perform a statement which copies some of the data from the update to table B in database Y on the same server. My question is: Can I access the data which caused the trigger to fire or just get an indication of which entry in table A had been updated? Best Regards
5
18662
by: Hubert Trzewik | last post by:
Hi, I want to have all-in-one trigger, defined like this: CREATE TRIGGER MyInsertDeleteUpdateHandler ON MyTable FOR DELETE, INSERT, UPDATE AS BEGIN (...)
0
8265
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8196
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8637
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8364
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4197
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2625
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1808
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.