Re: New record numbering system and CALL WORKER

2018-08-28 Thread Chip Scheide via 4D_Tech
I use longings as relational keys because it is easier to track down 
when the user(s) come to me as ask why some related(?) data is not 
where it should be.
[table]ID = 1234 
is a lot easier to work with then
[table]ID = B83F47092A384821A9FABA5379C3CCC0 
when try to track data.

I don't use relational keys for user data. Requisition Numbers, Sample 
ID, etc -- BUT -- these values need to be created too. In some 
instances either the user, or the usage, dictate a 'non-broken' 
sequence of values. 

This discussion can help to design a mechanism to fill that need.

In my systems the users can define their own sequence. They can setup 
the length, whether it is purely numeric (1,2,3,4 ..) or alphanumeric 
like most state's license plates (ABC123, ABC124 etc), include 
assignment date as part of the sequence value (ABC08-28-18), include 
other fixed text in the sequence (ABC-123,ABC-124), as well as indicate 
whether the sequence is to be 'unbroken'.

At some places, it is necessary to make an assignment of these (user 
defined) IDs before other records are created, not because the other 
records are (directly) dependent on the ID, but because ID order is 
important.

scenario
mom and her offspring are being entered into the system. Both use the 
same user created sequence for their respective, user visible, IDs. 
Also each need an internal relational ID.

Mom - needs to have the user created/visible ID generated before the 
offspring, so that while the IDs do not need to be sequential (1,2,3) 
they do need to be ordinal (1, 5,6,7,8).
The offspring, in this system, are created and displayed through a 
secondary process spawned from the Mother's entry process. So... mom 
gets a relational ID, and a user defined ID on record creation, so that 
offspring are properly IDed.


On Tue, 28 Aug 2018 16:29:54 +, Benedict, Tom via 4D_Tech wrote:
> Kirk Brooks writes:
> 
>> I am surprised this thread has drawn so much discussion. It's good
>> discussion but scanning back over it a key point is that all of these
>> contortions and workarounds to preserve a number sequence are based on the
>> single design decision to use an invoice (in this case) number as a key
>> field. I'm not criticizing of course - I used to do this as well and still
>> have a few cases where that sort of design exists though nothing involving
>> number series where gaps are an issue. Not to mention I've been doing 4D
>> long enough to recall the first discussions about data normalization the
>> community had and the, erm, hesitant embrace of it by many.
> 
> Thank you Kirk for finally mentioning this. The use of 'magic 
> numbers' is tempting, but ultimately leads to lots of work to 
> support. Keys should have no meaning.
> 
> That said, the need to manage sequence numbers without gaps is 
> legitimate and an interesting subject (as this thread has 
> illustrated). Just don't use them as relational keys, or if you do, 
> make sure you do it with your eyes open.
> 
> Tom Benedict
> Optum
> 
> 
> This e-mail, including attachments, may include confidential and/or
> proprietary information, and may be used only by the person or entity
> to which it is addressed. If the reader of this e-mail is not the intended
> recipient or his or her authorized agent, the reader is hereby notified
> that any dissemination, distribution or copying of this e-mail is
> prohibited. If you have received this e-mail in error, please notify the
> sender by replying to this message and delete this e-mail immediately.
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
---
Gas is for washing parts
Alcohol is for drinkin'
Nitromethane is for racing 
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-28 Thread Bernd Fröhlich via 4D_Tech
Kirk Brooks:

> scanning back over it a key point is that all of these
> contortions and workarounds to preserve a number sequence are based on the
> single design decision to use an invoice (in this case) number as a key
> field.

Nope, the invoice number has never been a key field over here.

Greetings from Germany,
Bernd Fröhlich
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-28 Thread Benedict, Tom via 4D_Tech
Kirk Brooks writes:

>I am surprised this thread has drawn so much discussion. It's good
>discussion but scanning back over it a key point is that all of these
>contortions and workarounds to preserve a number sequence are based on the
>single design decision to use an invoice (in this case) number as a key
>field. I'm not criticizing of course - I used to do this as well and still
>have a few cases where that sort of design exists though nothing involving
>number series where gaps are an issue. Not to mention I've been doing 4D
>long enough to recall the first discussions about data normalization the
>community had and the, erm, hesitant embrace of it by many.

Thank you Kirk for finally mentioning this. The use of 'magic numbers' is 
tempting, but ultimately leads to lots of work to support. Keys should have no 
meaning.

That said, the need to manage sequence numbers without gaps is legitimate and 
an interesting subject (as this thread has illustrated). Just don't use them as 
relational keys, or if you do, make sure you do it with your eyes open.

Tom Benedict
Optum


This e-mail, including attachments, may include confidential and/or
proprietary information, and may be used only by the person or entity
to which it is addressed. If the reader of this e-mail is not the intended
recipient or his or her authorized agent, the reader is hereby notified
that any dissemination, distribution or copying of this e-mail is
prohibited. If you have received this e-mail in error, please notify the
sender by replying to this message and delete this e-mail immediately.
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-28 Thread Kirk Brooks via 4D_Tech
I am surprised this thread has drawn so much discussion. It's good
discussion but scanning back over it a key point is that all of these
contortions and workarounds to preserve a number sequence are based on the
single design decision to use an invoice (in this case) number as a key
field. I'm not criticizing of course - I used to do this as well and still
have a few cases where that sort of design exists though nothing involving
number series where gaps are an issue. Not to mention I've been doing 4D
long enough to recall the first discussions about data normalization the
community had and the, erm, hesitant embrace of it by many.

This thread illustrates a way structural decisions manifest over time. It
jumps out at me particularly now because I'm finding this especially true
working with v17 and ORDA - the coding flows so easily if the structure
supports it and can become extremely complicated when it doesn't. Something
I like about working with ORDA (which I'm misusing as a collective noun for
all the 'new' language features) is how easy it is to abstract the key
value of a record without having to work with the actual value. This makes
using UUIDs for key values much easier. I like UUIDs for key values
precisely because it eliminates any lazy kludge to use it as part of the
data - it's always part of the structure. True, looking at a column of
UUIDs is not as useful as looking at  column of longints. If I need or want
a serial record count I add it as a separate field as I do something like
invoice, order, check or inventory transaction numbers. Years ago it could
matter if a couple of extra fields were in a table (though you wouldn't
guess looking at a lot of mature 4D structures) but not so much now.

If I want a number series to remain pristine I assign the value as the very
last action prior to saving and validating the transaction. From that point
on a missing number is a management issue for users and not a programming
issue for me.

Another technique I'm using more and more for things like identifiers is
encoding longints in a base 26 alpha string (a=0, b=1, ...). I got the idea
from airline tickets. I noticed all my reservations and such have been
identified by an alpha code of a few letters. For instance, 10546789
encodes to XCBTT. Well that's a lot easier to recognize and recall and it
sorts.

-- 
Kirk Brooks
San Francisco, CA
===

*We go vote - they go home*
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-28 Thread Richard Wright via 4D_Tech
It allows you to work with related records as if they were subrecords. For 
example, you open an Invoice and start a transaction so that changes to line 
items can be rolled back if the Invoice is cancelled (something that 
automatically happened with subrecords). But then you want to drill down to 
another table related to Invoices and have those changes treated independently 
of the whether or not you cancel the Invoice. This is also how it worked with 
subrecords and was actually a very important feature of subrecords—that they 
were considered part the parent record and not independent; like structured 
data within a field.


Richard Wright
DataDomain
rwri...@datadomainsoftware.com



> Date: Mon, 27 Aug 2018 13:08:32 -0700
> From: Kirk Brooks 
> 
> Hey guys - the very issue with the record counter is sketched out in the
> discussion about Suspending Transactions:
> 
> http://doc.4d.com/4Dv16/4D/16.3/Suspending-transactions.300-3652126.en.html
> 
> 
> I had missed this - it's quite a feature.
> 
> On Mon, Aug 27, 2018 at 7:54 AM Keisuke Miyako via 4D_Tech <
> 4d_tech@lists.4d.com> wrote:
> 
>> transactions can be paused since v16
>> 
> 
> -- 
> Kirk Brooks
> San Francisco, CA
> ===



