Erreur Itgeneor823 lors de l'exécution du script

Lors de l’exécution d’un script, je reçois le message d’erreur suivant dans Invantive Query Tool 24.0.594, auquel j’étais connecté depuis le 24/11/2025 19:50:39 (UTC).

itgeneor823: Statement #12 'insert into e....InvoiceNumber' starting on line 50 caused an error.

The OAuth access token for Exact Online has expired or is currently not accepted.

The access token has expired.

The remote server returned an error: (401) Unauthorized.

Please check that Exact Online is online. Try again later when Exact Online is offline. Re-authenticate on Exact Online when online and the access token is still not accepted.

Message ID: ea49bd90-e937-4d3c-9286-478826f37829

Occurred (UTC): 24/11/2025 19:55:57

insert into exactonlinerest..SalesEntries@eol
( Division
, EntryNumber
, InvoiceNumber
, Customer
, Description
, Journal
, Status
, Type
, EntryDate
, DueDate
, Currency
) 
select /*+ http_disk_cache(false) http_memory_cache(false) */ 3935673 Division
,      ftr.InvoiceNumber EntryNumber
,      ftr.InvoiceNumber
,      act.Id Customer
,      'Factuur ' || invoiceNumber description
,      '70' Journal
,      50
,      case
       when AmountDC < 0 
       then 21 
       else 20 
       end 
       Type
,      to_date(ftr.InvoiceDate, 'DD-MM-YYYY') InvoiceDate
,      to_date(ftr.ExpiryDate, 'DD-MM-YYYY') DueDate
,      ftr.Currency
-- 
-- Décommenter pour obtenir le code du compte.
--
--,      ftr.AccountCode
from   InvoicesToLoad@inmemorystorage ftr
left
outer
join   ExactOnlineREST..AccountsBulk@eol act
on     act.Division = 3935673
and    act.Code = to_char(ftr.AccountCode)
and    act.Status = 'C' /* Client */
where  ftr.LineNumber = 1
identified by 'INVOICE' || ftr.InvoiceNumber

System.Net.WebException
ValidationException
OAuthException
ValidationException
   at System.Net.HttpWebRequest.GetResponse()
   at Invantive.Data.Providers.Http.HttpBasedProvider.DoRequest(GlobalState owner, ExecutionOptions executionOptions, HttpWebRequest request, String url, ObjectDefinition objectDefinition, QueryObject queryObject, String partitionCode, String callSafeNameOverrule, String anonymizedPostText, Boolean allowRetryOnNoConnectionMade, Boolean allowRetryOnConnectionLoss, ParameterList parameters, Guid nativeCallUid, Boolean throwExceptionOnNonSuccessfulStatusCode, Object requestBody, Int64 timeoutInitialMs, Int64 timeoutMaxOnRetryMs, String resultCacheId, String publicQueryParameters, SqlExecutionStep sqlExecutionStep, ExecutionStatistics& executionStatistics, ODataErrorProcessingInstructions& oDataErrorProcessingInstructions)

Le jeton d’actualisation (refresh token) devrait être renouvelé, mais un problème supplémentaire est qu’une instruction SQL Server générée qui le précède est extrêmement lente. Il s’agit d’environ 24 000 lignes de SQL, à savoir :

select * from i8BI4ExactOnline_NWB.dbo.import20250115_ftr_sedis e where InvoiceNumber >= 25100503 and InvoiceNumber < 25979999 
and InvoiceNumber not in (25120002
, 25118137
, 25103932
, 25119950
, ... <23700+ regels meer
)

Si je retire le not in, la requête s’exécute en quelques centaines de millisecondes et renvoie 174 lignes.

Le UniversalSQL Invantive correspondant qui génère cette instruction est :

create or replace table InvoicesToLoad@inmemorystorage
as
select *
from   import20250115_ftr_sedis@sql ftr
where  to_char(ftr.InvoiceNumber) like '2512%'
and    ftr.invoicenumber >= ${INVOICENUMBER_FROM}
and    ftr.invoicenumber < ${INVOICENUMBER_TO}
and    ftr.invoicenumber not in ( select EntryNumber from InvoicesLoaded@InMemoryStorage )

Finalement, le temps d’exécution de la requête SQL Server a été réduit à moins d’1 seconde, en utilisant un left outer join afin qu’il n’envoie plus le not in :

--
-- Importe toutes les factures déjà envoyées depuis SEDIS
-- dans Exact Online.
--
-- Le numéro de facture dans Exact Online est identique à celui de SEDIS.
--
rollback transaction

set use-http-memory-cache@eol false

set use-http-disk-cache@eol false

local define DIVISION "123123"

use ${DIVISION}@eol

--
-- Changement pour l'incrémentiel : vérifier quels numéros d'entrée n'ont pas encore été comptabilisés.
--

