Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: How to Increment the value of a feild sequentillay in a multi-record block ?

Re: How to Increment the value of a feild sequentillay in a multi-record block ?

From: FAIZ QURESHI <faizq_at_hotmail.com>
Date: Sat, 17 May 2003 01:36:39 -0800
Message-ID: <F001.0059BBC6.20030517013639@fatcity.com>


Hello:
A few days back I had posted the following question to our list,



Hello All:
I am using Forms 6i.
I have a situation whichnrequires that in a multi-record block, I want the value of month field to be incremented automatically as the user navigates down the block.Only in the first record the user enters the month after that 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



MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus
-- 
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).
Received on Sat May 17 2003 - 04:36:39 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US