Home » Developer & Programmer » Forms » HOW TO INCREMENT SERIAL NUMBER IN INSERT MODE (WIN XP)
HOW TO INCREMENT SERIAL NUMBER IN INSERT MODE [message #404952] Mon, 25 May 2009 13:13 Go to next message
orasql
Messages: 3
Registered: June 2007
Location: hyderabad
Junior Member
dear friends,
i have an dispaly item which is serial num(sno)..when iam inserting 1st record sno is 1 as I initialized it to 1,after insertion of 1st record when cursor lands on sno item it should increment its value by 1...i.e,it should be 2,....how can i do that?
Re: HOW TO INCREMENT SERIAL NUMBER IN INSERT MODE [message #404962 is a reply to message #404952] Mon, 25 May 2009 16:05 Go to previous messageGo to next message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
This:
Quote:
i have an dispaly item which is serial num(sno)

is contradicting this:
Quote:
when cursor lands on sno item

"Display items" aren't navigable, so cursor can NOT get into these items.


As of your question: you might use :SYSTEM.TRIGGER_RECORD system variable if you want to use that sequence in current session.
Otherwise, if your application is meant to be used by a single user, MAX(SNO) + 1 might also do the job. Though, this approach will (sooner or later) fail in multiuser environment.
Finally, using a SEQUENCE might be the right choice for you.
Re: HOW TO INCREMENT SERIAL NUMBER IN INSERT MODE [message #405123 is a reply to message #404962] Tue, 26 May 2009 07:34 Go to previous messageGo to next message
orasql
Messages: 3
Registered: June 2007
Location: hyderabad
Junior Member
thanx for your helpful reply
Re: HOW TO INCREMENT SERIAL NUMBER IN INSERT MODE [message #405158 is a reply to message #404962] Tue, 26 May 2009 11:46 Go to previous messageGo to next message
orasql
Messages: 3
Registered: June 2007
Location: hyderabad
Junior Member
hi everyone...
in my form i have multiple records..i have an display item
SNO in my form...in insert mode i want to increment its value by 1 for every record(in update mode i used rownum its workin).plzz help me .iam attaching the screenshot of that form.thanx in advance
Re: HOW TO INCREMENT SERIAL NUMBER IN INSERT MODE [message #405161 is a reply to message #404952] Tue, 26 May 2009 12:09 Go to previous messageGo to next message
dsora
Messages: 24
Registered: May 2009
Junior Member
For the moment, you can assign value to item in when-new-record-instance by checking system.mode (insert mode), increment it for every new record.

By using sequence:
you can make use of sequence (sql object).
Assign <sequence>.nextval to display item in pre-insert trigger.
not sure, you may need to use 'synchronize'.
Re: HOW TO INCREMENT SERIAL NUMBER IN INSERT MODE [message #405202 is a reply to message #404952] Tue, 26 May 2009 23:53 Go to previous messageGo to next message
hisham99
Messages: 86
Registered: October 2008
Location: united arab emirates
Member
PROCEDURE seqno_prc(p_sourceblock IN VARCHAR2, p_sourcefield IN VARCHAR2) IS
v_currec NUMBER(4);
v_curfld VARCHAR2(50);
BEGIN
v_currec := :SYSTEM.CURSOR_RECORD;
v_curfld := :SYSTEM.CURSOR_FIELD;
LOOP
COPY(:SYSTEM.CURSOR_RECORD, p_sourceblock || '.' || p_sourcefield);
IF :SYSTEM.LAST_RECORD = 'TRUE' THEN
EXIT;
END IF;
NEXT_RECORD;
END LOOP;
GO_RECORD(v_currec);
GO_FIELD(v_curfld);
END;
-----------------------
WHEN-NEW-RECORD-INSTANCE

BEGIN
If :SYSTEM.RECORD_STATUS in('NEW') THEN
--seqno_prc('block_name','item_name');
seqno_prc('dept','deptno');
END IF;
END;
Re: HOW TO INCREMENT SERIAL NUMBER IN INSERT MODE [message #406439 is a reply to message #405161] Thu, 04 June 2009 01:01 Go to previous message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Use 'when-create-record'.

David
Previous Topic: item date format problem
Next Topic: Single stroke insertion in all fmb/rdf?
Goto Forum:
  


Current Time: Fri Dec 09 21:37:52 CST 2016

Total time taken to generate the page: 0.09168 seconds