Thread: Problem in SQL Trigger

Problem in SQL Trigger

From
"Ramesh Patel"
Date:
<p><br />Hi<br />i have one problem in Trigger.<br />this trigger alread work<br />on Red Hat Linux 7.3 but now i shift
toRHL9.0<br />in RHL 9.0  not<br />working . in this problem in ROUND function.<br />but how to i slove this<br />i
dontknow. so please help me.<br />This is  Function and<br />Trigger.<br />/////////////////////////// Function
Start//////////////////////////////////////////<br/>CREATE<br />FUNCTION add_issue_fun() returns opaque as'<br
/>BEGIN<br/>UPDATE<br />mtrl_mst <br />set balstk_cs = balstk_cs -<br />NEW.issueqty_cs,<br />balstk_mt = round(
cast((balstk_mt-<br />NEW.issueqty_mt) as numeric ),4)<br />where mtrl_mst.mtrl_code =<br />NEW.mtrl_code;<br />UPDATE
rcpt_detail<br />set consqty_cs=consqty_cs +<br />NEW.issueqty_cs<br />WHERE rcpt_detail.batch_code = NEW.batch_code<br
/><br/>and rcpt_detail.mtrl_code = NEW.mtrl_code<br />and<br />rcpt_detail.loc_code = NEW.loc_code;<br />return<br
/>NULL;<br/>END;'<br />language 'plpgsql';<br /><br />///////////////////////////
Function End//////////////////////////////////////////<br/>///////////////////////////Trigger Start
//////////////////////////////////////////<br/>CREATE<br />TRIGGER add_issue_trg<br />AFTER INSERT ON issue_detail<br
/>FOREACH<br />ROW EXECUTE PROCEDURE add_issue_fun();<br /><br />/////////////////////////// Trigger
End//////////////////////////////////////////<br/><p>Thanking<br /><br /><br />Ramesh Patel <br />Computer Dept. <br
/>Banasdairy,Palanpur  

Re: Problem in SQL Trigger

From
Rajesh Kumar Mallah
Date:

Can you tell us about the postgresql versions in 7.3 and 9.0
also post the actuall error message from postgresql.


regds
mallah.

Ramesh Patel wrote:

>
> Hi
> i have one problem in Trigger.
> this trigger alread work
> on Red Hat Linux 7.3 but now i shift to RHL9.0
> in RHL 9.0  not
> working . in this problem in ROUND function.
> but how to i slove this
> i dont know. so please help me.
> This is  Function and
> Trigger.
> /////////////////////////// Function 
> Start//////////////////////////////////////////
> CREATE
> FUNCTION add_issue_fun() returns opaque as'
> BEGIN
> UPDATE
> mtrl_mst
> set balstk_cs = balstk_cs -
> NEW.issueqty_cs,
> balstk_mt = round( cast((balstk_mt -
> NEW.issueqty_mt) as numeric ),4)
> where mtrl_mst.mtrl_code =
> NEW.mtrl_code;
> UPDATE rcpt_detail
> set consqty_cs=consqty_cs +
> NEW.issueqty_cs
> WHERE rcpt_detail.batch_code = NEW.batch_code
>
> and rcpt_detail.mtrl_code = NEW.mtrl_code
> and
> rcpt_detail.loc_code = NEW.loc_code;
> return
> NULL;
> END;'
> language 'plpgsql';
>
> /////////////////////////// 
> Function End//////////////////////////////////////////
> ///////////////////////////Trigger Start 
> //////////////////////////////////////////
> CREATE
> TRIGGER add_issue_trg
> AFTER INSERT ON issue_detail
> FOR EACH
> ROW EXECUTE PROCEDURE add_issue_fun();
>
> /////////////////////////// Trigger 
> End//////////////////////////////////////////
>
> Thanking
>
>
> Ramesh Patel
> Computer Dept.
> Banasdairy, Palanpur
>