Re: Forms 4.5 How- to Help requested

From: gti_matt <gtimatt_at_home.com>
Date: Wed, 12 Dec 2001 02:31:53 GMT
Message-ID: <tkzR7.60531$Sx.17387208_at_news1.elcjn1.sdca.home.com>


"Guy" <guycorbett_at_my-deja.com> wrote in message news:4be5d6aa.0112110130.7eeb1602_at_posting.google.com...
> OPEN base_table_cursor;
> > FETCH base_table_cursor INTO v_dummy;
> > IF base_table_cursor%FOUND THEN
> > --
> > -- Record already exists
> > --
> > CLOSE base_table_cursor;
>
>
> Thanks for the response but I think I did not make myself clear. I
> already have a piece of code similar to the above but the insert is
> initiated by a commit_form so what I can't work out is how to handle
> the condition where the record already exists. For a new record, when
> the user presses the 'Save' icon the commit_form will insert the new
> record, commit the changes and leave the user in the form with old and
> new records displayed. They want the same behaviour for 'insertion'
> of the records which already exist but are excluded by the where
> clause. In my handling of the record-already-exists condition above I
> can sort out the other table so that it is now included in the where
> clause but then what? If I allow the insert to continue it will fail
> because of the duplicate. If I try to rollback or requery the block I
> get an error saying this is not allowed in the pre-insert trigger.
> If this is not possible I can redesign the flow of the form but this
> is not really what the user wants.

I still think it should work - unless there's something I'm still not understanding in regards to your situation.

If you put the above code in an ON-INSERT (not PRE-INSERT or POST-INSERT) trigger, it should work. ON-INSERT triggers *in place of* the default forms DML that occurs behind the scenes when you have a database block with database items in it. If you look at the code again, the cursor tests for the existence of a record in your table based on your unique key criteria for identifying an existing record. If it's found, you issue a manual update statement and the form will NOT attempt to do its own insert. If it's not found, the INSERT_RECORD forms built-in will continue with the original INSERT statement that it wanted to do.

[Quoted] Unless I'm still missing something...?

-Matt Received on Wed Dec 12 2001 - 03:31:53 CET

Original text of this message