Oracle Forms question

Oracle form question

I have 2 new fields added. comment_user and comment_date.


when the user enter comments in the vend_change_comments field, I have to populate comment_user as user and comment_date as sysdate.

In the forms pre-update trigger I have this code.. If the old user and old date is not the same as present user and date, the update it to user and sysdate. I have this code, which is not working. Need help

	v_old_comment_user    dss.disposition_details.comment_user%TYPE;
	v_old_comment_date    dss.disposition_details.comment_date%TYPE; 
	Cursor C1 is
	select comment_user,comment_date
	  from dss.disposition_details
	 where id =
	   and action = 'R';
	Open C1;
	Fetch C1 into v_old_comment_user
	Close C1;
If v_old_comment_user is null and v_old_comment_date is null then
		:disposition_details.comment_user := user;
	  :disposition_details.comment_date := sysdate;	
Elsif v_old_comment_user != :disposition_details.comment_user then
    	:disposition_details.comment_user:= user; 
ElsIf v_old_comment_date != :disposition_details.comment_date then
    		:disposition_details.comment_date := sysdate;
End if;  

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

" is not working " means does not compile,  does compile and gives an error at runtime,  does compile and gives no error but is not updating comment_user.
If the last one is true verify  the trigger fires (put a message after the begin and if it does fire put additional messages with the value of the items that matter to  debug the problem), else give the error message for compile or runtime
slightwv (䄆 Netminder) Commented:
>>If the old user and old date is not the same as present user and date

Sounds like the end result is set current user and date no matter what.  Why even perform the check?  Just set them.

If userA adds a comment today.  Then comes back again tomorrow and adds another, why could the date remain today?

If you need history, create dss.disposition_details_history table and put a table trigger on dss.disposition_details that inserts the current records into disposition_details_history.

Should simplify the form logic.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mark GeerlingsDatabase AdministratorCommented:
I agree with slightwv's suggestion to just: "set current user and date no matter what.  Why even perform the check?"

If you do want to perform the check for some reason, there is a more efficient way to do that in Oracle Forms and avoid having to query the record in your pre-insert trigger:
1. Add two non-base-table, non-displayed fields in your block named: old_comment_user and old_comment_date (with data types that match your existing base-table fields).
2. Add a post-query trigger to set the values of:
    :disposition_details.old_comment_user := :disposition_details.comment_user;
    :disposition_details.old_comment_date := :disposition_details.comment_date;
3. Then your pre-update trigger can just compare the values of data already in the form with no extra query required.
anumosesAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.