SQL Queries Not Accepting Form Values

SQL Queries Not Accepting Form Values

Goal

Dynamic SQL queries rendering ? values when run, even though the tooltip shows the correct values being passed into the query. I'm trying to parse the values from a form and use them to run a SQL transaction block on submit (values for two of these fields left empty intentionally for this screenshot):

Steps

I've tried using an in-line ternary operator, and I've tried assigning the results of a subquery to a global variable. Neither has worked

Ternary operator approach

The memberOrAffiliateType field of the form appears to be populating correctly. The tooltip below indicates that the value is being passed from the form to the SQL correctly, in theory:


Global variable approach

I tried writing a second query and outputting the results to a global variable. I'm seeing the same compilation errors in the SQL at runtime:

This query pulls in the value from the form and conditionally returns the proper column name:

The variable pulls in the results array and parses it like so:

Similarly as the first approach, the tooltip indicates that the value is being recognized by the UI but is raising a syntax error when I hit "run":

It could be that these double quotes are causing issues. Have you tried plain query by hardcoding the member_id column?

Oh interesting, because var.value has double-quotes around it? Totally plausible, and you're right when I take the ternary operator out and hardcode member_id in that place I'm seeing a successful preview. Thanks for the insight!

Any tips on formatting the value attribute properly in the SQL?

You can try the GUI option. Then, you can play with the object or key-value pair options.

I recommend using a "mapping table" or "lookup table" to keep your database schema clean. This lookup table can be named "Member Type" and connect to a dropdown menu in your form. This will ensure that you only need one column in your main table to reference the "Member Type" table.