Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have a table(switch) with single column(status) and it has value either 'true' or 'false'.
I want my script to loaded if the value is only 'true' and to be not loaded if the value is 'false'.
I wrote this in the editor:
LOAD status;
[switch]:
SELECT status
FROM [schema].[switch];
let vButton = fieldvalue(status, 1) ;
if (vButton='true') then
------ Load scripts-------
else
EXIT Script;
End If;
But this does not work. Anytime i load, it automatically exits script.
Could you please help me on this issue?
Regards,
Tommy,
LOAD status;
[switch]:
SELECT status
FROM [schema].[switch];
let vButton = fieldvalue('status', 1) ;
if ('$(vButton)'='true') then
------ Load scripts-------
else
EXIT Script;
End If;
There are two things
1) Fieldvalue function always takes fieldname parameter with single quotes. Hence below is the one change require
fieldvalue('status', 1)
2) Ideally vButton= 'true' condition should work but wrapping variable within single quotes using $ expansion always works when comparing texts. So for safer side you can always use variable like '$(vButton)' when you need to compare texts. If you want to compare numeric then no need to use single quotes, you can refer the variable like $(vButton)
Hope this is helpful
Try putting quotes around field name, like:
let vButton = fieldvalue('status', 1) ;
Thank you for your response. Unfortunately it did not work.
Hi,
Can I suggest
if $(vButton)='true' then
------ Load scripts-------
else
EXIT Script;
End If;
try this
LOAD status;
[switch]:
SELECT status
FROM [schema].[switch];
let vButton = fieldvalue(status, 1) ;
if ('$(vButton)'='true') then
------ Load scripts-------
else
EXIT Script;
End If;
I get this error:
Unfortunately Kush, it didnt work out either. Thank you for the response.
LOAD status;
[switch]:
SELECT status
FROM [schema].[switch];
let vButton = fieldvalue('status', 1) ;
if ('$(vButton)'='true') then
------ Load scripts-------
else
EXIT Script;
End If;
Thanks Kush for the solution. It worked well.
Btw, I dont get the idea behind, if you have some short clue on that or a link to a document, could you pls share?
Sorry. I did not get your request? Are you asking how this worked?