Home » Developer & Programmer » Forms » IF condition problem in pre-update trigger
IF condition problem in pre-update trigger [message #521909] Sun, 04 September 2011 00:23 Go to next message
goparaju
Messages: 54
Registered: June 2011
Member
Hi Experts,

I am working in 6i. I have a datablock A.

DATA BLOCK A: concession, status, date(read only).

Requirement: If the status not in ('open','in process'), i want to assign sysdate to date column, otherwise, no sysdate assignment to date column. I am using below logic to achieve.

PRE-UPDATE TRIGGER:

IF :blockA.status not in ('open','in process') THEN
:blockA.date:=sysdate;
END IF;

But irrespective of above if condition, it's assigning sysdate to date column, could somebody help me why it's going wrong.

Kindly help.

Re: IF condition problem in pre-update trigger [message #521918 is a reply to message #521909] Sun, 04 September 2011 05:14 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
What happens when you move that code into a WHEN-VALIDATE-ITEM trigger on the :BLOCKA.STATUS item?
Re: IF condition problem in pre-update trigger [message #521920 is a reply to message #521918] Sun, 04 September 2011 05:28 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
Put a message immediately before the line that assigns sysdate and see if it's actually firing.
I would assume some other code is setting the date to sysdate.
Re: IF condition problem in pre-update trigger [message #521929 is a reply to message #521920] Sun, 04 September 2011 23:22 Go to previous messageGo to next message
itech
Messages: 173
Registered: May 2008
Location: Fsd, Pakistan
Senior Member

write like this..
if lower(:blocka.status) not in ('open','in process') then
:blocka.date := sysdate;
else
:blocka.date := null;
end if;
Re: IF condition problem in pre-update trigger [message #521945 is a reply to message #521929] Mon, 05 September 2011 02:45 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
No don't write like that. Identify the actual source of the problem and fix it.
Re: IF condition problem in pre-update trigger [message #521976 is a reply to message #521945] Mon, 05 September 2011 05:15 Go to previous messageGo to next message
itech
Messages: 173
Registered: May 2008
Location: Fsd, Pakistan
Senior Member

cookie monster, i believe that the requirement is stated as :
Quote:

Requirement: If the status not in ('open','in process'), i want to assign sysdate to date column, otherwise, no sysdate assignment to date column. I am using below logic to achieve.


so isnt the above piece of code fullfil the requirement ?
Re: IF condition problem in pre-update trigger [message #521980 is a reply to message #521976] Mon, 05 September 2011 05:19 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
The original code meets the requirement. If the column is getting set to sysdate in all circumstances then some other code will be responsible. That other code should be found and fixed.
Re: IF condition problem in pre-update trigger [message #521987 is a reply to message #521980] Mon, 05 September 2011 05:46 Go to previous messageGo to next message
itech
Messages: 173
Registered: May 2008
Location: Fsd, Pakistan
Senior Member

hmm, k, u can be right.
Re: IF condition problem in pre-update trigger [message #522027 is a reply to message #521987] Mon, 05 September 2011 12:49 Go to previous messageGo to next message
goparaju
Messages: 54
Registered: June 2011
Member
Hi,

Thanks for your replies. Below code is working for me.

if lower(:blocka.status) not in ('open','in process') then
:blocka.date := sysdate;
else
:blocka.date := null;
end if;


Thanks.
Re: IF condition problem in pre-update trigger [message #522030 is a reply to message #522027] Mon, 05 September 2011 16:00 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
Don't you think it'd be a good idea to find the other bit of code that's setting the date item to sysdate and fix it?
Re: IF condition problem in pre-update trigger [message #522086 is a reply to message #522027] Tue, 06 September 2011 07:05 Go to previous messageGo to next message
itech
Messages: 173
Registered: May 2008
Location: Fsd, Pakistan
Senior Member

goparaju wrote on Mon, 05 September 2011 22:49
Hi,

Thanks for your replies. Below code is working for me.

if lower(:blocka.status) not in ('open','in process') then
:blocka.date := sysdate;
else
:blocka.date := null;
end if;


Thanks.


welcome,
i beleive it was due to logical error,
since the user once set the status to open or in process
and then afterwards change the status, and since upn change of status u were not setting the date column to null, hte old value remained there...
Re: IF condition problem in pre-update trigger [message #522094 is a reply to message #522086] Tue, 06 September 2011 07:37 Go to previous message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
That might be the case.
Previous Topic: Entering Mathematical Equations / Symbols
Next Topic: How to cancel the Enter-Query Mode
Goto Forum:
  


Current Time: Sat Sep 07 12:57:11 CDT 2024