**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-28 Thread Pat Bensky via 4D_Tech
Dave,
That's fine as long as the id number isn't being used for something else
... in our case, the id numbers are used as the key field for relating data
from other tables, so this needs to be assigned when the record is created
):
Pat

On Tue, 28 Aug 2018 at 15:32, Dave Nasralla via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> Hi Bernd,
>
> I ran into a similar situation with Proposal and Project numbers. My
> decision was to not give the number out until they saved the record.
> This prevented people from using the number elsewhere (say for
> purchasing, etc) without a saved record in the system.
>
> dave
> On Tue, Aug 28, 2018 at 12:46 AM Bernd Fröhlich via 4D_Tech
> <4d_tech@lists.4d.com> wrote:
> >
> > Pat Bensky:
> >
> > > The important thing is that all record cancellations go through a
> > > *CancelRecord* method.
> > > I created a [SpareRecordNumbers] table which contains 3 fields: unique
> id,
> > > table number, and spare record number
> >
> > > As I said, it hasn't been thoroughly tested yet. So please feel free to
> > > chime in if you can see any flaws!
> >
> >
> > I have a similar system for invoice numbers.
> > Works perfectly in theory but in real life once or twice a year we got a
> missing invoice number.
> > Took me some time to figure out how it got lost (very obvious, once you
> know):
> >
> > User starts writing the invoice - gets a number through the system.
> > User goes home, leaving the invoice open.
> > User is disconnected, so the number is never returned.
> >
> > Now I look for lost number on every restart and if I find one I put it
> in the recycling bin.
> > Never lost a number since.
> >
> > Greetings from Germany,
> > Bernd Fröhlich
> > **
> > 4D Internet Users Group (4D iNUG)
> > Archive:  http://lists.4d.com/archives.html
> > Options: https://lists.4d.com/mailman/options/4d_tech
> > Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> > **
>
>
>
> --
> David Nasralla
> Clean Air Engineering
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **



-- 
*
CatBase - Top Dog in Data Publishing
tel: +44 (0) 207 118 7889
w: http://www.catbase.com
skype: pat.bensky
*
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-28 Thread Dave Nasralla via 4D_Tech
Hi Bernd,

I ran into a similar situation with Proposal and Project numbers. My
decision was to not give the number out until they saved the record.
This prevented people from using the number elsewhere (say for
purchasing, etc) without a saved record in the system.

dave
On Tue, Aug 28, 2018 at 12:46 AM Bernd Fröhlich via 4D_Tech
<4d_tech@lists.4d.com> wrote:
>
> Pat Bensky:
>
> > The important thing is that all record cancellations go through a
> > *CancelRecord* method.
> > I created a [SpareRecordNumbers] table which contains 3 fields: unique id,
> > table number, and spare record number
>
> > As I said, it hasn't been thoroughly tested yet. So please feel free to
> > chime in if you can see any flaws!
>
>
> I have a similar system for invoice numbers.
> Works perfectly in theory but in real life once or twice a year we got a 
> missing invoice number.
> Took me some time to figure out how it got lost (very obvious, once you know):
>
> User starts writing the invoice - gets a number through the system.
> User goes home, leaving the invoice open.
> User is disconnected, so the number is never returned.
>
> Now I look for lost number on every restart and if I find one I put it in the 
> recycling bin.
> Never lost a number since.
>
> Greetings from Germany,
> Bernd Fröhlich
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **



-- 
David Nasralla
Clean Air Engineering
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-28 Thread Chuck Miller via 4D_Tech
Thanks. As I said I was not sure. 

Regards

Chuck

 Chuck Miller Voice: (617) 739-0306
 Informed Solutions, Inc. Fax: (617) 232-1064   
 mailto:cjmillerinformed-solutions.com 
 Brookline, MA 02446 USA Registered 4D Developer
   Providers of 4D and Sybase connectivity
  http://www.informed-solutions.com  

This message and any attached documents contain information which may be 
confidential, subject to privilege or exempt from disclosure under applicable 
law.  These materials are intended only for the use of the intended recipient. 
If you are not the intended recipient of this transmission, you are hereby 
notified that any distribution, disclosure, printing, copying, storage, 
modification or the taking of any action in reliance upon this transmission is 
strictly prohibited.  Delivery of this message to any person other than the 
intended recipient shall not compromise or waive such confidentiality, 
privilege or exemption from disclosure as to this communication. 

> On Aug 27, 2018, at 11:02 PM, Justin Carr via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> I'm pretty sure calling SUSPEND TRANSACTION more than once without resuming 
> in between causes a run time error.
> 
> I just tried this and my changes are saved as I would expect:

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-28 Thread Pat Bensky via 4D_Tech
Good point, Bernd. I will implement that also.
Pat

On Tue, 28 Aug 2018 at 07:46, Bernd Fröhlich via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> Pat Bensky:
>
> > The important thing is that all record cancellations go through a
> > *CancelRecord* method.
> > I created a [SpareRecordNumbers] table which contains 3 fields: unique
> id,
> > table number, and spare record number
>
> > As I said, it hasn't been thoroughly tested yet. So please feel free to
> > chime in if you can see any flaws!
>
>
> I have a similar system for invoice numbers.
> Works perfectly in theory but in real life once or twice a year we got a
> missing invoice number.
> Took me some time to figure out how it got lost (very obvious, once you
> know):
>
> User starts writing the invoice - gets a number through the system.
> User goes home, leaving the invoice open.
> User is disconnected, so the number is never returned.
>
> Now I look for lost number on every restart and if I find one I put it in
> the recycling bin.
> Never lost a number since.
>
> Greetings from Germany,
> Bernd Fröhlich
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **



-- 
*
CatBase - Top Dog in Data Publishing
tel: +44 (0) 207 118 7889
w: http://www.catbase.com
skype: pat.bensky
*
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-28 Thread Bernd Fröhlich via 4D_Tech
Pat Bensky:

> The important thing is that all record cancellations go through a
> *CancelRecord* method.
> I created a [SpareRecordNumbers] table which contains 3 fields: unique id,
> table number, and spare record number

> As I said, it hasn't been thoroughly tested yet. So please feel free to
> chime in if you can see any flaws!


I have a similar system for invoice numbers.
Works perfectly in theory but in real life once or twice a year we got a 
missing invoice number.
Took me some time to figure out how it got lost (very obvious, once you know):

User starts writing the invoice - gets a number through the system.
User goes home, leaving the invoice open.
User is disconnected, so the number is never returned.

Now I look for lost number on every restart and if I find one I put it in the 
recycling bin.
Never lost a number since.

Greetings from Germany,
Bernd Fröhlich
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-27 Thread Justin Carr via 4D_Tech
On 28 Aug 2018, at 11:52 am, Chuck Miller via 4D_Tech <4d_tech@lists.4d.com> 
wrote:
> 
> It does, but remember if you already have multiple transactions, you will 
> have to keep track and may have to suspend that many times

I don't think that is true. When you SUSPEND TRANSACTION, the effective 
Transaction level goes back to 0, so no matter how many levels deep you are, 
when you call START TRANSACTION after SUSPEND TRANSACTION, the Transaction 
level function always returns 1.

I'm pretty sure calling SUSPEND TRANSACTION more than once without resuming in 
between causes a run time error.

I just tried this and my changes are saved as I would expect:

QUERY([SomeTable];[SomeTable]UniqueId=1)
[SomeTable]Value:="ABC"
SAVE RECORD([SomeTable])
UNLOAD RECORD([SomeTable])

START TRANSACTION  ---> Transaction level = 1, In transaction = True, 
Active transaction = True
START TRANSACTION  ---> Transaction level = 2, In transaction = True, 
Active transaction = True
START TRANSACTION  ---> Transaction level = 3, In transaction = True, 
Active transaction = True

