Solved

when to use single quotes in Project Variables

  • 19 November 2019
  • 1 reply
  • 22 views

what is the right scenario for using single quotes to wrap project variables? 

 

Let's say i have a data constraint added to a field and i am using a dynamic project variable like, so

in this scenario, i am comparing a data to another date, and i have the variable encased in single quotes.

I always assumed the single quotes was how Discovery Hub "renders" the underlying variable, but i recently found that my assumption was untrue. 

is the single quotes only to be used when evaluating a character string? or are there some rules to apply wrapping in single quotes.

 

Note: the variable above is a dynamic -> select max({datefield}) from {table} statement, under the covers. 

icon

Best answer by JTreadwell 19 November 2019, 19:33

View original

1 reply

Userlevel 3
Badge +5

Hi Josiah, Thanks for posting. 

Discovery Hub will always render a variable. You only need single quotes when evaluating character strings. So in the above example you need single quotes because SQL will be evaluating the date string that will be rendered from the variable. 

You can click the "Show Translation" radio button at the bottom of the dialog box to see what script will be passed to SQL. 

A rule of thumb for custom Data Selection Rules: Just type your WHERE clause, but without the "WHERE". So after you click "show translation" this will be what's passed to SQL as the WHERE clause. 

Hope that helps. 

Reply