Fixed sqlite_apply_sql to use  instead of  since  is an external variable and  is a local variable.