amsc

ExecuteSQL - the word date...

Discussion created by amsc on Nov 23, 2017
Latest reply on Nov 24, 2017 by jbrown

I had been banging my head against the wall for a while trying to figure out why my executeSQL command wasn't working.  What I wanted was (and is) a simple query so I wouldn't need to make another value list. 

 

ExecuteSQL ( "SELECT DISTINCT region FROM daily_route_drivers AS dr WHERE dr.date = ?  "

; ""

; ¶

; daily_route_summary::g_date2 )

 

It continually gave a ? as a response and the data monitor simply gave a "there's an error in the syntax" message. 

 

After MUCH head scratching, it dawned on my that the word date might be a protected SQL word.  It is.  So, just simply embedding the word date with \" on each side fixed it.  Probably something straight forward for many of you, but did take a little for me to figure out.  New executesql command that works is:

 

ExecuteSQL ( "SELECT DISTINCT region FROM daily_route_drivers AS dr WHERE dr.\"date\" = ?  "

; ""

; ¶

; daily_route_summary::g_date2 )

 

I never could find anything online that helped with that detail, so I figured I'd post it here for others. 

 

Alex

 

Now, a question for others that has always puzzled me.  When I look at executeSQL examples in various blogs and posts, they are always embedded in Let commands.  Why is it in a Let command?

Outcomes