Sage 200 - table of counters instead of columns Identity - strange behavior

Recently, I was commissioned to write a Sage import tool that imports the number of discounts with a price.

Considered Sage 200 Tables:

  • StockItem - Main Product Table
  • StockItemDiscount - basic discount table
  • StockItemQtyDiscBreak - Qty Discount Discount

I will not bore you with information about the scheme, since this does not apply to my question, suffice it to say that the primary key in all three tables is the set of BigInt identifiers without (sigh), 1 StockItem can have many discounts and 1 discount can have many discounts on qty discount.

Now, in order to create the import procedure, I first had to analyze what Sage 200 did in SQL if you created the "Discount and Breaks" manually in sage (using SQL Profiler). As I said, Sage 200 does not use Identity columns; instead, it uses a counter table.

Inserting a new line into StockItemDiscount did the following:

UPDATE [Counter] SET [NextValue] = [NextValue] + 10 WHERE [CounterID] = 1

Then he selects a new identifier:

SELECT NextValue FROM Counter WHERE CounterID = 1

He then inserts a new row using the new value that he just selected from the counter:

INSERT INTO StockItemDiscount (StockItemDiscountID, /.../) VALUES (@NewID, /.../) 

My question is : Why does the earth do this? what could be the reason for this? (In particular, +10 THEN, reading the value)

All tables use the same counter, so 5 rows in 1 table will lead to a space in the identifier of another table - I just don’t understand why they do this?

, : StockItemDiscount i, StockItemQtyDiscBreak - , SQL can not see incrementing of the , 5 (6- , , , Sage 10 , , 10, ?

+3
4

# 1:

N0 N1-N9 ?

№ 2:

N0 N1-N9 ? , 5 , .

- , N1-N9?

# 1a # 2a:

, , , /​​.

0

Sage , ( , ).

Sage SDK, , ..

SDK, Sage, , , .

+2
№ 4 , "" .. , , .
0

Sage API , dbo.SYSCounter 10. -, , 1 . , , . SYSCounter xx , .

Direct SQL changes are not supported. If you are manipulating identifiers, this is obvious to anyone looking at the audit trail. It is recommended that you use the API with the SDK documentation. Talk with your BP or a third-party developer for more information.

0
source

All Articles