SUSPEND TRANSACTION  ---> Transaction level = 3, In transaction = True, 
Active transaction = False

START TRANSACTION  ---> Transaction level = 1, In transaction = True, 
Active transaction = True

QUERY([SomeTable];[SomeTable]UniqueId=1)
[SomeTable]Value:="XYZ"
SAVE RECORD([SomeTable])
UNLOAD RECORD([SomeTable])

VALIDATE TRANSACTION---> Transaction level = 3, In transaction = True, 
Active transaction = False

RESUME TRANSACTION---> Transaction level = 3, In transaction = True, 
Active transaction = True

CANCEL TRANSACTION  ---> Transaction level = 2, In transaction = True, 
Active transaction = True
CANCEL TRANSACTION  ---> Transaction level = 1, In transaction = True, 
Active transaction = True
CANCEL TRANSACTION  ---> Transaction level = 0, In transaction = False, 
Active transaction = False


QUERY([SomeTable];[SomeTable]UniqueId=1)

// [SomeTable]Value is now "XYZ"


**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-27 Thread Chuck Miller via 4D_Tech
It does, but remember if you already have multiple transactions, you will have 
to keep track and may have to suspend that many times

Regards

Chuck

 Chuck Miller Voice: (617) 739-0306
 Informed Solutions, Inc. Fax: (617) 232-1064   
 mailto:cjmillerinformed-solutions.com 
 Brookline, MA 02446 USA Registered 4D Developer
   Providers of 4D and Sybase connectivity
  http://www.informed-solutions.com  

This message and any attached documents contain information which may be 
confidential, subject to privilege or exempt from disclosure under applicable 
law.  These materials are intended only for the use of the intended recipient. 
If you are not the intended recipient of this transmission, you are hereby 
notified that any distribution, disclosure, printing, copying, storage, 
modification or the taking of any action in reliance upon this transmission is 
strictly prohibited.  Delivery of this message to any person other than the 
intended recipient shall not compromise or waive such confidentiality, 
privilege or exemption from disclosure as to this communication. 

> On Aug 27, 2018, at 7:51 PM, Justin Carr via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> C_BOOLEAN($vB_InTransaction)
> 
> $vB_InTransaction:=Active transaction
> If ($vB_InTransaction)
>   SUSPEND TRANSACTION
>   START TRANSACTION
> End if
> 
> // allocate the new ID here
> 
> If ($vB_InTransaction)
>   VALIDATE TRANSACTION
>   RESUME TRANSACTION
> End if

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-27 Thread Keisuke Miyako via 4D_Tech
read access on a shared object triggers built-in Use/End use.
in that sense, the speed "penalty" for access is no different to write.

the speed question really boils down to what you do inside Use/End use.

for example, you might do New shared object, New shared collection.
you might do collection.query(), collection.map(), collection.reduce(), .push() 
.reverse(), concat(), etc.
each operation on a shared object has a certain cost and you are blocking 
access during that atomic operation.
so to simply measure the speed of locking or unlocking would be missing the 
point.

the same applies to read access.
while it is true that you don't need to explicitly Use/End use if you only read 
a property,
it might be necessary to Use/End use for a series of read accesses on multiple 
properties,
to make sure the set of values keep logical integrity.

2018/08/28 0:04、Keith Culotta via 4D_Tech 
<4d_tech@lists.4d.com>のメール:
Does the speed penalty apply to reading values from Storage, or just to writing 
values to Storage?



**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-27 Thread Justin Carr via 4D_Tech
On 28 Aug 2018, at 6:08 am, Kirk Brooks via 4D_Tech <4d_tech@lists.4d.com> 
wrote:
> 
> Hey guys - the very issue with the record counter is sketched out in the
> discussion about Suspending Transactions:
> 
> http://doc.4d.com/4Dv16/4D/16.3/Suspending-transactions.300-3652126.en.html
> 
> 
> I had missed this - it's quite a feature.

It is and it works well. One gotcha is if you are potentially allocating more 
than 1 ID for the same table within the transaction, you must allocate the new 
IDs within their own transaction, otherwise you just keep getting the same 
(initial) value returned for the next ID,

i.e. in the method that is allocating your new IDs you need to do something 
like:

C_BOOLEAN($vB_InTransaction)

$vB_InTransaction:=Active transaction
If ($vB_InTransaction)
SUSPEND TRANSACTION
START TRANSACTION
End if

// allocate the new ID here

If ($vB_InTransaction)
VALIDATE TRANSACTION
RESUME TRANSACTION
End if

This requires having the "Allow Nested Transactions" compatibility checkbox 
ticked.
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-27 Thread Pat Bensky via 4D_Tech
Hi guys,
Thanks for all your suggestions and  helpful info.
After considering all these options, I've come up with a simple solution
that seems to work perfectly well, although it hasn't yet been tested
comprehensively.
The important thing is that all record cancellations go through a
*CancelRecord* method.
I created a [SpareRecordNumbers] table which contains 3 fields: unique id,
table number, and spare record number.

When a new record is created, the *IDNums* method runs:
=

*C_LONGINT*($found;$iTableNumber;$iFieldNumber;$newnumber)

*RESOLVE POINTER*(*$1*;$var;$iTableNumber;$iFieldNumber) // $1 is a pointer
to the record number field

  // first check to see if there are any spare recordnumbers to be used up

$newnumber:=-1

$found:=*Find in field*([SpareRecordNumbers]TableNumber;$iTableNumber)

*While* (($found>-1) & ($newnumber=-1))

*If* (*Find in field*([SpareRecordNumbers]TableNumber;$iTableNumber)>-1)

$found:=*Find in field*([SpareRecordNumbers]TableNumber;$iTableNumber)

*GOTO RECORD*([SpareRecordNumbers];$found)

$newnumber:=[SpareRecordNumbers]RecordNumber

*DELETE RECORD*([SpareRecordNumbers])

  // just to make sure that another process hasn't beaten us to it ...
unlikely but let's be 100% sure

*If* (*Find in field*(*$1*->;$newnumber)>-1)

$newnumber:=-1

$found:=-1

*Else*

*$1*->:=$newnumber

*End if*

*Else*

$found:=0

*End if*

*End while*

*If* (*$1*->=0)

*$1*->:=*Sequence number*(*Table*($iTableNumber)->)

*End if*
=

When a new record is cancelled, the *CancelRecord* method is called:
=

*// first do any necessary checks, eg get the user to confirm that they
really do want to cancel*

*// if the cancel is to proceed, $cancel:=True*

*If* ($cancel)

$RecordNumber:=*Field*(iTablenumber;1)-> // all of our data tables have the
record number in field 1

*CANCEL TRANSACTION*

*If* (yNewRecord))  // yNewRecord flag was set when the record was created

*CREATE RECORD*([SpareRecordNumbers])

[SpareRecordNumbers]RecordNumber:=$RecordNumber

[SpareRecordNumbers]TableNumber:=iTableNumber

*SAVE RECORD*([SpareRecordNumbers])

*UNLOAD RECORD*([SpareRecordNumbers])

*End if*
End if
=
This doesn't require any locked record checking, copying of flags or
variables, or any of that process-slowing activity. If all the data in a
table is deleted, the Sequence Number is reset to 0.
 It's lightning fast. I imported 180,000 records using the old method, and
it took almost two hours. Using this method it took less than 10 minutes!
That will make our clients happy :)

As I said, it hasn't been thoroughly tested yet. So please feel free to
chime in if you can see any flaws!

Cheers
Pat

On Mon, 27 Aug 2018 at 21:08, Kirk Brooks via 4D_Tech <4d_tech@lists.4d.com>
wrote:

