I have a question and I would like to know if it is possible to solve.
I created a trigger on a table and it is working perfectly. I make a validation and if you enter a particular condition shows an error message. The message appears in the Forms rodape.
I would like to know if you can view this type an alert message ... When you enter the condition the system displays an alert on the screen.
CREATE OR REPLACE TRIGGER DBAMV.TRG_U_VERIF_CD_IMATEC
Before update
ON dbamv.same_caixa
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
--Pragma Autonomous_Transaction;
Begin
IF (UPDATING) THEN
DECLARE
Cursor cCD_IMATEC Is
SELECT count(*)
FROM dbamv.same_caixa_agrupamento
WHERE cd_imatec = :new.cd_imatec;
vqt_imatec NUMBER;
Begin
OPEN cCD_imatec;
FETCH cCD_imatec INTO vqt_imatec;
Close cCD_imatec;
IF :new.cd_imatec > 0 then
IF vqt_imatec > 0 Then
raise_application_error( -20002, 'Código Imatec já utilizado !!! = '||vqt_imatec);
END IF;
END IF;
END;
END IF;
End;
/
1-Why does not verify the triggers of Forms itself? Since it is a simple validation and not increasing the complexity of the structure and business in the database.
2- Depending still on the business maybe Conferints Unique on the table resolves your problem of having to create triggers.
I have already created a primary key in the table .... so far quiet. If the person tries to save the information by pressing F10 for example the forms ta an error in the footer and does not let save ...
The idea was to show this message on an even alert. Type (the code is already being used, please try another code ...).
I am not very experienced in forms development .... when you speak to use the triggers of own forms, where do I use?
There are a few ways but you can, for example, create a pre-insert trigger (in the case of insertion) in the data block that has your information. Then you would be the consultation if the id exists and launches the alert, preventing its recording.
I took the test today again. Only this time did not display any alert ....
only the error in the footer: frm-40509 Oracle error: It is not possible to update the registry. (due to trigger)
Detail, Query in this case is returning 1
declare
Vresult number(5);
alerta number(5);
begin
SELECT count(*) into Vresult
FROM dbamv.same_caixa_agrupamento
WHERE cd_imatec = :same_caixa.cd_imatec;
if Vresult >= 1 then
set_alert_property('alert_caixa',alert_message_text,'Código já utilizado, por favor utilizar outro código !!!' );
alerta:=show_alert('alert_caixa');
end if;
end;
When I put the code above in the pre-insert (this in the block) did not display the alert. Remembering that I have a trigger in the table that validates this information.
it works good. As this validating the field it shows the alert normally.
The idea was to know if it is possible to get this error that the table trigger generates and displaying the alert in the system ....
but of any I'm going to go using the field validation for now.
when you click to exit the form validates the data and displays the message. But only displays the message the first time, if I click the field again and then click to exit the forms no longer displays the message.
Is it possible to let it always display the message until the user changes the data in the field? Type will only be able to go to the next field if the value is correct.
After I displayed the alert I put to return to the item with: