Prior to OriendDB 3.0 we were executing Batch Scripts in the form of:
BEGIN
let x = SELECT * FROM MyClass
COMMIT
return $x;
Using the following commands:
ODatabaseDocument myDb;
myDb.command(new OCommandScript("sql", batchCommand)).execute(params);
In OrientDB 3.0 the ODatabaseDocument.command(OCommandRequest iCommand) is marked as deprecated and instructs the user to use the command / execute methods that simply take strings. However, it does not seem that either the suggested versions of the command or execute methods actually allow you to run a script of this nature. Trying the following:
myDb.execute("sql", batchCommand, params)
Results in a OCommandSQLParsingException("Encountered " "BEGIN "" at line 2, column 1."). Passing the "script" in as the language for execute also yields the same result. Using the command(string, params) method yields a slightly different syntax error.
Is there some obvious API that we are overlooking to execute these types of scripts? Any pointers would be much appreciated.
It turns out that the issue was indeed missing semi-colons. As explained here commands in batch scripts need to be separated by semi-colons. This even applies to the BEGIN and COMMIT statements. Once the script was updated, the execute command worked as expected. I'll leave this here in case any one else runs into the same issue.