Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Using Variables in Edit Script Dialog Problem

I can store the Path Names on variables and successfully use them. vData = 'D:\QlikviewData';

let

But when I try to pass parameters to a stored procedures, it does not work. Ex:

let mailTo = 'tugba@kuveytturk';

let From = 'server@kuveytturk'

let body = ' An error occured'

let subject = 'MIS Reload Error';

SQL EXECUTE SP_SendMail @From =$(From) , @To=$(mailTo), @Subject$(subject),@Body=$(body)

But this works when I send the parameters directly, without storing the values at variables. EXECUTE SP_SendMail @From = 'server@kuveytturk', @To= 'tugba@kuveytturk', @Subject='MIS Reload Error',@Body=' An error occured';

SQL





7 Replies
Not applicable
Author

Hi,

try this:

Let vName = Chr(39)&'Rainer'&Chr(39);

The inverted commas then are part of the variable value.

Good luck!

Rainer



Not applicable
Author

hi,

we use $ sign with variables only when we want to evaluate the contents on the right hand side of = sign (as in mailTo = 'tugba@kuveytturk'😉

but here u just need the contents of that variable ,so just use name of variable without using $ sign

let mailTo = 'tugba@kuveytturk';

let From = 'server@kuveytturk'

let body = ' An error occured'

let subject = 'MIS Reload Error';

SQL EXECUTE SP_SendMail @From =From , @To=mailTo, @Subject subject,@Body=body

thanks



Not applicable
Author

Thank you for being concerned with my problem.

Rainer, I tried chr(39) and used the variable with $(), it really works thanks.

Tauqueer, I tried your solution, when I write just the variable name without $(), it shows the variable name but not its content. Thanks for your advice.

As a result I will use chr(39) with $().

Not applicable
Author

Hi, I have one more question.

When I use ScriptError once, then I can not see its content any more.

For example if I compare its value, then this means I can not see what is inside it.

LOAD wrongColoumnName

FROM $(vData) Datasource.qvd (qvd);

IF ScriptError <> 0 THEN

let





error = 'An error has occured';



END

After I do this comparison the value inside ScriptError is dissapeared. ( ScriptError <> 0 )

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

When you use Variables and $-sign expansion, you need to use single quotes for those parameters that are supposed to look like strings.

For example:

If you need to create a condition like: TransYear = 2010, using a variable, you can use $(vYear) . However, for conditions like :

Product = 'Shoes', you need to enclose your $()-expansion in a set of single quotes:

Product = '$(vMyProduct)'

no need to tinker with CHR(39), in this case QlikView works well with the simple pair of single qoutes...

cheers,

Not applicable
Author

Hi, I have one more question.

When I use ScriptError once, then I can not see its content any more.

For example if I compare its value, then this means I can not see what is inside it.

LOAD wrongColoumnName

FROM $(vData) Datasource.qvd (qvd);

IF ScriptError <> 0 THEN

let

error = 'An error has occured';

END

After I do that comparison ( ScriptError <> 0 ) the value inside ScriptError is dissapeared.

I can not show it in a listbox

Not applicable
Author

I mean that when I use IF ScriptError <> 0 then the value of ScriptError becomes null.