db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knut Anders Hatlen <knut.hat...@oracle.com>
Subject Re: How to INSERT (CURRENT_DATE+7 DAYS) in apache derby
Date Mon, 29 Apr 2013 20:21:41 GMT
manojkumar16 <manojkumar16@gmail.com> writes:

> I am writing a default scheduler for my project and it needs to be triggered
> 7 days later the deployment of project.
> Can somebody help me writing an INSERT statement which takes (CURRENT_DATE +
> 7 days) as a value for DATE field.
> + 7 DAYS)*, 604800000);
> REPEAT_INTERVAL is of long type and value associated with it is 7 days.
> I am having issue in settting [START_DATE+7 days] value.

Hi Manoj,

There is a JDBC escape function called TIMESTAMPADD that you could use
for this. It produces a timestamp rather than a date, but you can cast
the resulting timestamp to a date and insert it into the table.

I think something like this should do the trick:

insert into purge_acc(start_date, repeat_interval)
   values (cast({ fn timestampadd(sql_tsi_day, 7, current_date) } as date), 604800000)

The TIMESTAMPADD function is documented here:

Hope this helps,

Knut Anders

View raw message