Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Anders Altberg
  Where is Anders Altberg?
 Uppsala
 Sweden
 Anders Altberg
 To: Anup Singh
  Where is Anup Singh?
 Delhi
 India
 Anup Singh
 Tags
Subject: RE: Duplicate Bill No.
Thread ID: 209644 Message ID: 209818 # Views: 42 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Windows Vista and VFP
Date: Wednesday, December 31, 2008 12:37:54 PM         
   


> Dear Friends
>
> I am suffering with a very serious problem of bill number duplication.
>
> I am using free tables (.dbf) files
>
>
>
> sele gernal
> =rlock()
> sele tranfile
> set filt to
> set order to mdisvc
> fond="N"
> do while fond="N"
>   	seek billnumber
> 	if .not. found()
>     	fond="Y"
>   	else
>   		billnumber=billnumber+1
> 	endif
> enddo
> appe blan
> =rlock()
> repl bill with billnumber
> unlock all
> 

>
> I lock record in "gernal" file so that if any user want to add bill record in "tranfile" he will wait upto unlock. When i complete all the transaction then i issue "unlock all" to free all the tables for all and next user can save.
>
> Not often, but daily 1 or 2 bills generated with a duplicate number in multiuser platform.
>
> Please suggest me.
>
> With regard
> Anup Singh
> (M.D.)

> MARG Compusoft Pvt. Ltd.
>
> Email:anupmarg@gmail.com
> Web:www.margcompusoft.com

Shorten to
INSERT INTO Tranfile (billnumber) SELECT MAX(billnumber)+1 FROM Tranfile 


You should add a column that automatically adds a sequential number to you table.

SELECT MAX(billnumber) FROM Tranfile INTO ARRAY ABillnumber
ALTER TABLE Tranfile ALTER COLUMN billnumber Int AutoInc NEXTVALUE aBillNumber(1)+1 STEP 1 

From now on an incremented billnumber will be added automaticlly.
Q: How do you add the primary key that is required in every table?

-Anders

ENTIRE THREAD

Duplicate Bill No. Posted by Anup Singh @ 12/30/2008 8:34:42 AM
RE: Duplicate Bill No. Posted by mike castillo @ 12/30/2008 8:57:00 AM
RE: Duplicate Bill No. Posted by tushar @ 12/30/2008 9:08:55 AM
RE: Duplicate Bill No. Posted by Anil Sharma @ 12/30/2008 9:15:14 AM
RE: Duplicate Bill No. Posted by tushar @ 12/30/2008 9:34:36 AM
RE: Duplicate Bill No. Posted by Anil Sharma @ 12/30/2008 9:44:08 AM
RE: Duplicate Bill No. Posted by tushar @ 12/30/2008 2:29:07 PM
RE: Duplicate Bill No. Posted by mike castillo @ 12/31/2008 2:31:15 AM
RE: Duplicate Bill No. Posted by tushar @ 12/31/2008 6:04:54 AM
RE: Duplicate Bill No. Posted by Anders Altberg @ 12/31/2008 12:37:54 PM
RE: Duplicate Bill No. Posted by Anil Sharma @ 1/2/2009 9:06:24 AM
RE: Duplicate Bill No. Posted by Anders Altberg @ 1/2/2009 11:40:02 AM
RE: Duplicate Bill No. Posted by Anup Singh @ 1/2/2009 9:46:35 AM
RE: Duplicate Bill No. Posted by Jag Pal Sharma @ 2/2/2016 12:32:58 PM
RE: Duplicate Bill No. Posted by Tore Bleken @ 2/2/2016 12:48:00 PM
RE: Duplicate Bill No. Posted by Anders Altberg @ 1/2/2009 2:18:18 PM
RE: Duplicate Bill No. Posted by Anil Sharma @ 1/3/2009 7:58:04 AM
RE: Duplicate Bill No. Posted by anand kulkarni @ 2/4/2016 8:28:08 AM
RE: Duplicate Bill No. Posted by Tore Bleken @ 2/4/2016 8:58:38 AM
RE: Duplicate Bill No. Posted by anand kulkarni @ 2/4/2016 10:49:02 AM