> Hey guys - the very issue with the record counter is sketched out in the
> discussion about Suspending Transactions:
>
> http://doc.4d.com/4Dv16/4D/16.3/Suspending-transactions.300-3652126.en.html
>
>
> I had missed this - it's quite a feature.
>
> On Mon, Aug 27, 2018 at 7:54 AM Keisuke Miyako via 4D_Tech <
> 4d_tech@lists.4d.com> wrote:
>
> > transactions can be paused since v16
> >
>
> --
> Kirk Brooks
> San Francisco, CA
> ===
>
> *We go vote - they go home*
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **



-- 
*
CatBase - Top Dog in Data Publishing
tel: +44 (0) 207 118 7889
w: http://www.catbase.com
skype: pat.bensky
*
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-27 Thread Kirk Brooks via 4D_Tech
Hey guys - the very issue with the record counter is sketched out in the
discussion about Suspending Transactions:

http://doc.4d.com/4Dv16/4D/16.3/Suspending-transactions.300-3652126.en.html


I had missed this - it's quite a feature.

On Mon, Aug 27, 2018 at 7:54 AM Keisuke Miyako via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> transactions can be paused since v16
>

-- 
Kirk Brooks
San Francisco, CA
===

*We go vote - they go home*
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-27 Thread Tim Nevels via 4D_Tech
On Aug 27, 2018, at 2:00 PM, John DeSoi wrote:

> I don't know. In some simple tests without any contention from multiple 
> processes, both reading and writing took 0 ms. 
> 
> I did not know Storage was slow until this thread came up. I did not see that 
> in the documentation, maybe only something you learn about if you go to the 
> conference. Without some published benchmarks, it sounds like 4D folklore at 
> this point.

We have to take Miyako’s word for this. He’s the one that says storage is 
“slow”. But as we all know, “slow” is a relative term. What’s slow to Miyako 
may be plenty fast for another.

After more thought about this topic, I’ve decided to do so real world testing 
and benchmarking to see what kind of speeds we are talking about. That’s the 
only real way to know which is the fastest way and which is the slowest way.

I’m still formalizing exactly what I will test and how I will test. 

I’ll test the traditional table based sequence number system. We all know how 
that works. I’ll make a super basic one so I can do some speed tests. I’ll also 
test the Storage sequence number system that was your initial idea and 
implement they way I outlined in my previous email. 

I’ll want to test this in the most harsh environment I can. So it will be done 
in client/server so we have network I/O to deal with. 

I’ll also want to have many processes requesting sequence numbers at the same 
time to introduce record locking and waiting for the table based system, and 
the built in Storage locking mechanism which I assume also has a built in 
queuing systems to stack up calls and handle them in FIFO order. 

So maybe I’ll start up 4D Server and 4D Client and then on 4D Client launch say 
50 processes. Each process will loop say 100,000 times creating sequence 
numbers. Just do it brute force hard with no delays.  I’ll add some timing code 
and we’ll see who’s the winner. 

And I’ll also see if I can create any deadlock situation that some have pointed 
out could be an issue when using shared storage.

Anyone have other ideas on how to set up a good test case, let me know. 

Tim

*
Tim Nevels
Innovative Solutions
785-749-3444
timnev...@mac.com
*

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-27 Thread John DeSoi via 4D_Tech
I don't know. In some simple tests without any contention from multiple 
processes, both reading and writing took 0 ms. 

I did not know Storage was slow until this thread came up. I did not see that 
in the documentation, maybe only something you learn about if you go to the 
conference. Without some published benchmarks, it sounds like 4D folklore at 
this point.

What seems *really* slow to me is CALL FORM. I'm seeing about 100ms between 
CALL FORM and the time the method starts executing in the form process (not 
called from the same process as the form window). 

John DeSoi, Ph.D.


> On Aug 27, 2018, at 10:04 AM, Keith Culotta via 4D_Tech 
> <4d_tech@lists.4d.com> wrote:
> 
> Does the speed penalty apply to reading values from Storage, or just to 
> writing values to Storage?
> 
> 
> 
>> On Aug 26, 2018, at 8:57 AM, John DeSoi via 4D_Tech <4d_tech@lists.4d.com> 
>> wrote:
>> 
>> Storage is the best option for interprocess communications if you want to 
>> use preemptive processes.

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-27 Thread Chip Scheide via 4D_Tech
yes  :)

it would simplify the code to create a new sequence value,
rather then having to pass the needed info out of the current 
transaction/process into a new process, and then transfer it back.

I'll keep this in mind for when I finally get to v16+  :)


On Mon, 27 Aug 2018 14:53:13 +, Keisuke Miyako via 4D_Tech wrote:
> transactions can be paused since v16
> 
> would that help?
> 
> http://doc.4d.com/4Dv16/4D/16.3/SUSPEND-TRANSACTION.301-3652123.en.html
> 
>> 2018/08/27 23:46、Chip Scheide via 4D_Tech <4d_tech@lists.4d.com>のメール:
>> working from inside a transaction requires (as far as I can figure out)
>> stepping outside the transaction process and generating the value(s)
>> then passing the value(s) back into the transaction.
> 
> 
> 
> 
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
---
Gas is for washing parts
Alcohol is for drinkin'
Nitromethane is for racing 
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-27 Thread Keith Culotta via 4D_Tech
Does the speed penalty apply to reading values from Storage, or just to writing 
values to Storage?

Thanks,
Keith - CDI

> On Aug 26, 2018, at 8:57 AM, John DeSoi via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> Storage is the best option for interprocess communications if you want to use 
> preemptive processes.

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-27 Thread Keisuke Miyako via 4D_Tech
transactions can be paused since v16

would that help?

http://doc.4d.com/4Dv16/4D/16.3/SUSPEND-TRANSACTION.301-3652123.en.html

> 2018/08/27 23:46、Chip Scheide via 4D_Tech <4d_tech@lists.4d.com>のメール:
> working from inside a transaction requires (as far as I can figure out)
> stepping outside the transaction process and generating the value(s)
> then passing the value(s) back into the transaction.




**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-27 Thread Chip Scheide via 4D_Tech
there is  the catch :)

working from inside a transaction requires (as far as I can figure out)
stepping outside the transaction process and generating the value(s) 
then passing the value(s) back into the transaction.

Returning requires the same thing-in reverse.

Chip

On Sat, 25 Aug 2018 08:20:37 -0700, Kirk Brooks via 4D_Tech wrote:
> 
> This approach let's 4D handle the record locking and request que and as
> long as you don't call it within a transaction just blissfully works.
---
Gas is for washing parts
Alcohol is for drinkin'
Nitromethane is for racing 
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-27 Thread Jody Bevan via 4D_Tech
Chuck:

That is exactly what we do for our code. Has served us well for all our sites. 
We can have 200+ current users on the system, importing records from labs (thus 
needing lots of counters quickly), and never noticed a problem with the system. 
For those counters we do not wanted to have one go missing we have a BLOB to 
hold for use next time. 

The reason we use our own counters rather than 4D’s auto assigned number is 
that we are often importing records from previous systems. We can easily roll 
back the counters when and where needed. We also like to put a good block of 
unused numbers between what was imported and what has been created by the 
system. That way looking at the unique numbers the Admins and us can know 
quickly where the record came from. This is specifically important when the 
system is first used.

Jody

Jody Bevan
Developer

Argus Productions Inc. 
+1 587-487-6120



