0

Automatic progressive number WHEN IMPORTING - Urgent help!

Hello everyone!

I have the typical code for a progressive ID Number (in "trigger on create"):

let before := max((select CASOS).'Número');
'Número' := before + 1;

It works good, but when I try to import a CSV file, this code doesn't work.

I realized that TRIGGER ON CREATE doesn't work when importing.

How to make this work? I am urged to do several imports (from different files) and the progressive number field should work.

 

Thank you!!

5 replies

null
    • Nick
    • 4 yrs ago
    • Reported - view

    Yo can update the ID Numbers after the import with something like this (button or Console)

    let myNum := 1;
    for i in (select YourTable) order by FieldName do
    i.(progressive ID Number := myNum);
    myNum := myNum + 1
    end

     

    (or edit the csv files and add the ID before importing?)

    ----

    Keep backup of your database!!!

    ----

     

    Yes, trigrers won't fire while importing :-(

    • SoluMaker
    • 4 yrs ago
    • Reported - view

    Dear Nick!

    It worked great!!!

    However, It does the numbering through +6000 records once and again and is very very time consuming.

    Is it possible to collect just the recently added records?

     

    (maybe those where ProgressiveNumericField = null, is possible? where it goes exactly)

    • Nick
    • 4 yrs ago
    • Reported - view

    Hi SoluMaker,

    I never tried something like that, maybe someone more experienced will give us his lights.

    • Mconneen
    • 4 yrs ago
    • Reported - view

    @SoulMaker ...  As a best practice.. You should import to a staging / import table.. and not your base transaction table.  Yes.. you can define a match key... and yes.. the import will do an insert or update based on the match key..   but from an Old (old) IT guy.. best practice is staging table.. edits for data quality .. then insert / update based on matching criteria ..  

     

    Still .. when creating new rows from code.. The after create trigger will NOT fire.. (please verify me.. at least when I last checked that was the case) ... As such.. any known "Trigger on create" logic should be put into a function that you can call. 

     

    I do believe Integromat integrations will fire the Trigger on Create..  Again.. this seems to be "tribal knowledge" .. so verify 

    • SoluMaker
    • 4 yrs ago
    • Reported - view

    Hi Nick,

    I added to your code a filter (between characters "[]") and it worked good. It took only the recently imported fields.

     

    Although it works as a temporary solution, I will also check @Mconneen experience point of view :) (or at least, I will try to figure it out)

     

    Thanks to all for the help

Content aside

  • 4 yrs agoLast active
  • 5Replies
  • 1084Views