Re: Raise Notice

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Raise Notice
Дата
Msg-id 20050622001846.GA83488@winnie.fuhr.org
обсуждение исходный текст
Ответ на Re: Raise Notice  (Michael Fuhr <mike@fuhr.org>)
Список 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/

В списке pgsql-novice по дате отправления:

Предыдущее
От: George McQuade
Дата:
Сообщение: Re: Subquery
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: Newbie Q:"RETURN cannot have a parameter in function returning set"?