Is it possible to use variables in storage bucket files?

Hello,

I currently have a storage bucket that contains all our SQL queries. This works great for queries that are the same every time, the issue I’m coming across is quries that need a different variable. The variable is within the UiPath process.

For example, if I’m running through a date list, and input each list item into the query, how can I call the storage bucket variable and input the date variables?

The only Idea I have had is to place a “ReplaceMeWithVariable” within the storage bucket file, and use variable.Replace() method to enter in the correct variable. But this might not be avisable every time.

Your idea is the only way to do it.

A tip on how to do it, say your query is…

SELECT * FROM [TableName] WHERE [FieldName] = ‘SomeValue’

If you swap out ‘SomeValue’ with {0}:

SELECT * FROM [TableName] WHERE [FieldName] = ‘{0}’

Then say you read that query string into myQueryStr and need to replace {0} with a value in myReplaceVal, you can do:

String.Format(myQueryStr,myReplaceVal)

If you have additional replacement values you can do…

SELECT * FROM [TableName] WHERE [FieldName] = ‘{0}’ AND [FieldName2] = ‘{1}’

String.Format(myQueryStr,myReplaceVal,myReplaceVal2)

1 Like

Yea I thought the replace might be the only way, thanks for the confirmation. And yes, I had forgotten about the format function, thank you!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.