record number in free record lookup
Craig Tooker
craig at cwtsoftware.com
Fri Feb 3 06:54:16 PST 2012
The variable name does not matter. The type does. It should be a .0
type such as CE(8,.0). The @RN is a system variable that in the case of
new(@RN) will return the record number of the current lookup named new.
I *think* what Richard was trying to say was that you should be very
careful with a database design that uses record numbers as an access
method to retrieve sub (or deity forbid) master records.
There are too many instances when you will want to restructure a
database which will cause the record numbers to change (such as packing
a file or a re-design). Always try to use unique keys which are
normalized in the database design and avoid using record numbers.
To answer your question in your first post, the record number is
assigned [and is available via new(@RN)] immediately after the lookup
-free which creates the record. Before or after the write.
In the example you supplied, you may have a logic problem if 6 le @TD
because it will fall through the lookup and break on the following line
that references a lookup that has not been performed. You may know that
will never happen so perhaps I'm nitpicking.
Craig
On 2/3/2012 09:40, scooter6 at gmail.com wrote:
> So I have to use 'rn' as the variable and it will work?
> Basically same thing I'm doing I just have to replace my 'ce' variable
> with 'rn'?
>
> On Fri, Feb 3, 2012 at 9:27 AM, Richard Kreiss<rkreiss at verizon.net> wrote:
>
>> Top post from phone:
>>
>> To get the new record number after the lookup free add rn=new(@rn). This
>> will be the new record number.
>>
>> Be careful about record numbers as Filepro will add new records to deleted
>> records. So it is possible that a new record may be added which has a lower
>> record number the the highest available record number in the file.
>>
>> Richard
>> Sent from my iPhone
>>
>> On Feb 3, 2012, at 9:06 AM, "scooter6 at gmail.com"<scooter6 at gmail.com>
>> wrote:
>>
>>> I have a process that is adding a record to a file and I need to capture
>>> the record number that is being added
>>> i.e.
>>>
>>> If = 6 gt @td
>>> Then = lookup new = file r=free -e
>>>
>>> Then = ce(10,*)=new(@rn)
>>>
>>>
>>> I need 'ce' equal to the record number that is getting added to 'file'
>> so I
>>> can do another free lookup that needs
>>> the newly created record number in 'file'
>>>
>>> Is this possible?
>>> I have tried setting ce after I do a 'write' new but that didn't work
>> either
>>> Anyone?
>>>
>>> Scott
>>> PDM
>>> -------------- next part --------------
>>> An HTML attachment was scrubbed...
>>> URL:
>> http://mailman.celestial.com/pipermail/filepro-list/attachments/20120203/2a5a65de/attachment.html
>>> _______________________________________________
>>> Filepro-list mailing list
>>> Filepro-list at lists.celestial.com
>>> Subscribe/Unsubscribe/Subscription Changes
>>> http://mailman.celestial.com/mailman/listinfo/filepro-list
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://mailman.celestial.com/pipermail/filepro-list/attachments/20120203/9e1394fe/attachment.html
> _______________________________________________
> Filepro-list mailing list
> Filepro-list at lists.celestial.com
> Subscribe/Unsubscribe/Subscription Changes
> http://mailman.celestial.com/mailman/listinfo/filepro-list
More information about the Filepro-list
mailing list