mercredi 18 avril 2018

Batch Variables not equal enabledelayedexpansion

I need your help because i have a shocking problem

2512 and 2512 are not equal !

The context is :i'm doing an import program between 2 Oracle DataBases

I want to verify if the export is correct so i want to automaticaly check if the tables have the same number of line.

In a batch file i do a query with SQLplus on the first DB, i store the result in a text file, then i read the file and put the result in a variable.

I do the same thing with the second DB.

Results seems to be equal (see the screenshot)

But when i try if !resultats_prod!==!resultats_test!(...) else(...), it execute the else

here is the code

echo liste_tables : !liste_tables!
echo.
for %%i in (!liste_tables!) do (

    echo SELECT count^^^(*^^^) FROM %%i;    base de prod
    echo SELECT count^^^(*^^^) FROM %%i; | sqlplus -s user/passwd@db_prod > C:\...\resultat_prod.txt
    for /f "tokens=*" %%i in (C:\...\resultat_prod.txt) do set resultats_prod=%%i
    echo resultat prod : !resultats_prod!
    pause

    echo SELECT count^^^(*^^^) FROM %%i;    base de test
    echo SELECT count^^^(*^^^) FROM %%i; | sqlplus -s user/passwd@db_test> C:\...\resultat_test.txt
    for /f "tokens=*" %%i in (C:\...\resultat_test.txt) do set resultats_test=%%i 
    echo resultat test : !resultats_test!
    pause

    if !resultats_prod!==!resultats_test! ( 
        echo ---!resultats_prod! et !resultats_test! sont egaux---
        echo ---IMPORT REUSSI---
    ) else ( 
        echo ---!resultats_prod! et !resultats_test! ne sont pas egaux---
        echo ---IMPORT RATE---
    )  

    echo fin boucle
    echo.
)

I have used setlocal enabledelayedexpansion before and endlocal after.

Thanks for your help

Aucun commentaire:

Enregistrer un commentaire