Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: How to Increment the value of a feild sequentillay in a multi
The logic is to be placed in the when-new-record-instance trigger:
Validation unit must be at least Block or higher (not record or item)
1- go to previous record 2- pick up the month from it 3- move back to the new record 4- increment and replace the month.
HTH! Aleem
-----Original Message-----
Sent: Saturday, May 17, 2003 2:37 PM To: Multiple recipients of list ORACLE-L Subject: Re: How to Increment the value of a feild sequentillay in amulti-record block ?
Hello:
A few days back I had posted the following question to our list,
the month field in the subsequent records should be sequentially incremented
by 1.
Can anyone please forward me the code in PL/ SQL for doing this.
Regards,
Faiz
but I could get no replies to my question. So I had to break my head on my
own and find a solution for that. I could find not one but two solutions:
Ist Soultion
The eample is built on a form with EMP block.
In the Trigger
when-new-block-instance (Emp Block)
:Global.currdate := '';
In the Trigger
when-new-record-instance (Emp Block)
If :Hiredate is not null and :Global.currdate is null then
If :System.last_record <> 'True' then
last_record;
:Global.currdate := to_char(:hiredate,'dd-mon-yyyy');
End if;
End if;
In the Trigger (hiredate Item)
when-new-item-instance
IF :System.Record_Status IN ('CHANGED','INSERT') THEN
IF :hiredate is null then
:hiredate := Add_months(to_date(:Global.currdate,'DD-Mon-YYYY'),1);
:Global.currdate := to_char(:hiredate,'dd-mon-yyyy');
end if;
end if;
IInd Solution : -
We can do the same thing by defining a when-new-rcord-instance trigger and
a when-new-block instance trigger and using a loop to increment the value of
a global variable.
Hope this helps others who face a similar situation in future.
Regards,
Faiz
-- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: FAIZ QURESHI INET: faizq_at_hotmail.com Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Abdul Aleem INET: dmit_at_beaconhouse.edu.pk Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Sat May 17 2003 - 05:31:43 CDT