> On Aug 26, 2018, at 7:37 PM, Chuck Miller via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> OK i have done this many times with a table. You have multiple records in the 
> table, one for each id you need. I usually make that records key name 
> ([table]field). If you have to keep track of released numbers, you can add a 
> blob field. I would not be adding object fields as you can not access using 
> SQL. I also have never figured out why you need a semaphore. I think in olden 
> days (v1, 1.5 etc) you needed to slow this down to some extent.
> 
> You have be cognizant of whether you are inside a transaction or not. these 
> queries and updates are blazing since you always have relatively few records 
> in the table. If you have 500 keys you will have 500 records. Run method. 
> Query for key. Load record if locked wait retry load. See if you have any 
> returned numbers otherwise set next number, save record, unload record return 
> it.
> 
> Pat when you say you need to use all numbers what happens in the following 
> scenario. You create a record and it gets ID 100, for the next months you 
> create 10,000 more records. You then decide to delete 1000, would you reuse 
> that number. or only reuse if cancelling out of creation. If the later why 
> not simply assign right before you save
> 
> Regards
> 
> 
> Chuck
> 
> 

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-26 Thread Chuck Miller via 4D_Tech
OK i have done this many times with a table. You have multiple records in the 
table, one for each id you need. I usually make that records key name 
([table]field). If you have to keep track of released numbers, you can add a 
blob field. I would not be adding object fields as you can not access using 
SQL. I also have never figured out why you need a semaphore. I think in olden 
days (v1, 1.5 etc) you needed to slow this down to some extent.

You have be cognizant of whether you are inside a transaction or not. these 
queries and updates are blazing since you always have relatively few records in 
the table. If you have 500 keys you will have 500 records. Run method. Query 
for key. Load record if locked wait retry load. See if you have any returned 
numbers otherwise set next number, save record, unload record return it.

Pat when you say you need to use all numbers what happens in the following 
scenario. You create a record and it gets ID 100, for the next months you 
create 10,000 more records. You then decide to delete 1000, would you reuse 
that number. or only reuse if cancelling out of creation. If the later why not 
simply assign right before you save

Regards


Chuck

 Chuck Miller Voice: (617) 739-0306
 Informed Solutions, Inc. Fax: (617) 232-1064   
 mailto:cjmillerinformed-solutions.com 
 Brookline, MA 02446 USA Registered 4D Developer
   Providers of 4D and Sybase connectivity
  http://www.informed-solutions.com  

This message and any attached documents contain information which may be 
confidential, subject to privilege or exempt from disclosure under applicable 
law.  These materials are intended only for the use of the intended recipient. 
If you are not the intended recipient of this transmission, you are hereby 
notified that any distribution, disclosure, printing, copying, storage, 
modification or the taking of any action in reliance upon this transmission is 
strictly prohibited.  Delivery of this message to any person other than the 
intended recipient shall not compromise or waive such confidentiality, 
privilege or exemption from disclosure as to this communication. 

> On Aug 25, 2018, at 10:10 AM, Pat Bensky via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> Using v17 ...
> 
> I'm looking at ways to update our ancient record numbering system, and I
> think I should be able to do it efficiently with CALL WORKER, but having a
> bit of trouble getting my head around  it.
> 
> The record numbers are like invoice numbers: each must be unique, and we
> don't want to have any gaps in the numbering sequence. So we need to keep
> track of any record numbers that are created and then abandoned (eg if a
> user creates a new record and then cancels it).
> The old system works well but it uses semaphores and SET/GET PROCESS
> VARIABLE and DELAY PROCESS. I isn't very efficient, especially when a large
> number of records are being imported and each one needs a new record number.
> Record numbers must be assigned synchronously - processing must not
> continue until the new record number has been assigned. Also, this
> frequently needs to be done in a context where there is no active form, so
> CALL FORM won't work.
> 
> As I see it, we'll need to call a worker, which calls the worker that
> assigns the record number.
> The first worker has to wait until the second one has created the new
> number.
> Then the original method, that called the first worker, must wait until the
> first worker  gets the new number. It seems that this won't be much better
> than the old method.
> 
> Am I completely barking up the wrong tree? Is this not an appropriate use
> for workers? Or have I misunderstood something?
> 
> Pat

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-26 Thread John DeSoi via 4D_Tech
Storage is the best option for interprocess communications if you want to use 
preemptive processes. I have not done any real benchmarking but I have not 
noticed that anything seems slow. By setting up return values on a per-process 
basis you can avoid locking contention on storage. 

