I have such an issue with SQL Anywhere 10. I am working with it and a SyBase database version 5.0.0
I am developing an application which is supposed to take some .SQL scripts and execute them on the server.
To do so I am using ibatis' ScriptRunner class, namely its method runScript. That method works sweet when executing a script which contains INSERT or UPDATE operations, but it displays com.sybase.jdbc3.jdbc.SybSQLException: SQL Anywhere Error -131: Syntax error whenever it comes across some "BEGIN" or even "DECLARE".
I really do not know what is going.
Anyone could help out? Thanks in advance.
This question is marked "community wiki".
asked 22 Aug '13, 11:02
A BEGIN END block has to be sent to SQL Anywhere as a single executable unit. If ScriptRunner is going to "look inside" your BEGIN and process it step by step, rather than send it all to the server in one fell swoop, you'll see a syntax error very quickly if you try anything interesting.
Maybe there is some ScriptRunner syntax that will force it to pass a BEGIN block as a single unit.
In the end it was way easier than I initially thought.
Volker: thanks for your reply, though the question was to do it as part of a Java Application.
Breck: you put the key before me: CALLING. Java's CallableStatement allows you to call SQL procedures, so I worked out that I would only have to read all the stuff in each file to use it as the input for the methods prepareCall and execute from that very class.
The reading of the commands in the file I did with Java Files' method readAllLines, whose output I put in a List of strings; I joined in all those Strings in one alone and used it as the parameter for the prepareCall to perform its wonders.
Thanks so much to all who have participated in this thread!
answered 27 Aug '13, 08:23