I guess that the issue you're referring to is explained here: - http://stackoverflow.com/q/11899306/521799 - http://stackoverflow.com/q/3481771/521799
The "DELIMITER" command is really a command for the MySQL SQL client. With JDBC (or with JOOQ, shouldn't matter), just remove the DELIMITER $$ [...] $$ part and keep the contents. Unrelated: I like your idea of creating "temp" tables this way. Note that since your temp table's row type matches that of the underlying view, you might be able to run typesafe queries against it by applying jOOQ's runtime table mapping as explained here: http://www.jooq.org/doc/3.2/manual/sql-building/dsl-context/runtime-schema-mapping/ Cheers Lukas 2013/12/17 <[email protected]> > Hi all, > > I'm trying to do something which perhaps isn't intended to be done with > jOOQ, but I'm sure someone should be able to see what I'm trying to do. > > Basically, I create a "temporary" table on top of a view (its not actually > temporary, it's a table name with a random number appended to the end of > it), which I am then going to merge back in to another table once I have > performed some SQL statements on the "temporary" table. > I needed it to be not a real temporary table so that I can create triggers > on it. > > I am trying to create a trigger using SQL in a String, but I get a syntax > error even though the syntax is valid when used in MySQLWorkbench. I've > snipped the trigger here to make it easier to read. > > String sql1 = "create table temptable123456 as (select * from > underlyingview)"; > > String sql2 = "delimiter $$ create trigger temptable123456_bupd before > update on temptable123456 for each row begin if(condition1) then set field > = value; end if; if(condition2) then set field = value; > end if; end$$"; > > create.execute(sql1); > create.execute(sql2); > > The error I get is the standard syntax error - > > You have an error in your SQL syntax; check the manual that corresponds to > your MySQL server version for the right syntax to use near 'delimiter $$ > create trigger temptable123456_bupd before upd' at line 1 > > So my question is - is there a way to achieve what I'm trying to do here? > > Thanks! > > -- > You received this message because you are subscribed to the Google Groups > "jOOQ User Group" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "jOOQ User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