For example, I have a wrapper for CALL FORM which allows a return value. I'm 
using this to provide services to non-GUI (possibly preemptive) processes that 
need to call form related features. One place I'm using this is to call a 
Javascript auto-layout library (http://ijzerenhein.github.io/autolayout.js) to 
generate a form layout from a constraint specification. This approach allows me 
to load the layout library in one (hidden) process and use it from any other 
process. The call looks like this:


//Internal method to execute the auto layout request in the web/javascript 
process.

  //$0 - Object with layout specification.
  //$1 - Collection of VFL specification strings.
  //$2 - View with.
  //$3 - View height.
  //$4 - (flag) Layout window, provided by this method only.


C_OBJECT($0;$oResult)
C_COLLECTION($1;$cSpec)
C_LONGINT($2;$width;$3;$height)
C_LONGINT($4;$window)

$cSpec:=$1
$width:=$2
$height:=$3

If (Count parameters<4)
$window:=FD_Layout_window 
PM_CALL_IN_FORM_WINDOW (Current method 
name;->$oResult;0;->$cSpec;->$width;->$height;->$window)
Else 
WA EXECUTE JAVASCRIPT 
FUNCTION(fd_waLayout;"autoLayoutD5";$oResult;$cSpec;$width;$height)
End if 

$0:=$oResult


John DeSoi, Ph.D.



> On Aug 25, 2018, at 4:44 PM, Tim Nevels via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> But lets explore other possibilities. What could “Storage” be use for in 
> other cases? Is it a good use of “Storage”?

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-26 Thread Keisuke Miyako via 4D_Tech
I totally agree with Christian, in fact,
the point (slow, should be avoided if possible) was right there in the Summit 
keynote.

on the point of "slow"
of course it is a relative thing and perhaps not a big deal depending on the 
context,
but you only have to run code with Storage and the speed difference is quite 
palpable.
it is not a 4D specific phenomena, it is intrinsic to how blocking based on 
mutex works.

on the point of "good coding"
4D forces you to forfeit exclusive access with the "Use/End use" code block,
so unless you implicitly use storage in a stacked subroutine (super bad idea),
it is hard to violate the FILO tule unintentionally.

a more subtle gotcha is to make the mistake of
using objects and collections as if they were values, not references.
it's not limited to storage, but it can really bite you when you make the 
mistake with storage.

2018/08/26 17:26、Tim Nevels via 4D_Tech 
<4d_tech@lists.4d.com>のメール:

Humm... interesting comment. Why do you say Storage is slower and can produce 
deadlocks? Tell us why you believe this.



**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-26 Thread Tim Nevels via 4D_Tech
Humm... interesting comment. Why do you say Storage is slower and can produce 
deadlocks? Tell us why you believe this. 

Was my example an example of “not well programmed”? Be honest. Give me real, 
solid,  constructive criticism. This is a forum for exchanging ideas and 
learning. I’ve been wrong many times in the past. I may be wrong now. I am 
interested in learning and improving and understanding more. 

Please elaborate on why “you should avoid Storage where you can”.  

I thought Storage was a wonderful new 4D feature. But you say it should be 
avoided. Why?

Tim

Sent from my iPad

> On Aug 26, 2018, at 3:03 AM, Christian Sakowski 
>  wrote:
> 
> Hopefully not. You should avoid Storage where you can. They are slower and 
> can produce (if not well programmed) dead locks.
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-26 Thread Christian Sakowski via 4D_Tech
> But lets explore other possibilities.

Hopefully not. You should avoid Storage where you can. They are slower and can 
produce (if not well programmed) dead locks.
--

Grüße/Regards,
[heubach-media] | Christian Sakowski
christian.sakow...@heubach-media.de
iChat/AIM: SakowskiF
Tel: +49/(0)40/52 10 59-23



> Am 25.08.2018 um 23:44 schrieb Tim Nevels via 4D_Tech <4d_tech@lists.4d.com>:
> 
> On Aug 25, 2018, at 4:33 PM, Christian Sakowski 
>  wrote:
> 
>> i mainly use Storage as „constants“. I store global attributes and user 
>> specific options and access rights. Those are in fact mostly read only.
> 
> Hi Christian,
> 
> And that is a great use of “Storage”. I’ll be doing the same thing in new 
> databases I create.
> 
> But lets explore other possibilities. What could “Storage” be use for in 
> other cases? Is it a good use of “Storage”?
> 
> One of the great things about 4D is that features designed and intended to be 
> use for one situation turn out to be very useful in other situations. And I 
> love the “big brains” on the iNUG exposing these new uses.
> 
> Tim
> 
> *
> Tim Nevels
> Innovative Solutions
> 785-749-3444
> timnev...@mac.com
> *
> 
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **


--
heubach media
Osterfeldstr. 12-14 | Haus 1 | Eingang Nord
22529 Hamburg
tel: 040 / 52 10 59 - 10 | fax: -99
mail: i...@heubach-media.de
home: www.heubach-media.de
Geschäftsführer|CEO: Matthias Heubach

Mieten Sie Ihre Computer, iPads & Drucker für Ihre Events bei:
http://www.milo-rental.com

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen.
Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten 
haben,
informieren Sie bitte sofort den Absender und vernichten Sie diese Mail.
Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht 
gestattet.
 
This e-mail may contain confidential and/or privileged information.
If you are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail.
Any unauthorized copying, disclosure or distribution of the
material in this e-mail is strictly forbidden.
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-25 Thread John DeSoi via 4D_Tech
Hi Pat,

Set the method property to "Execute on Server".

This shared object/collection could also have a collection of numbers that need 
to be reused if you require that there are no missing numbers in your sequence. 

Of course, you'll have to get the database involved at some level to handle 
startup and shutdown and the case where the server crashed without writing the 
last sequence number used.

John DeSoi, Ph.D.


> On Aug 25, 2018, at 10:21 AM, Pat Bensky via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> Thanks John.
> But how would that work in a multi-user setting? Whatever method is used
> for assigning the new numbers, it must run on the server, otherwise we're
> back to the problem of using semaphores, checking record locking, etc.
> Also I should point out that there could be a large number of tables for
> which the record numbering system needs to be used. We have a RecordNumbers
> table which has one record for each table that requires this function. so
> we must have ONE process that accesses and updates that table.
> PB

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-25 Thread Tim Nevels via 4D_Tech
On Aug 25, 2018, at 4:33 PM, Christian Sakowski 
 wrote:

> i mainly use Storage as „constants“. I store global attributes and user 
> specific options and access rights. Those are in fact mostly read only.

Hi Christian,

And that is a great use of “Storage”. I’ll be doing the same thing in new 
databases I create.

But lets explore other possibilities. What could “Storage” be use for in other 
cases? Is it a good use of “Storage”?

One of the great things about 4D is that features designed and intended to be 
use for one situation turn out to be very useful in other situations. And I 
love the “big brains” on the iNUG exposing these new uses.

Tim

*
Tim Nevels
Innovative Solutions
785-749-3444
timnev...@mac.com
*

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-25 Thread Christian Sakowski via 4D_Tech
Tim,

i mainly use Storage as „constants“. I store global attributes and user 
specific options and access rights. Those are in fact mostly read only.

--
Grüße/Regards,
[heubach-media] | Christian Sakowski
christian.sakow...@heubach-media.de
iChat/AIM: SakowskiF
Tel: +49/(0)40/52 10 59-23



> Am 25.08.2018 um 22:57 schrieb Tim Nevels :
> 
> On Aug 25, 2018, at 2:25 PM, Christian Sakowski 
>  wrote:
> 
>> This is not necessary. For just reading you don’t need to use „use“.
>> For generating sequence numbers, you have to use „auto increment“. Nothing 
>> else.
>> For invoice numbers, you now can save the number to the database within 
>> transactions with SUSPEND/RESUME TRANSACTION (of course, locking and waiting 
>> if necessary…)
> 
> Hi Christian,
> 
> You are correct, it is not necessary to “Use” a shared object if you are only 
> going to read it. I’m still getting used to this new 4D feature. Thanks for 
> reminding me of that.
> 
> Regarding sequence numbers and using the “auto increment” or the “Sequence 
> number” command, I always use that. I agree it’s the best, period. 
> 
> But this is really a discussion of how one might use shared storage. Rightly 
> or wrongly. Trying to understand how to use this new 4D feature and gather 
> some ideas on possible ways of using it. I’m still learning and trying to 
> understand it. 
> 
> Tim
> 
> *
> Tim Nevels
> Innovative Solutions
> 785-749-3444
> timnev...@mac.com
> *
> 


--
heubach media
Osterfeldstr. 12-14 | Haus 1 | Eingang Nord
22529 Hamburg
tel: 040 / 52 10 59 - 10 | fax: -99
mail: i...@heubach-media.de
home: www.heubach-media.de
Geschäftsführer|CEO: Matthias Heubach

Mieten Sie Ihre Computer, iPads & Drucker für Ihre Events bei:
http://www.milo-rental.com

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen.
Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten 
haben,
informieren Sie bitte sofort den Absender und vernichten Sie diese Mail.
Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht 
gestattet.
 
This e-mail may contain confidential and/or privileged information.
If you are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail.
Any unauthorized copying, disclosure or distribution of the
material in this e-mail is strictly forbidden.
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-25 Thread Tim Nevels via 4D_Tech
On Aug 25, 2018, at 2:25 PM, Christian Sakowski 
 wrote:

> This is not necessary. For just reading you don’t need to use „use“.
> For generating sequence numbers, you have to use „auto increment“. Nothing 
> else.
> For invoice numbers, you now can save the number to the database within 
> transactions with SUSPEND/RESUME TRANSACTION (of course, locking and waiting 
> if necessary…)

Hi Christian,

You are correct, it is not necessary to “Use” a shared object if you are only 
going to read it. I’m still getting used to this new 4D feature. Thanks for 
reminding me of that.

Regarding sequence numbers and using the “auto increment” or the “Sequence 
number” command, I always use that. I agree it’s the best, period. 

But this is really a discussion of how one might use shared storage. Rightly or 
wrongly. Trying to understand how to use this new 4D feature and gather some 
ideas on possible ways of using it. I’m still learning and trying to understand 
it. 

Tim

*
Tim Nevels
Innovative Solutions
785-749-3444
timnev...@mac.com
*

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-25 Thread Christian Sakowski via 4D_Tech
> Use (Storage)
>   [MyNextNumber]NextNumber:=Storage.myNextNumber
> End use

This is not necessary. For just reading you don’t need to use „use“.
For generating sequence numbers, you have to use „auto increment“. Nothing else.
For invoice numbers, you now can save the number to the database within 
transactions with SUSPEND/RESUME TRANSACTION (of course, locking and waiting if 
necessary…)
--

Grüße/Regards,
[heubach-media] | Christian Sakowski
christian.sakow...@heubach-media.de
iChat/AIM: SakowskiF
Tel: +49/(0)40/52 10 59-23



> Am 25.08.2018 um 21:10 schrieb Tim Nevels via 4D_Tech <4d_tech@lists.4d.com>:
> 
> On Aug 25, 2018, at 10:33 AM, Pat Bensky wrote:
> 
>> Thanks John.
>> But how would that work in a multi-user setting? Whatever method is used
>> for assigning the new numbers, it must run on the server, otherwise we're
>> back to the problem of using semaphores, checking record locking, etc.
>> Also I should point out that there could be a large number of tables for
>> which the record numbering system needs to be used. We have a RecordNumbers
>> table which has one record for each table that requires this function. so
>> we must have ONE process that accesses and updates that table.
> 
> I like John’s idea of using the new shared object “Storage”. This has a 
> built-in, super efficient, locking mechanism using the “Use/End Use” system. 
> My first thought were that this could be the ultimate “next sequence number” 
> system if you have already used the “Sequence number” attribute for a table 
> (which is already the ultimate “next sequence number” system for a table in 
> terms of speed and reliability in a multi-user and transactional system. 
> 
> So here is an idea for a basic sequence number system based on shared 
> “Storage” object. The goals are:
> 
> - Make it as fast as possible
> - Make it work on single-user and client/server with the least amount of code
> - Use built-in 4D features wherever you can
> - Works anywhere and everywhere, no special cases to deal with
>   - any process cooperative or preemptive
>   - in triggers
>   - inside or outside transactions
>   - from a form or from a process with no UI
> - Don’t care about “lost numbers” (holes in the sequence numbers are OK)
> 
> Sorry Pat, you’ll have to complicate the system to make it work for your 
> specific needs, but that should be doable with a more complex storage object. 
> I just wanted to present the concept I have here in the simplest terms for 
> easy digestion.
> 
> 1. Initialization - this needs to be done once for a database application. If 
> you are running single-user, do this in the “On Startup” method. If you are 
> running client/server do this in “On Server Startup”
> 
> Use (Storage)
>   Storage.myNextNumber:=1
> End use
> 
> 2. GetNextNumber - this is a method that will return the next number from the 
> shared storage. Set the method property for “Execute on server”. This will 
> make it work in single-user or client/server with no code changes. 
> 
> // Method: GetNextNumber
> 
> C_LONGINT($0)
> 
> Use (Storage)
>   $0:=Storage.myNextNumber
>   Storage.myNextNumber:=$0+1 // increment sequence
> End use
> 
> 3. Permanent storage of the next number - If you want this to maintain it’s 
> value across launches of the application, use a table in the database. So in 
> the “initialization” part above instead of setting "Storage.myNextNumber:=1” 
> you would query a table and get the next number value from a field in a 
> record. When the database quits you update that value so it is available for 
> the next “On Startup” or “On Server Startup” You would put this code in the 
> “On Exit” or “On Server Shutdown”.
> 
> 4. What if my database crashes and my code does not get a chance to do a 
> proper save of the next number to the database? A valid consideration and one 
> I think should be addressed. We all know that 4D will crash sometimes, so 
> best to be prepared and handle it as best we can. 
> 
> How about in the “initialization” part you also start a new process whose job 
> is to save the next number from the storage object to a database record. Have 
> this process run as often as you are comfortable with. If you are journaling 
> your data file — and you should be — the record update will be in the journal 
> file so that if 4D crashes, on the next startup it will integrate the change 
> into the database and you’ve not lost anything. 
> 
> You could bypass the whole shared storage approach and just do database 
> operations on records, but I would speculate that using shared storage is 
> just a tad bit faster than doing a query, wait for record to be unlocked, 
> increment, save record, unload record operation. Might not be, I’ve not done 
> any testing to see which is faster. Just seems like less overhead to not call 
> the database engine every time you need a next number. But it does introduce 
> a "cache within a cache” situation. And the potential risk of losing that 
> last sequence 

Re: New record numbering system and CALL WORKER

2018-08-25 Thread Tim Nevels via 4D_Tech
On Aug 25, 2018, at 10:33 AM, Pat Bensky wrote:

> Thanks John.
> But how would that work in a multi-user setting? Whatever method is used
> for assigning the new numbers, it must run on the server, otherwise we're
> back to the problem of using semaphores, checking record locking, etc.
> Also I should point out that there could be a large number of tables for
> which the record numbering system needs to be used. We have a RecordNumbers
> table which has one record for each table that requires this function. so
> we must have ONE process that accesses and updates that table.

I like John’s idea of using the new shared object “Storage”. This has a 
built-in, super efficient, locking mechanism using the “Use/End Use” system. My 
first thought were that this could be the ultimate “next sequence number” 
system if you have already used the “Sequence number” attribute for a table 
(which is already the ultimate “next sequence number” system for a table in 
terms of speed and reliability in a multi-user and transactional system. 

So here is an idea for a basic sequence number system based on shared “Storage” 
object. The goals are:

- Make it as fast as possible
- Make it work on single-user and client/server with the least amount of code
- Use built-in 4D features wherever you can
- Works anywhere and everywhere, no special cases to deal with
   - any process cooperative or preemptive
   - in triggers
   - inside or outside transactions
   - from a form or from a process with no UI
- Don’t care about “lost numbers” (holes in the sequence numbers are OK)

Sorry Pat, you’ll have to complicate the system to make it work for your 
specific needs, but that should be doable with a more complex storage object. I 
just wanted to present the concept I have here in the simplest terms for easy 
digestion.

1. Initialization - this needs to be done once for a database application. If 
you are running single-user, do this in the “On Startup” method. If you are 
running client/server do this in “On Server Startup”

Use (Storage)
   Storage.myNextNumber:=1
End use

2. GetNextNumber - this is a method that will return the next number from the 
shared storage. Set the method property for “Execute on server”. This will make 
it work in single-user or client/server with no code changes. 

// Method: GetNextNumber

C_LONGINT($0)

Use (Storage)
   $0:=Storage.myNextNumber
   Storage.myNextNumber:=$0+1 // increment sequence
End use

3. Permanent storage of the next number - If you want this to maintain it’s 
value across launches of the application, use a table in the database. So in 
the “initialization” part above instead of setting "Storage.myNextNumber:=1” 
you would query a table and get the next number value from a field in a record. 
When the database quits you update that value so it is available for the next 
“On Startup” or “On Server Startup” You would put this code in the “On Exit” or 
“On Server Shutdown”.

4. What if my database crashes and my code does not get a chance to do a proper 
save of the next number to the database? A valid consideration and one I think 
should be addressed. We all know that 4D will crash sometimes, so best to be 
prepared and handle it as best we can. 

How about in the “initialization” part you also start a new process whose job 
is to save the next number from the storage object to a database record. Have 
this process run as often as you are comfortable with. If you are journaling 
your data file — and you should be — the record update will be in the journal 
file so that if 4D crashes, on the next startup it will integrate the change 
into the database and you’ve not lost anything. 

You could bypass the whole shared storage approach and just do database 
operations on records, but I would speculate that using shared storage is just 
a tad bit faster than doing a query, wait for record to be unlocked, increment, 
save record, unload record operation. Might not be, I’ve not done any testing 
to see which is faster. Just seems like less overhead to not call the database 
engine every time you need a next number. But it does introduce a "cache within 
a cache” situation. And the potential risk of losing that last sequence number 
before your process “flushes” it to the database cache and writes to the 
journal file. But one of my above stated goals was maximum speed, so I think 
this will buy you a tiny bit of extra speed. 

Here is some example code for saving the next number storage value to the 
database. Put this in a method that is called in either “On Startup” or “On 
Server Startup”. To make is super simple, [MyNextNumber] table only contains 1 
record and 1 field. And no other process is ever allowed to do any write 
operations to table [MyNextNumber]. The only process to modify it is 
“SaveMyNextNumber” then you don’t have to worry about possible record locking 
issues.

$processID_l:=New Process(“SaveMyNextNumber”;0)

// Method: SaveMyNextNumber

ALL RECORDS([MyNextNumber]) 
if 

Re: New record numbering system and CALL WORKER

2018-08-25 Thread Kirk Brooks via 4D_Tech
Pat,

On Sat, Aug 25, 2018 at 8:25 AM Pat Bensky via 4D_Tech <4d_tech@lists.4d.com>
wrote:

> What you say makes sense, but the record number as key field is so integral
> to the way the program works, it would be a nightmare to try and change it
>

Understood. But this approach still works, you just have more values in the
'returned' collection. Of course I'm assuming you're not going to have
hundreds of returned counters. That could make a difference.

And both methods can be run EOS to speed up the multiuser environment.

Try it out. I know that years ago that much querying and checking record
locking would have been slow. It's not now.

-- 
Kirk Brooks
San Francisco, CA
===

*We go vote - they go home*
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-25 Thread Pat Bensky via 4D_Tech
Hi Kirk,
What you say makes sense, but the record number as key field is so integral
to the way the program works, it would be a nightmare to try and change it
:) If I was starting a project from scratch, that would be a different
story.
Pat

On Sat, 25 Aug 2018 at 16:20, Kirk Brooks via 4D_Tech <4d_tech@lists.4d.com>
wrote:

> Pat,
> A couple of thoughts since it sounds like you're refactoring your code (all
> pseudo code, v17):
> 1) don't use this number as a key field.
>
> 2) The counter record:
>
> [COUNTER]
>
> ID
>
> name  - optional but a good idea
>
> _data  - object field: { nextNumber: 0, returned: []}
>
> 3) Counter_get_next(text) -> long
>
> $1 is name of counter series
>
> Put [COUNTER] in read/write
>
> Query for record
>
> Wait until record is unlocked
>
> `
>
> if(COUNTER._data.returned.length>0)` use the first one here
>
> $0:=
> COUNTER._data.returned.
> shift
> ()
>
> else
>
> $0:=
> COUNTER._data.nextNumber
>
> COUNTER._data.nextNumber:=
> COUNTER._data.nextNumber
> +1
>
> end if
>
> SAVE RECORD
>
> UNLOAD RECORD
>
>
> 4) Counter_save_unused (text; long)
>
> Same idea except you just push $2 onto 'returned'. You could add a sort
> command to make sure the smallest returned value is on top if that's an
> issue.
>
>
> Several years ago I stopped using invoice or PO numbers (or phone numbers
> or SSNs or any data value) as key fields. This greatly simplifies the issue
> you may have had about the 'unused' numbers that come up when data entry is
> canceled. If you're not using that number as a key field you don't need to
> assign it until the transaction completes. But if you've got some other
> situations that result in 'returned' numbers it's not big deal.
>
> This approach let's 4D handle the record locking and request que and as
> long as you don't call it within a transaction just blissfully works.
>
>
>
> On Sat, Aug 25, 2018 at 7:11 AM Pat Bensky via 4D_Tech <
> 4d_tech@lists.4d.com>
> wrote:
>
> > Using v17 ...
> >
> > I'm looking at ways to update our ancient record numbering system, and I
> > think I should be able to do it efficiently with CALL WORKER, but having
> a
> > bit of trouble getting my head around  it.
> >
> > The record numbers are like invoice numbers: each must be unique, and we
> > don't want to have any gaps in the numbering sequence. So we need to keep
> > track of any record numbers that are created and then abandoned (eg if a
> > user creates a new record and then cancels it).
>
> --
> Kirk Brooks
> San Francisco, CA
> ===
>
> *We go vote - they go home*
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **



