public OracleEpochFunction() { super("extract(second from (cast(?1 as timestamp) - to_date('1970-01-01', 'yyyy-mm-dd'))) " + "+ 60 * extract(minute from (cast(?1 as timestamp) - to_date('1970-01-01', 'yyyy-mm-dd'))) " + "+ " + (60 * 60) + " * extract(hour from (cast(?1 as timestamp) - to_date('1970-01-01', 'yyyy-mm-dd'))) " + "+ " + (24 * 60 * 60) + " * extract(day from (cast(?1 as timestamp) - to_date('1970-01-01', 'yyyy-mm-dd')))"); this.paramRenderer = new TemplateRenderer("(select extract(second from (t1 - to_date('1970-01-01', 'yyyy-mm-dd'))) " + "+ 60 * extract(minute from (t1 - to_date('1970-01-01', 'yyyy-mm-dd'))) " + "+ " + (60 * 60) + " * extract(hour from (t1 - to_date('1970-01-01', 'yyyy-mm-dd'))) " + "+ " + (24 * 60 * 60) + " * extract(day from (t1 - to_date('1970-01-01', 'yyyy-mm-dd'))) " + "from (select cast(?1 as timestamp) as t1 from dual))"); }
protected void renderDiff(FunctionRenderContext context) { renderer.start(context).addArgument(0).build(); } }
@Override public void render(FunctionRenderContext context) { if (context.getArgumentsSize() != 1) { throw new RuntimeException("The hour function needs exactly one argument <datetime>! args=" + context); } renderer.start(context).addArgument(0).build(); } }
@Override public void render(FunctionRenderContext context) { if (context.getArgumentsSize() != 1) { throw new RuntimeException("The minute function needs exactly one argument <datetime>! args=" + context); } renderer.start(context).addArgument(0).build(); } }
public OracleMinuteDiffFunction() { super("(extract(day from cast(?2 as timestamp) - cast(?1 as timestamp)) * " + (24 * 60) + " + extract(hour from cast(?2 as timestamp) - cast(?1 as timestamp)) * 60 + extract(minute from cast(?2 as timestamp) - cast(?1 as timestamp)))"); this.bothParamRenderer = new TemplateRenderer("(select extract(day from t2 - t1) * " + (24 * 60) + " + extract(hour from t2 - t1) * 60 + extract(minute from t2 - t1) from (select cast(?1 as timestamp) as t1, cast(?2 as timestamp) as t2 from dual))"); this.firstParamRenderer = new TemplateRenderer("(select extract(day from cast(?2 as timestamp) - t1) * " + (24 * 60) + " + extract(hour from cast(?2 as timestamp) - t1) * 60 + extract(minute from cast(?2 as timestamp) - t1) from (select cast(?1 as timestamp) as t1 from dual))"); this.secondParamRenderer = new TemplateRenderer("(select extract(day from t2 - cast(?1 as timestamp)) * " + (24 * 60) + " + extract(hour from t2 - cast(?1 as timestamp)) * 60 + extract(minute from t2 - cast(?1 as timestamp)) from (select cast(?2 as timestamp) as t2 from dual))"); }
@Override public void render(FunctionRenderContext context) { if (context.getArgumentsSize() != 1) { throw new RuntimeException("The " + functionName + " function needs exactly one argument <expression>! args=" + context); } renderer.start(context).addArgument(0).build(); }
public OracleSecondDiffFunction() { super("(extract(day from cast(?2 as timestamp) - cast(?1 as timestamp)) * " + (24 * 60 * 60) + " + extract(hour from cast(?2 as timestamp) - cast(?1 as timestamp)) * " + (60 * 60) + " + extract(minute from cast(?2 as timestamp) - cast(?1 as timestamp)) * 60 + trunc(extract(second from cast(?2 as timestamp))) - trunc(extract(second from cast(?1 as timestamp))))"); this.bothParamRenderer = new TemplateRenderer("(select extract(day from t2 - t1) * " + (24 * 60 * 60) + " + extract(hour from t2 - t1) * " + (60 * 60) + " + extract(minute from t2 - t1) * 60 + trunc(extract(second from t2)) - trunc(extract(second from t1)) from (select cast(?1 as timestamp) as t1, cast(?2 as timestamp) as t2 from dual))"); this.firstParamRenderer = new TemplateRenderer("(select extract(day from cast(?2 as timestamp) - t1) * " + (24 * 60 * 60) + " + extract(hour from cast(?2 as timestamp) - t1) * " + (60 * 60) + " + extract(minute from cast(?2 as timestamp) - t1) * 60 + trunc(extract(second from cast(?2 as timestamp))) - trunc(extract(second from t1)) from (select cast(?1 as timestamp) as t1 from dual))"); this.secondParamRenderer = new TemplateRenderer("(select extract(day from t2 - cast(?1 as timestamp)) * " + (24 * 60 * 60) + " + extract(hour from t2 - cast(?1 as timestamp)) * " + (60 * 60) + " + extract(minute from t2 - cast(?1 as timestamp)) * 60 + trunc(extract(second from t2)) - trunc(extract(second from cast(?1 as timestamp))) from (select cast(?2 as timestamp) as t2 from dual))"); }
@Override public void render(FunctionRenderContext context) { if (context.getArgumentsSize() != 1) { throw new RuntimeException("The second function needs exactly one argument <datetime>! args=" + context); } renderer.start(context).addArgument(0).build(); } }
public OracleHourDiffFunction() { super("(extract(day from cast(?2 as timestamp) - cast(?1 as timestamp)) * 24 + extract(hour from cast(?2 as timestamp) - cast(?1 as timestamp)))"); this.bothParamRenderer = new TemplateRenderer("(select extract(day from t2 - t1) * 24 + extract(hour from t2 - t1) from (select cast(?1 as timestamp) as t1, cast(?2 as timestamp) as t2 from dual))"); this.firstParamRenderer = new TemplateRenderer("(select extract(day from cast(?2 as timestamp) - t1) * 24 + extract(hour from cast(?2 as timestamp) - t1) from (select cast(?1 as timestamp) as t1 from dual))"); this.secondParamRenderer = new TemplateRenderer("(select extract(day from t2 - cast(?1 as timestamp)) * 24 + extract(hour from t2 - cast(?1 as timestamp)) from (select cast(?2 as timestamp) as t2 from dual))"); }
@Override public void render(FunctionRenderContext context) { if (context.getArgumentsSize() != 1) { throw new RuntimeException("The day function needs exactly one argument <datetime>! args=" + context); } renderer.start(context).addArgument(0).build(); } }
public DateDiffFunction(String functionName, String template) { this.functionName = functionName; this.renderer = new TemplateRenderer(template); }
@Override public void render(FunctionRenderContext context) { if (context.getArgumentsSize() != 1) { throw new RuntimeException("The year function needs exactly one argument <datetime>! args=" + context); } renderer.start(context).addArgument(0).build(); } }
public MySQLSecondDiffFunction() { super("truncate(unix_timestamp(?2), 0) - truncate(unix_timestamp(?1), 0)"); this.bothParamRenderer = new TemplateRenderer("(select truncate(unix_timestamp(t2), 0) - truncate(unix_timestamp(t1), 0) from (select ?1 as t1, ?2 as t2) as temp)"); }
@Override public void render(FunctionRenderContext context) { if (context.getArgumentsSize() != 1) { throw new RuntimeException("The month function needs exactly one argument <datetime>! args=" + context); } renderer.start(context).addArgument(0).build(); } }
public PagePositionFunction(String template) { this.renderer = new TemplateRenderer(template); }
@Override protected void renderDiff(FunctionRenderContext context) { renderer.start(context).addArgument(0).addArgument(1).build(); } }
public AbstractRepeatFunction(String template) { this.renderer = new TemplateRenderer(template); }
@Override protected void renderDiff(FunctionRenderContext context) { renderer.start(context).addArgument(0).addArgument(1).build(); } }
public DayFunction(String template) { this.renderer = new TemplateRenderer(template); }
@Override protected void renderDiff(FunctionRenderContext context) { renderer.start(context).addArgument(0).addArgument(1).build(); } }