RE: SQL in ejscript
You also have a method called "executeSQLQuery(String sql)", but with this you do not get any result back.
This one is not available for Online either. In Online, there is no way to execute sql statements directly against the database.
Important: if you use any of the above for an Onsite installation, be careful if you include any user input at all, so you do not create a sql injection.