-- 
*
CatBase - Top Dog in Data Publishing
tel: +44 (0) 207 118 7889
w: http://www.catbase.com
skype: pat.bensky
*
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-25 Thread Pat Bensky via 4D_Tech
Thanks John.
But how would that work in a multi-user setting? Whatever method is used
for assigning the new numbers, it must run on the server, otherwise we're
back to the problem of using semaphores, checking record locking, etc.
Also I should point out that there could be a large number of tables for
which the record numbering system needs to be used. We have a RecordNumbers
table which has one record for each table that requires this function. so
we must have ONE process that accesses and updates that table.
PB

On Sat, 25 Aug 2018 at 15:49, John DeSoi via 4D_Tech <4d_tech@lists.4d.com>
wrote:

>
> > On Aug 25, 2018, at 9:10 AM, Pat Bensky via 4D_Tech <
> 4d_tech@lists.4d.com> wrote:
> >
> > As I see it, we'll need to call a worker, which calls the worker that
> > assigns the record number.
> > The first worker has to wait until the second one has created the new
> > number.
> > Then the original method, that called the first worker, must wait until
> the
> > first worker  gets the new number. It seems that this won't be much
> better
> > than the old method.
> >
> > Am I completely barking up the wrong tree? Is this not an appropriate use
> > for workers? Or have I misunderstood something?
>
> It would have been really nice if CALL WORKER was implemented like EXECUTE
> METHOD and could return a value. You can do this on your own, but it is
> quite a bit  of work to do it in a general way.
>
> For your application, all you need is a shared object (no worker needed).
> Only one process at a time will be able to modify the counter. Some startup
> method could initialize the counter to the starting value.
>
> C_LONGINT($0)
>
> Use (Storage.myCounter)
>   Storage.myCounter.value:= Storage.myCounter.value+1
>   $0:= Storage.myCounter.value
> End use
>
>
> John DeSoi, Ph.D.
>
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **



