Re: Some one plz help me (MAHENDRA D RATHOD) - Mailing list pgsql-admin

From Oliver Elphick
Subject Re: Some one plz help me (MAHENDRA D RATHOD)
Date
Msg-id 1052740079.18710.7.camel@linda.lfix.co.uk
Whole thread Raw
In response to Some one plz help me (MAHENDRA D RATHOD)  ("Ramesh PAtel " <ramesh@banas.guj.nic.in>)
List pgsql-admin
On Mon, 2003-05-12 at 11:53, Ramesh PAtel wrote:
> My self is Mahendra D Rathod.
>
> I have some problem in executing trigger at backend side
>
> One trigger is fired AFTER INSERT OR UPDATE ON  mtrl_issue_detail
>
> So when any row of "mtrl_issue_detail" is inserted or updated this
> trigger is fired on one function.
>
> This function updates the same row that has just been inserted or
> updated.
>
> Now when this process happens the database gets HANGED. and i have to
> restart the database on server.

This is hardly surprising, because you have explicitly set up an
infinite loop.

If you wish to change the record being updated or inserted, you should
use a BEFORE trigger, change NEW (the record to be inserted or the
after-update record) and return NEW.

Check the documentation:
  Programmer's Manual
    Procedural Languages
      PL/pgSQL
        Trigger procedures

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight, UK                             http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "Study to show thyself approved unto God, a workman
      who does not need to be ashamed and who correctly
      handles the word of truth."          II Timothy 2:15


pgsql-admin by date:

Previous
From: "Ramesh PAtel "
Date:
Subject: Some one plz help me (MAHENDRA D RATHOD)
Next
From: Tom Lane
Date:
Subject: Re: No flamefest please, MySQL vs. PostgreSQL AGAIN