Display Alert in Forms

Dicas do Oracle Forms Builder - Blocos, Itens, LOV, Canvas, Triggers, comandos, PLL, d2kwutil, FMB, Alert, menus, etc
Post Reply
douglasmattos
Rank: Analista Júnior
Rank: Analista Júnior
Posts: 75
Joined: Mon, 19 Mar 2012 2:28 pm

Good morning!

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.

follows trigger.

Select all

 
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; 
/ 
 
DanielNN
Moderador
Moderador
Posts: 641
Joined: Mon, 03 Sep 2007 3:26 pm
Location: Fortaleza - CE
att,

Daniel N.N.

Hello,

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.
douglasmattos
Rank: Analista Júnior
Rank: Analista Júnior
Posts: 75
Joined: Mon, 19 Mar 2012 2:28 pm

Danielnn,

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?
DanielNN
Moderador
Moderador
Posts: 641
Joined: Mon, 03 Sep 2007 3:26 pm
Location: Fortaleza - CE
att,

Daniel N.N.

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.
douglasmattos
Rank: Analista Júnior
Rank: Analista Júnior
Posts: 75
Joined: Mon, 19 Mar 2012 2:28 pm

I understood,

I'll take a test here.
douglasmattos
Rank: Analista Júnior
Rank: Analista Júnior
Posts: 75
Joined: Mon, 19 Mar 2012 2:28 pm

Good morning,

I took the test and did not work. In Pre-Insert Forms brings an alert for each record ...

:(
DanielNN
Moderador
Moderador
Posts: 641
Joined: Mon, 03 Sep 2007 3:26 pm
Location: Fortaleza - CE
att,

Daniel N.N.

Can you post the Trigger from the forms block?
douglasmattos
Rank: Analista Júnior
Rank: Analista Júnior
Posts: 75
Joined: Mon, 19 Mar 2012 2:28 pm

Good morning Danielnn.

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

This was the code I tested here:

Select all

 
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;	 
 
DanielNN
Moderador
Moderador
Posts: 641
Joined: Mon, 03 Sep 2007 3:26 pm
Location: Fortaleza - CE
att,

Daniel N.N.

Hello,

Place the following line, shortly after the alert, to indicate that trigger gave problem:

Select all

RAISE FORM_TRIGGER_FAILURE;
You can, as an alternative, have a trigger " When_validate-item "in the specific field that wants to validate.
douglasmattos
Rank: Analista Júnior
Rank: Analista Júnior
Posts: 75
Joined: Mon, 19 Mar 2012 2:28 pm

I did the tests with those of the options.

Select all

RAISE FORM_TRIGGER_FAILURE;
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.

If I use the

Select all

WHEN_VALIDATE-ITEM
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.
douglasmattos
Rank: Analista Júnior
Rank: Analista Júnior
Posts: 75
Joined: Mon, 19 Mar 2012 2:28 pm

I placed the validation in the field with

Select all

WHEN_VALIDATE-ITEM
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:

Select all

go_item(':same_caixa.cd_imatec');
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 11 guests