When running CREATE SQL Query as below from a ".sql" file , Syntax error is thrown,. However if i run the same sql on the console it runs fine.
create alias TO_DATE as $$
java.util.Date toDate(String s,String format) throws Exception {
return new java.text.SimpleDateFormat("yyyy.MM.dd").parse(s);}
$$;
create alias TO_DATE as [*]$$ java.util.Date toDate(String s,String format) throws Exception { return new java.text.SimpleDateFormat(""yyyy.MM.dd"").parse(s)" [42000-177]
at org.h2.message.DbException.getSyntaxError(DbException.java:190)
if i change this query to below in .sql file :
create alias TO_DATE as '$$'
java.util.Date toDate(String s,String format) throws Exception {
return new java.text.SimpleDateFormat("yyyy.MM.dd").parse(s);}
'$$';
It throws an error :
Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "create alias TO_DATE as '$$' java.util.Date toDate(String s,String format) throws Exception { return new java.text.SimpleDateFormat(""yyyy.MM.dd"").parse(s[*])" [42000-177]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:344)
at org.h2.message.DbException.get(DbException.java:178)
at org.h2.message.DbException.get(DbException.java:154)
Whats the issue here and how to resolve it ?