Consider using sequences instead and remove the logic to see if a contact already exists (aka checking to make SURE it is unique. It will always be unique unless you have rogue programs out there not using the sequence object)
CREATE SEQUENCE seq_contact
MINVALUE 1
START WITH 1
INCREMENT BY 1
CACHE 10
INSERT INTO Contact (P_Id,FirstName,LastName)
VALUES (seq_contact.nextval,'Lars','Monsen')
-----Original Message-----
From: Stone, Joel [mailto:Joel.Stone@xxxxxxxxxx]
Sent: Thursday, March 13, 2014 3:48 PM
To: midrange-l@xxxxxxxxxxxx
Subject: is there a proper method to get next number in sequence?
Contracts are added to our database by going to a dataara and retrieving the next contract number.
This next contract number is used to add the new contract record. (contract number is primary unique key).
It is possible that contract numbers already exist sporadically, so somewhere in the logic the contract file must be checked for key existence.
Is it OK to find the next contract # during the contract add? I would think that this would be risky and it may be better to simply bump the data area by 1 and then wait and validate it is unique whenever the NEXT user tries to add a contact.
Any suggestions?
Thanks
______________________________________________________________________
This outbound email has been scanned for all viruses by the MessageLabs Skyscan service.
For more information please visit
http://www.symanteccloud.com ______________________________________________________________________
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at
http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.