local define INVOICENUMBER_FROM "25100503"

local define INVOICENUMBER_TO "25979999"

--
-- Récupère depuis Exact Online les numéros d'entrée / numéros de facture déjà connus.
--
create or replace table InvoicesLoaded@InMemoryStorage
as
select /*+ http_disk_cache(true) http_memory_cache(true) */ 
       txn.EntryNumber
from   TransactionsIncremental@eol txn
where  txn.type in (20,21)
and    txn.entrynumber >= ${INVOICENUMBER_FROM}
and    txn.entrynumber <  ${INVOICENUMBER_TO}

create or replace table InvoicesToLoad@inmemorystorage
as
select ftr.*
from   import20250115_ftr_sedis@sql ftr
left
outer
join   InvoicesLoaded@InMemoryStorage ild
on     ild.EntryNumber = ftr.invoicenumber
where  ftr.invoicenumber >= ${INVOICENUMBER_FROM}
and    ftr.invoicenumber < ${INVOICENUMBER_TO}
--
-- Non chargé précédemment.
--
and    ild.EntryNumber is null

begin transaction

insert into exactonlinerest..SalesEntries@eol
( Division
, EntryNumber
, InvoiceNumber
, Customer
, Description
, Journal
, Status
, Type
, EntryDate
, DueDate
, Currency
) 
select /*+ http_disk_cache(false) http_memory_cache(false) */ ${DIVISION} Division
,      ftr.InvoiceNumber EntryNumber
,      ftr.InvoiceNumber
,      act.Id Customer
,      'Factuur ' || invoiceNumber description
,      '70' Journal
,      50
,      case
       when AmountDC < 0 
       then 21 
       else 20 
       end 
       Type
,      to_date(ftr.InvoiceDate, 'DD-MM-YYYY') InvoiceDate
,      to_date(ftr.ExpiryDate, 'DD-MM-YYYY') DueDate
,      ftr.Currency
-- 
-- Décommenter pour obtenir le code du compte.
--
--,      ftr.AccountCode
from   InvoicesToLoad@inmemorystorage ftr
left
outer
join   ExactOnlineREST..AccountsBulk@eol act
on     act.Division = ${DIVISION}
and    act.Code = to_char(ftr.AccountCode)
and    act.Status = 'C' /* Customer */
where  ftr.LineNumber = 1
identified by 'INVOICE' || ftr.InvoiceNumber

insert into ExactOnlineREST..SalesEntryLines@eol
( Division
, AmountFC
, Description
, GLAccount
, Quantity
, linenumber
, VATCode
, VATAmountFC
)
select ${DIVISION} Division
,      ftr.AmountDC + 1 * ftr.VATAmountDC
,      ftr.Description
,      gat.ID GLAccount
,      1 Quantity
,      ftr.linenumber
,      ftr.VATCode
,      ftr.VATAmountDC
--
-- Décommenter si nécessaire pour l'analyse.
--
--,      ftr.Grootboek
from   InvoicesToLoad@inmemorystorage ftr
left
outer
join   GLAccountsBulk@eol gat
on     gat.Division = ${DIVISION}
and    gat.Code = 
       -- Traduire les anciens comptes du grand livre.
       case 
       when ftr.Grootboek = '8000' then '80000' 
       when ftr.Grootboek = '2081' then '15070' 
       when ftr.Grootboek = '7041' then '76000' 
       when ftr.Grootboek = '7802' then '76010' 
       when ftr.Grootboek = '7803' then '76020' 
       when ftr.Grootboek = '7804' then '76030' 
       when ftr.Grootboek = '7805' then '76050' 
       when ftr.Grootboek = '7806' then '76060' 
       when ftr.Grootboek = '7807' then '76070' 
       when ftr.Grootboek = '7808' then '76080' 
       when ftr.Grootboek = '8400' then '80316' 
       else ftr.Grootboek 
       end
where  1=1
attach to 'INVOICE' || ftr.InvoiceNumber

commit transaction

Content de voir que le script fonctionne à nouveau. C’est une bonne solution de contournement pour itgeneor823.

Pour pouvoir analyser cela, merci de télécharger et d’installer une nouvelle version depuis https://download.invantive.com.

Cette nouvelle version contient la nouvelle table SystemOAuthFlowEvents@DataDictionary, qui permet de mieux analyser le fonctionnement. Après l’apparition du message d’erreur itgeneor823, merci de bien vouloir récupérer toutes les lignes avec un select * et de les ajouter à ce ticket.

Cette question a été automatiquement clôturée après 1 semaine d’inactivité. La dernière réponse donnée a été marquée comme solution.

Merci de poser une nouvelle question via un sujet distinct si le problème se reproduit. Merci d’inclure dans la nouvelle question un lien vers ce sujet en collant son URL dans le texte.