-- 
*
CatBase - Top Dog in Data Publishing
tel: +44 (0) 207 118 7889
w: http://www.catbase.com
skype: pat.bensky
*
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: New record numbering system and CALL WORKER

2018-08-25 Thread Kirk Brooks via 4D_Tech
Pat,
A couple of thoughts since it sounds like you're refactoring your code (all
pseudo code, v17):
1) don't use this number as a key field.

2) The counter record:

[COUNTER]

ID

name  - optional but a good idea

_data  - object field: { nextNumber: 0, returned: []}

3) Counter_get_next(text) -> long

$1 is name of counter series

Put [COUNTER] in read/write

Query for record

Wait until record is unlocked

`

if(COUNTER._data.returned.length>0)` use the first one here

$0:=
COUNTER._data.returned.
shift
()

else

$0:=
COUNTER._data.nextNumber

COUNTER._data.nextNumber:=
COUNTER._data.nextNumber
+1

end if

SAVE RECORD

UNLOAD RECORD


4) Counter_save_unused (text; long)

Same idea except you just push $2 onto 'returned'. You could add a sort
command to make sure the smallest returned value is on top if that's an
issue.


Several years ago I stopped using invoice or PO numbers (or phone numbers
or SSNs or any data value) as key fields. This greatly simplifies the issue
you may have had about the 'unused' numbers that come up when data entry is
canceled. If you're not using that number as a key field you don't need to
assign it until the transaction completes. But if you've got some other
situations that result in 'returned' numbers it's not big deal.

This approach let's 4D handle the record locking and request que and as
long as you don't call it within a transaction just blissfully works.



On Sat, Aug 25, 2018 at 7:11 AM Pat Bensky via 4D_Tech <4d_tech@lists.4d.com>
wrote:

> Using v17 ...
>
> I'm looking at ways to update our ancient record numbering system, and I
> think I should be able to do it efficiently with CALL WORKER, but having a
> bit of trouble getting my head around  it.
>
> The record numbers are like invoice numbers: each must be unique, and we
> don't want to have any gaps in the numbering sequence. So we need to keep
> track of any record numbers that are created and then abandoned (eg if a
> user creates a new record and then cancels it).

-- 
Kirk Brooks
San Francisco, CA
===

*We go vote - they go home*
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

New record numbering system and CALL WORKER

2018-08-25 Thread Pat Bensky via 4D_Tech
Using v17 ...

I'm looking at ways to update our ancient record numbering system, and I
think I should be able to do it efficiently with CALL WORKER, but having a
bit of trouble getting my head around  it.

The record numbers are like invoice numbers: each must be unique, and we
don't want to have any gaps in the numbering sequence. So we need to keep
track of any record numbers that are created and then abandoned (eg if a
user creates a new record and then cancels it).
The old system works well but it uses semaphores and SET/GET PROCESS
VARIABLE and DELAY PROCESS. I isn't very efficient, especially when a large
number of records are being imported and each one needs a new record number.
Record numbers must be assigned synchronously - processing must not
continue until the new record number has been assigned. Also, this
frequently needs to be done in a context where there is no active form, so
CALL FORM won't work.

As I see it, we'll need to call a worker, which calls the worker that
assigns the record number.
The first worker has to wait until the second one has created the new
number.
Then the original method, that called the first worker, must wait until the
first worker  gets the new number. It seems that this won't be much better
than the old method.

Am I completely barking up the wrong tree? Is this not an appropriate use
for workers? Or have I misunderstood something?

Pat

-- 
*
CatBase - Top Dog in Data Publishing
tel: +44 (0) 207 118 7889
w: http://www.catbase.com
skype: pat.bensky
*
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**