Trigger Problem - Mailing list pgsql-novice

From Ramesh PAtel
Subject Trigger Problem
Date
Msg-id 3EA54AC9.20255.CE8DCD@localhost
Whole thread Raw
Responses Re: Trigger Problem
List pgsql-novice
Hi All


i have problem in Trigger functoin




when trigger  fire then ERROR
massage is


ERROR :  Attribute 'UNDEF00'
not found
PostgreSQL status:PGRES_FATAL_ERROR


here UNDEF00 is by defult value of
po_no
TRIGGER IS


CREATE TRIGGER add_stock_gr_trig  AFTER
UPDATE on gr FOR EACH
ROW execute procedure add_stock_gr_fun();      
my function is this


create function add_stock_gr_fun()
returns opaque as'
DECLARE
    rec RECORD;
    txtpo varchar;
BEGIN


IF NEW.po_no <> "UNDEF00"
THEN   
            SELECT
INTO rec  gr_no, noofbags, final_wt, matl_cd
            FROM
po p, gr g
            WHERE
g.po_no=p.po_no and g.gr_no=NEW.gr_no;   


            IF
OLD.po_no #= "UNDEF00" THEN

                        UPDATE

matl_mst

                        SET

bal_bag = bal_bag + rec.noofbags,  
            
           bal_kg= bal_kg + rec.final_wt   

                       WHERE

matl_mst.matl_cd = rec.matl_cd;
            ELSE

                        UPDATE

matl_mst

                        SET

bal_bag = bal_bag + NEW.noofbags - OLD.noofbags,    
            
           bal_kg= bal_kg + NEW.final_wt  -  
OLD.final_wt

                       WHERE

matl_mst.matl_cd = rec.matl_cd;

                        
            END
IF;
END IF;


return NULL;    








END;'  language 'plpgsql';      








please Help me




Ramesh Patel

pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: Installing postgresql
Next
From: Dani Oderbolz
Date:
Subject: Re: Trigger Problem