0

Unique number

Hello, I have several tables (médical vacuums, défibrilators...), in each table there are the different devices referenced by an internal N°.
I am looking for a formula to check that the internal N° is unique, this formula works if I duplicate the internal N° on one base but does not work with the other bases

 

I hope I have been clear in my request

thanks

alain

8 replies

null
    • Alain.1
    • 3 yrs ago
    • Reported - view

    ?

    • Sean
    • 3 yrs ago
    • Reported - view

    I don't know if this is what you entended, but if the test fails on one of the if statements none of the following if statements will execute.

    • Alain.1
    • 3 yrs ago
    • Reported - view

    You are right. 
    in fact i would like to scan several tables to see if the number i just created already exists.

    • Sean
    • 3 yrs ago
    • Reported - view

    Right, but I think my definition of a failed test is different than yours. When the if statement test condition fails or returns false, none of the code inside that if statement is executed so none of the nested if statements following that one will execute. Each one will need to be in its own if-then-end structure and not nested the way you have it.

    • Alain.1
    • 3 yrs ago
    • Reported - view

    thank you for your return, I will deepen if-else-then..

    basically my problem is looking for a number that could be duplicated on other tables .. i don't know how to scan the other tables. if you have any suggestions.

    alain

    • Sean
    • 3 yrs ago
    • Reported - view

    If you want to check multiple tables, you can't use nested if statements and you can't use else. You need to test each table individually...

     

    let myField1 := 'N° interne';
    if cnt(select Aspirateur where 'N° interne' = myField1) > 0 then
    alert("Ce N° interne existe déja!)
    end;
    if cnt(select Bistouri where 'N° interne' = myField1) > 0 then
    alert("Ce N° interne existe déja!)
    end;
    if cnt(select Défibrillateur where 'N° interne' = myField1) > 0 then
    alert("Ce N° interne existe déja!)
    end

     

    etc...

    • Sean
    • 3 yrs ago
    • Reported - view

    I would modify the alerts to include the table names so you know which table(s) has/have a match.

     

    let myField1 := 'N° interne';
    if cnt(select Aspirateur where 'N° interne' = myField1) > 0 then
    alert("Ce N° interne existe déja en table Aspirateur!)
    end;
    if cnt(select Bistouri where 'N° interne' = myField1) > 0 then
    alert("Ce N° interne existe déja en table Bistouri!)
    end;
    if cnt(select Défibrillateur where 'N° interne' = myField1) > 0 then
    alert("Ce N° interne existe déja en table Défibrillateur!)
    end

    • Alain.1
    • 3 yrs ago
    • Reported - view

    thank you, it works perfectly. It's a small step for you but a leap for me. 👍🏻

Content aside

  • 3 yrs agoLast active
  • 8Replies
  • 1084Views