SQL Procedural Dynamic SQL

NuoDB SQL supports the use of SQL statements that are defined and compiled at runtime for use in SQL stored procedures or user defined functions (UDFs


[ INTO target_var [ , target_var ] ... ]
[ USING VALUES input_var [ , input_var ] ... ]


Dynamic SQL and the EXECUTE IMMEDIATE statement allow any SQL statement to be executed within a SQL stored procedure or UDF.

EXECUTE IMMEDIATE allows SQL statements to be defined and compiled at runtime, thereby allowing the SQL statement to be dynamically built at execution time by substituting parameter values or concatenating text strings. Concatenating text strings allows building SQL statements that select from different tables and columns. Usage of the EXECUTE IMMEDIATE statement includes:

When writing dynamic SQL, NULL values need to be considered. This is true of SQL statements in general, not just dynamic SQL. For example, an SQL statement such as WHERE column = value will never be equal if value is NULL.

SQL statements that contain quoted literals also need to be considered when constructing dynamic SQL. NuoDB supports a function that will automatically escape quotes within a value. See QUOTENAME.

Dynamic SQL and the EXECUTE IMMEDIATE statement are not available in triggers.