in reply to How to get a placeholder to keep the current column value?
I've played with trying to build the SQL dynamically (by checking to see which fields on the object are different from the one stored in the repository, and generating an SQL UPDATE statement on the fly), but that can be error-prone and time-consuming.
Another option eschews database independence -- and yes, I'm well aware that this option is probably of no solace to you, unless Postgres is an option. If you have a DBMS that supports triggers, you can just issue all the SQL as-is, and write your triggers to refuse to overwrite null fields; in PL/SQL (Oracle), such a trigger would look something like this:
This does have the drawback, as I mentioned, of being non-portable (but I have sinned, I do use it on occasion). If your application's ecological niche makes the precaching repository approach feasible, I'd suggest that, otherwise I believe that the dynamic SQL is the best approach. Good luck!-- :NEW.XXXX refers to the value of the XXXX field specified in the +update statement -- :OLD.XXXX refers to the value in the record being updated IF :NEW.foo IS NULL THEN :NEW.foo := :OLD.foo END IF;
If not P, what? Q maybe?
"Sidney Morgenbesser"
|
|---|