Removed dbms argument from executeSql statement.
fixed it
changed case of cdm_schema

added row_id to all output temp tables
Fixed R code to run with new SQL.