Re: FORMS 4.5: WHEN-VALIDATE-ITEM TRIGGER

From: Webmaster <w3master_at_beatrix.philips.nl>
Date: 1996/08/07
Message-ID: <3208691E.7B3B_at_beatrix.philips.nl>#1/1


Erlend Stokkedal wrote:
>
> I have a problem, with a application that i'm making, and that is with a
> When-Validate-Item trigger in Forms 4.5. The code is as follow:
>
> DECLARE
> BEGIN
> select kundenr, enavn, fnavn, adresse, postnr, psted, kundegruppe, regdato
> into :kundeblk.kundenr, :kundeblk.enavn, :kundeblk.fnavn, :kundeblk.adresse, :kundeblk.postnr,
> :kundeblk.psted, :kundeblk.kundegruppe, :kundeblk.regdato from kunde
> where kunde.kundenr = :kundeblk.kundenr;
>
> EXCEPTION
> when no_data_found then
> insert into kunde values(:kundeblk.kundenr,:kundeblk.enavn, :kundeblk.fnavn, :kundeblk.adresse,
> :kundeblk.postnr,:kundeblk.psted,:kundeblk.kundegruppe,:kundeblk.regdato);
>
>
> END;
>
> This trigger is fired from the customernr field and the intention of this
> trigger is to find out if there is a customer registered with a spesific
> customer number. If there is a customer with e.g customernr 3 then all the
> fields are filled out with the information about that customer. This works
> fine, but when i want the program to be able to accept my values that i put
> into the fields if the customer number is not occupied then i got this message:
>
> FRM 40508: ORACLE error: Unable to INSERT record.
>
> Can anyone please help me?
>
> Best regards from Erlend:-)

Hi Erlend,

Would be nice to have the definition of your table KUNDE but here are some
possible error sources:

- the value of one of your parameters is violating a table constraint
- your parameters are not in the right order (but right amount)
- you don't have INSERT privileges in the block or for the table KUNDE

Anyway, the whole procedure looks strange to me...

BTW are we talking about BASE TABLE ITEMS??? In case

:kundeblk.kundenr,
:kundeblk.enavn, 
:kundeblk.fnavn, 
:kundeblk.adresse,
:kundeblk.postnr,
:kundeblk.psted,
:kundeblk.kundegruppe,
:kundeblk.regdato 

have set the BASE TABLE ITEM property set to TRUE this will change everything!

If so, your must be aware that you are navigating in a set of records! Everytime you change a value in one of the fields you changed the value in the record!

To perform the same what you want make sure first that: - you save the value first of the KUNDENR field in order to restore it   afterwards
- assuming somebody inserts a value into this field which if different from
  the value of the actual record you have to find out the number of the record
  in the block and go to this record via GO_RECORD - in case somebody inserts a new value use INSERT_RECORD first and let the user
  edit the new record.
- don't forget to restore the old KUNDENR value of the record you started first

  • Be aware that when using INSERT you won't see the newly inserted record immediately! You will need a COMMIT and afterwards fetching the records again into the block.

I know that this information may be insufficient but my proposals are based on assumptions about your structures. Make sure to detail your next request!

-- 

Kind regards,

Bernd Buchegger (Webmaster)
Marketing Communications Publishing Services
Philips Semiconductors
Building BEp-42b
P.O. Box 218
5600 MD  Eindhoven
The Netherlands

Fax:            +31 40 2724825
Phone:          +31 40 2724684
Internet:       w3master_at_ehv.sc.philips.com
                Bernd.Buchegger_at_ehv.sc.philips.com

---=> LET'S MAKE THINGS BETTER <=---
Received on Wed Aug 07 1996 - 00:00:00 CEST

Original text of this message