Re: New record numbering system and CALL WORKER

2018-08-27 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: Writing Components

2018-08-27 Thread Chip Scheide via 4D_Tech
I prefer to reference the pieces as:
Host - the primary system in which 1 or more components are installed
Component - a library of functions and/or forms which are focused on a specific 
task
 
less confusing  :) 
and 4D references both of these terms at various points in their documentation
Chip
> Jody,
> 
> Yes, that term took a while to get used to…
> 
> It is basically just your 4D database that contains all the code, 
> forms, etc that you are putting into your component.
> 
> Components are matrix databases whose files are suffixed either .4db 
> (interpreted matrix database), .4dc (compiled matrix database) or 
> .4dbase (package type matrix database, see .4dbase Extension).  
> 
> You wouldn’t go wrong if you just replaced the term Matrix Database 
> with Component Database.
> 
> It is the database that you put inside your Components folder.
> 
> Foundation Shell is a Matrix Database.
> 
> Thanks,
> Walt Nelson (Seattle)
> 
> www.foundationshell.com 
> w...@foundationshell.com 
> 
>> On Aug 26, 2018, at 11:19 AM, Jody Bevan via 4D_Tech 
>> <4d_tech@lists.4d.com > wrote:
>> 
>>  I know as I started to read the documentation - within the first 
>> page they introduced a term ‘matrix databases’ that was not 
>> defined as to how they are using it. The sentence then became 
>> meaningless - hate writing like that.
> 
> **
> 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
> **

Hell is other people 
 Jean-Paul Sartre
**
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: Writing Components

2018-08-27 Thread Walt Nelson via 4D_Tech
Jody,

Yes, that term took a while to get used to…

It is basically just your 4D database that contains all the code, forms, etc 
that you are putting into your component.

Components are matrix databases whose files are suffixed either .4db 
(interpreted matrix database), .4dc (compiled matrix database) or .4dbase 
(package type matrix database, see .4dbase Extension).  

You wouldn’t go wrong if you just replaced the term Matrix Database with 
Component Database.

It is the database that you put inside your Components folder.

Foundation Shell is a Matrix Database.

Thanks,
Walt Nelson (Seattle)

www.foundationshell.com 
w...@foundationshell.com 

> On Aug 26, 2018, at 11:19 AM, Jody Bevan via 4D_Tech <4d_tech@lists.4d.com 
> > wrote:
> 
>  I know as I started to read the documentation - within the first page they 
> introduced a term ‘matrix databases’ that was not defined as to how they are 
> using it. The sentence then became meaningless - hate writing like that.

**
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
I do this too, only I use a second (related) table [Sequence_Recyled] 
rather then a blob.
Each record in the related table holds a return value, and a relational 
ID.

query before creating, use if found
on return of a created value, a new record in the recycle table is 
created & populated.

if deleting on a table with recyclable ID the old (previously used) ID 
goes into the recycle bin.
If deleting lots of records - selection to array, array to selection.

On Mon, 27 Aug 2018 08:29:55 -0600, Jody Bevan via 4D_Tech wrote:
> 
> 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. 
---
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 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
**