blue_harvester
22nd May 2006 11:41 UTC
Label confusion?
I have the following code that checks a variable for either the value 'microsoft' or 'oracle'. Depending on the value the code will jump to a label:
StrCmp $var_FL_DB_TYPE "microsoft" sqlserver oracle
sqlserver:
ExecWait '"osql.exe" -S SERVER -U USER -P PASS -n -i validate_osql.sql -b'
oracle:
ExecWait '"sqlplus.exe" USER/PASS@DATABASE @validate_sqlplus.sql'
I know for a fact that the value of var_FL_DB_TYPE is 'microsoft', but the oracle label ALWAYS gets executed. I've even tried removing the jump to oracle ref in the StrCmp line, but this line always gets executed!!
What am I doing wrong?
Red Wine
22nd May 2006 12:10 UTC
!include LogicLib.nsh
function myfunc
${If} "$var_FL_DB_TYPE" == "microsoft"
ExecWait '"osql.exe" -S SERVER -U USER -P PASS -n -i validate_osql.sql -b'
${Else}
ExecWait '"sqlplus.exe" USER/PASS@DATABASE @validate_sqlplus.sql'
${EndIf}
FunctionEnd
RobGrant
22nd May 2006 12:19 UTC
You need to jump over the 2nd label. Code isn't skipped just because there's a label above it.
StrCmp $var_FL_DB_TYPE "microsoft" sqlserver oracle
sqlserver:
ExecWait '"osql.exe" -S SERVER -U USER -P PASS -n -i validate_osql.sql -b'
Goto end
oracle:
ExecWait '"sqlplus.exe" USER/PASS@DATABASE @validate_sqlplus.sql'
end:
Red Wine
22nd May 2006 12:26 UTC
Though, if you want to make your "coding" life easy and avoid labels and relative jumps, try to use LogicLib :-)
RobGrant
22nd May 2006 12:30 UTC
Sure, although labels are rather useful if he ever adds in more database types :)
blue_harvester
22nd May 2006 12:45 UTC
Thanks for this guys, both worked a treat.