Re: Raise Notice

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Prasad dev <esteem3300(at)hotmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Raise Notice
Date: 2005-06-22 00:18:46
Message-ID: 20050622001846.GA83488@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

[Please copy the mailing list on replies, and please don't post in HTML.
Ordinarily I'd trim the message I'm replying to, but since it wasn't
sent to the mailing list I'll post it here in its entirety. See my
response below.]

On Tue, Jun 21, 2005 at 10:49:35PM +0000, Prasad dev wrote:
>
> After posting i realised what i asked for was very unclear so here it
> goes,
> create table del2 (d2 int,d3 int,d4 int,primary key(d2,d3));
> create table del1 (d1 int, d2 int,d3 int,primary key(d1),foreign key
> (d2,d3) references del2(d2,d3));
> insert into del2 values (1,1,1);
> insert into del2 values (2,2,2);
> insert into del2 values (3,3,3);
> insert into del1 values (1,1,1);
> -------------------------------------------------------------------------
> CREATE OR REPLACE FUNCTION del_rest() RETURNS TRIGGER AS '
> DECLARE
> t record;
> BEGIN
> SELECT * INTO t FROM del2 WHERE d2=OLD.d2 and d3=OLD.d3;
> IF NOT FOUND THEN
> RAISE NOTICE ''No such record exits in table del2'';
> return null;
> END IF;
> END;
> 'LANGUAGE 'plpgsql';
> CREATE TRIGGER delrest BEFORE DELETE ON del2 FOR EACH ROW EXECUTE
> PROCEDURE del_rest();
>
> delete from del2 where d2=44 and d3=44;
> Here record 44 doesn't exist in the table del2 i just want it to show
> me the message in raise notice, i am using postgre - 7.3. When i
> run the query this is the output without the message.
>
> data=> delete from del2 where d2=44 and d3=44;
> DELETE 0
> data=>

A row-level trigger calls the trigger function once for each row
that the operation would affect. Since there are no matching rows,
the trigger function is never called.

What problem are you trying to solve? The "DELETE 0" response
already shows that no rows were deleted -- what purpose would the
notice serve?

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Michael Fuhr 2005-06-22 00:35:51 Re: Newbie Q:"RETURN cannot have a parameter in function returning set"?
Previous Message George McQuade 2005-06-21 22:13:06 Re: Subquery