Re: Apache Derby CURRENT_TIMESTAMP not working in BEFORE INSERT and BEFORE UPDATE triggers at runtime

2023-12-04 Thread Rick Hillegas
On 12/3/23 11:34 AM, Steven Saunders wrote: Hi Rick, Can you confirm or not that Before Update and Before Insert triggers can or cannot be used to modify column values on a table? A trigger fires a triggeredStatement. The triggeredStatement can modify columns in a table. The

Re: Apache Derby CURRENT_TIMESTAMP not working in BEFORE INSERT and BEFORE UPDATE triggers at runtime

2023-12-03 Thread Steven Saunders
Hi Rick, Can you confirm or not that Before Update and Before Insert triggers can or cannot be used to modify column values on a table? The answer to this question will help me understand the limitations in an attempt to migrate the software as-is codewise to work with Derby. The only way to

Re: Apache Derby CURRENT_TIMESTAMP not working in BEFORE INSERT and BEFORE UPDATE triggers at runtime

2023-12-01 Thread Rick Hillegas
Is there some reason that you have to solve this problem with triggers? An alternative solution would be to perform your integrity checks in a database procedure which runs with DEFINERS rights and to restrict UPDATE privilege on the table to the table owner. On 12/1/23 10:15 AM, Steven

Re: Apache Derby CURRENT_TIMESTAMP not working in BEFORE INSERT and BEFORE UPDATE triggers at runtime

2023-12-01 Thread Steven Saunders
Hi Rick, I guess the first question of most importance is: Can we use Before Update or Before Insert triggers to intercept and modify column values (timestamps or otherwise)? The over simplified example was to show that the before triggers were not functioning as expected so attempts as

Re: Apache Derby CURRENT_TIMESTAMP not working in BEFORE INSERT and BEFORE UPDATE triggers at runtime

2023-11-29 Thread Rick Hillegas
You could replace the INSERT trigger with a generated column. I don't see how to eliminate the UPDATE trigger and preserve the behavior you want. Here's how to eliminate the INSERT trigger. First make the following class visible on the JVM's classpath: import java.sql.Timestamp; public

Re: Apache Derby CURRENT_TIMESTAMP not working in BEFORE INSERT and BEFORE UPDATE triggers at runtime

2023-11-29 Thread Steven Saunders
Hi Rick, Thanks for the alternative, it looks like you switched from Before Insert and Before Update to After Insert and After Update, respectfully. That will add multiple updates for one Insert or Update inturn causing unwanted triggers to fire in a slightly more complex schema I am trying to

Re: Apache Derby CURRENT_TIMESTAMP not working in BEFORE INSERT and BEFORE UPDATE triggers at runtime

2023-11-28 Thread Rick Hillegas
Hi Steven, Derby hews fairly closely to SQL Standard syntax. Your triggers look wrong to me. Your triggered SQL statements are VALUES statements, which simply manufacture some values and throw them into the void. I think that is why you had to include MODE DB2SQL in your syntax. I don't think