Hola Roberto:
To follow up on what Larry said, I found that the best way to use
auto-number (IMHO) is to add a record with the basic information and then
call the just inserted record using the auto-numbered PK in the EDIT mode
using a form. I very seldom use forms in the ENTER mode, unless it is an
application that is data entry intensive and the form is designed just for
that; I normally use forms in the EDIT mode. The following snippet of code
illustrates the relevant portion of the code I use to generate a new,
auto-numbered Work Order:
-- A equipment code v_new_equip_code has been previously selected...
-- Now I will confirm that the user wants to proceed creating the work
order...
SET VAR vmessage = (' Create W.O. for Equipment Code: ' + .v_new_equip_code)
DIALOG .vmessage=37 vyes_no vcont YES CAPTION 'Confirm New Work Order...' +
ICON SERIOUS
IF (LUC(.vyes_no) EQ 'NO' OR vcont EQ '[Esc]' ) THEN
GOTO Done
ENDIF
-- Here I add one record with some basic information such as date, status,
etc., the auto-number will be automatically generated...
INSERT INTO fwo_file (fwo_fy,fwo_stat,fih_cont,fwork_type, +
equip_code,freason,foreman,hr_out,mi_out,fwo_work_location +
fwo_sched_start,wo_actual_start,wo_actual_end, +
fwcost_other,fwcost_labor,fwcost_parts,fwo_comments) +
VALUES( (IYR(.#DATE)), 'O', 'I', 'S', +
.v_new_equip_code,'','',0,0,'VSC', +
.#DATE, .#DATE, .#DATE, +
0.0, 0.0, 0.0, '')
-- Now I retrieve the auto-number PK fwo_no just generated by the INSERT
command
SET VAR vnew_fwono = fwo_no in fwo_file where count = LAST
-- Now I call the record just added in the EDIT mode using the PK fwo_no
using a form to make changes as needed
EDIT USING fwo_form WHERE fwo_no = .vnew_fwono
LABEL Done
I have used this approach in a multi-user application with moderate,
simultaneous work order generation by as many as 10 users with out a single
problem (duplicate auto-number) in as far back as I can remember. I hope the
information is of help.
Javier,
Javier Valencia, PE
President
Valencia Technology Group, L.L.C.
14315 S. Twilight Ln, Suite #14
Olathe, Kansas 66062-4578
Office (913)829-0888
Fax (913)649-2904
Cell (913)915-3137
================================================
Attention:
The information contained in this message and or attachments is intended
only for the person or entity to which it is addressed and may contain
confidential and/or privileged material. Any review, retransmission,
dissemination or other use of, or taking of any action in reliance upon,
this information by persons or entities other than the intended recipient
is prohibited. If you received this in error, please contact the sender and
delete the material from all system and destroy all copies.
======================================================
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] Behalf Of Lawrence Lustig
Sent: Monday, May 16, 2005 3:49 PM
To: RBG7-L Mailing List
Subject: [RBG7-L] - Re: AutoNumber Record
> SET VAR vnextnum INTEGER = (NEXT(mytable,nextnumber))
>
> This work OK, (I always get the next number value) but if I look at the
> table, the value of the record does NOT update to the next number,
The standard way to use an AUTONUM column is _not_ to call the NEXT()
function.
Whenever you insert a new record in a table, R:Base will take care of
making
sure that the new record contains the next number in sequence. You would
never
issue an UPDATE statement against that column, and you don't include it in
any
INSERT statements you issue -- it all happens automatically, by R:Base
magic.
An _alternative_ way to use the autonumbering system is with the NEXT()
function. This gives you the next value in the sequence and updates
R:Base's
internal counter (in the SYS_DEFAULTS table, if I recall correctly). If you
pull numbers off this way then yes, it is your responsiblity to put the
value
you get in the proper column.
--
Larry