When-validate-item

Dicas do Oracle Forms Builder - Blocos, Itens, LOV, Canvas, Triggers, comandos, PLL, d2kwutil, FMB, Alert, menus, etc
Post Reply
lelostyle
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Posts: 9
Joined: Thu, 09 Jul 2009 9:59 pm
Location: SP

Good afternoon guys,

Thanks for opening this space for help. Come on

I need to do a when-validate-item in three fields that I have in my forms. The fields are as follows well, carc and branch of the table
branch_carac_bem_segurado. At the time that will use you type verify if it exists in the table, if it exists let me insert, if not from MSG speaking that does not exist. As I am a beginner I am finding difficulties, if someone can give me a light.


gratoo

Lelo
Jezper
Rank: Programador Pleno
Rank: Programador Pleno
Posts: 36
Joined: Mon, 17 Aug 2009 11:02 am
Location: Gaspar-SC
Jeziel Peres

PL/SQL - Forms 6i

It makes a condition in this validate in which Verefica on the table ... or Nesao assembles your condition in a procedure and only calls it in the validity.

creates a procedure where in it you do the select with any conditions and then just calls this procedure in the validate.

If it is not really this your difficulty speaks, try to explain better and post aqui your current code.
lelostyle
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Posts: 9
Joined: Thu, 09 Jul 2009 9:59 pm
Location: SP

Jeziel,

Thanks for help.

Now it even cleared, but it turns out that my code is not funny, it's not validating anything in the field, can you check what I'm wrong?

follows

Select all

begin 
	select	count(1) 
	into	:radesc.cd_tipo_bem_segurado  
	from	RAMO_CARAC_BEM_SEGURADO 
	where	cd_tipo_bem_segurado	=	:radesc.cd_tipo_bem_segurado; 
exception 
	when	no_data_found	then 
		mensagem ('Tipo Bem Segurado não Cadastrado.'); 
		raise form_trigger_failure; 
	when	others	then 
		mensagem ('Problemas ao Selecionar Registro em TIPO_BEM_SEGURADO. Erro: '||sqlerrm||' - (when-validate-item - controle.cd_tipo_bem_segurado).'); 
		raise form_trigger_failure; 
end; 
 
If you can help me !!!
Gratooo
Lelooo
User avatar
NightSpy
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 49
Joined: Tue, 09 Sep 2008 4:18 pm
Location: SP

Face using count, will never give when no_data_found, porque to fall in this error and lock the program, have to come back null in your select and using the count will never return null, at most 0 .... alias, so no need to use Exception with a Select count ...

I did not understand why you played the select result in the place of the value that you typed on the screen and you used it on the wher.

It would be interesting to declare a variable ... Thus:

Select all

 
Declare 
   aux number; 
Begin 
   select count(*) into aux 
   from   RAMO_CARAC_BEM_SEGURADO 
   where   cd_tipo_bem_segurado   =   :radesc.cd_tipo_bem_segurado;  
    
   if aux = 0 then 
      mensagem ('Tipo Bem Segurado não Cadastrado.'); 
      raise form_trigger_failure;  
   end if; 
end; 
SergioLBJr
Rank: Oracle Guru
Rank: Oracle Guru
Posts: 448
Joined: Tue, 16 Jun 2009 3:07 pm
Location: Parobé - RS
Sérgio Luiz Bonemberger Junior
Programador Junior
Parobé RS

[]s

It does not make a SELECT INTO, in a block field, even because you do not need it.

Select all

 
declare 
  cursor c_teste is 
    select  1  
    from   RAMO_CARAC_BEM_SEGURADO  
    where   cd_tipo_bem_segurado   =   :radesc.cd_tipo_bem_segurado;  
begin 
  open c_teste ; 
  if c_teste%notfound then 
    mensagem ('Tipo Bem Segurado não Cadastrado.');  
    raise form_trigger_failure;  
  end if; 
  close c_teste; 
exception  
   when   others   then  
      mensagem ('Problemas ao Selecionar Registro em TIPO_BEM_SEGURADO. Erro: '||sqlerrm||' - (when-validate-item - controle.cd_tipo_bem_segurado).');  
      raise form_trigger_failure;  
end;  
should work, if error occurs, post in forms.
Jezper
Rank: Programador Pleno
Rank: Programador Pleno
Posts: 36
Joined: Mon, 17 Aug 2009 11:02 am
Location: Gaspar-SC
Jeziel Peres

PL/SQL - Forms 6i

The SERGIOLBJR SELECT ESA correct ...
I still do not understand very well what you want ....
lelostyle
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Posts: 9
Joined: Thu, 09 Jul 2009 9:59 pm
Location: SP

Personal,

Thank you for help until now.

It turns out that neho of the two funfo I do not know the reason.

I have 3 fields well, Cara and branch of the branch_carac_bem_segurado table.

I need to insert the information in the Forms field, verify that it is valid in the bank, for example:

Inserts branch 1, if validated leaves Insert, otherwise the message notifying that there is no branch, and do for the other fields também.

Some simple suggestion so that besides making I can understand.

gratoo

Leloooo
SergioLBJr
Rank: Oracle Guru
Rank: Oracle Guru
Posts: 448
Joined: Tue, 16 Jun 2009 3:07 pm
Location: Parobé - RS
Sérgio Luiz Bonemberger Junior
Programador Junior
Parobé RS

[]s

What happened??? What was the mistake that trigger fired ???
lelostyle
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Posts: 9
Joined: Thu, 09 Jul 2009 9:59 pm
Location: SP

The worst of td is that no error !!!
Performs good, the problem is not that the message preventing the user insert.

Valeww
Jezper
Rank: Programador Pleno
Rank: Programador Pleno
Posts: 36
Joined: Mon, 17 Aug 2009 11:02 am
Location: Gaspar-SC
Jeziel Peres

PL/SQL - Forms 6i

So put a clause preventing it there ... there shows the message, then put a clause that prevails the user from performing this function ...

This message has q of the only when he commits or when he Inserts the data ???
lelostyle
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Posts: 9
Joined: Thu, 09 Jul 2009 9:59 pm
Location: SP

Good morning, thank you for the help so far.
is the following I think the problem is in a function that is already in the forms that treats all kinds of error, is that why is not it validating?

Gratoo
lelostyle
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Posts: 9
Joined: Thu, 09 Jul 2009 9:59 pm
Location: SP

That's only when it inserts the data in the field !!!!
Jezper
Rank: Programador Pleno
Rank: Programador Pleno
Posts: 36
Joined: Mon, 17 Aug 2009 11:02 am
Location: Gaspar-SC
Jeziel Peres

PL/SQL - Forms 6i

You showing that it is registered or not registered or may or may not register, a user who has already a table.

This means that confused this. Try it to be clearer .. from which you messages you to bar the registration user?
SergioLBJr
Rank: Oracle Guru
Rank: Oracle Guru
Posts: 448
Joined: Tue, 16 Jun 2009 3:07 pm
Location: Parobé - RS
Sérgio Luiz Bonemberger Junior
Programador Junior
Parobé RS

[]s

Dude if you think the problem is in the function that treats the mistakes, then put it in the forum, or comment where it is clinging call and checks if it will treat.
lelostyle
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Posts: 9
Joined: Thu, 09 Jul 2009 9:59 pm
Location: SP

I want you to type the user type and try to move to the next field, display the message Senao exists.

has this function that treats errors follows, and by the way there is some screens:

Select all

FUNCTION ERROS (TIPO_ERRO IN VARCHAR2, 
                CODIGO_ERRO IN NUMBER, 
                TEXTO_ERRO IN VARCHAR2) 
                RETURN VARCHAR2 IS 
  V_MENSAGEM    VARCHAR2(300) := TEXTO_ERRO; 
BEGIN 
  IF CODIGO_ERRO = 40100 THEN 
     V_MENSAGEM := TIPO_ERRO||'-'||TO_CHAR(CODIGO_ERRO)||':'||' Primeiro registro.'; 
  ELSIF CODIGO_ERRO = 40102 THEN 
        V_MENSAGEM := TIPO_ERRO||'-'||TO_CHAR(CODIGO_ERRO)||':'||' Registro deve ser informado ou excluido.'; 
  ELSIF CODIGO_ERRO IN (40200, 41008) THEN 
        V_MENSAGEM := TIPO_ERRO||'-'||TO_CHAR(CODIGO_ERRO)||':'||' Campo protegido contra atualização.'; 
  ELSIF CODIGO_ERRO = 40202 THEN 
        V_MENSAGEM := TIPO_ERRO||'-'||TO_CHAR(CODIGO_ERRO)||':'||' Campo deve ser informado.'; 
  ELSIF CODIGO_ERRO = 40207 and substr(V_MENSAGEM,1,16) = 'Must be in range' THEN 
        V_MENSAGEM := TIPO_ERRO||'-'||TO_CHAR(CODIGO_ERRO)||':'||replace(V_MENSAGEM, 'Must be in range', ' Valor deve estar entre'); 
        V_MENSAGEM := replace(V_MENSAGEM, 'to', 'e'); 
  ELSIF CODIGO_ERRO = 40209 and substr(V_MENSAGEM,1,21) = 'Field must be of form' THEN 
        V_MENSAGEM := TIPO_ERRO||'-'||TO_CHAR(CODIGO_ERRO)||':'||replace(V_MENSAGEM, 'Field must be of form', ' Campo deve respeitar o formato de'); 
  ELSIF CODIGO_ERRO = 40212 and substr(V_MENSAGEM,1,23) = 'Invalid value for field' THEN 
        V_MENSAGEM := TIPO_ERRO||'-'||TO_CHAR(CODIGO_ERRO)||':'||replace(V_MENSAGEM, 'Invalid value for field', ' Valor inválido para o campo'); 
  ELSIF CODIGO_ERRO = 40401 THEN 
     V_MENSAGEM := TIPO_ERRO||'-'||TO_CHAR(CODIGO_ERRO)||':'||' Não há transações para serem efetivadas.';  
  ELSIF CODIGO_ERRO = 40501 THEN 
     V_MENSAGEM := TIPO_ERRO||'-'||TO_CHAR(CODIGO_ERRO)||':'||' Registro não poderá ser alterado ou excluído, pois está sendo alterado por outro usuário.';  
  ELSIF CODIGO_ERRO = 40508 THEN 
     V_MENSAGEM := TIPO_ERRO||'-'||TO_CHAR(CODIGO_ERRO)||':'||' ERRO ORACLE: Problema ao inserir um registro. Favor entrar em contato com o suporte.';  
  ELSIF CODIGO_ERRO in (41000, 41009) THEN 
        V_MENSAGEM := TIPO_ERRO||'-'||TO_CHAR(CODIGO_ERRO)||':'||' Função não disponível.'; 
  ELSIF CODIGO_ERRO = 41051 THEN 
        V_MENSAGEM := TIPO_ERRO||'-'||TO_CHAR(CODIGO_ERRO)||':'||' Proibida a criação de registros.'; 
  ELSIF CODIGO_ERRO = 41830 THEN 
        V_MENSAGEM := TIPO_ERRO||'-'||TO_CHAR(CODIGO_ERRO)||':'||' Lista de Valores não contém dados.'; 
  ELSIF CODIGO_ERRO = 41049 THEN 
	V_MENSAGEM := TIPO_ERRO||'-'||TO_CHAR(CODIGO_ERRO)||':'||' Registro Não pode ser Excluído';  
  ELSIF CODIGO_ERRO = 40702 THEN 
	V_MENSAGEM := TIPO_ERRO||'-'||TO_CHAR(CODIGO_ERRO)||':'||' Favor SALVAR ou CANCELAR as alterações feitas antes de mudar de tela';  
  ELSIF CODIGO_ERRO = 40403 THEN 
	V_MENSAGEM := TIPO_ERRO||'-'||TO_CHAR(CODIGO_ERRO)||':'||' Esta transação não pode ser Salvada pois há telas anteriores que ainda NÃO foram salvas!. Sair SEM SALVAR desta tela e salvar primeiro as telas pendentes!.';  
  ELSIF CODIGO_ERRO IN (40358, 50002, 50003, 50004) THEN 
	V_MENSAGEM := TIPO_ERRO||'-'||TO_CHAR(CODIGO_ERRO)||':'||' Data Inválida.';  
  ELSIF CODIGO_ERRO = 40509 THEN 
	if substr(get_application_property (CURRENT_FORM_NAME),1,4) = 'SINI' then 
		V_MENSAGEM := TIPO_ERRO||'-'||TO_CHAR(CODIGO_ERRO)||':'||' Erro ao atualizar. Tabela pode não existir ou falta privilégio p/processar operação. Clique em <SHIFT> + <F1> p/verificar o erro e contacte a equipe da SIMETRIAS.(Ramal 7651)';  
	else 
		V_MENSAGEM := TIPO_ERRO||'-'||TO_CHAR(CODIGO_ERRO)||':'||' Erro ao atualizar. Tabela pode não existir ou falta privilégio p/processar operação. Clique em <SHIFT> + <F1> p/verificar o erro e contacte a área de SISTEMAS(Ramais 7651,7647 e 7652).';  
	end if; 
  ELSIF CODIGO_ERRO IN (40356, 50016) THEN 
	V_MENSAGEM := TIPO_ERRO||'-'||TO_CHAR(CODIGO_ERRO)||':'||' Conteúdo Inválido para Campo Numérico.';  
  ELSIF CODIGO_ERRO = 50025 THEN 
	V_MENSAGEM := TIPO_ERRO||'-'||TO_CHAR(CODIGO_ERRO)||':'||' Dia e Hora devem ser informados no seguinte formato : DD/MM/AAAA HH:MI.';  
  ELSIF CODIGO_ERRO = 28000 THEN 
	V_MENSAGEM := TIPO_ERRO||'-'||TO_CHAR(CODIGO_ERRO)||':'||' Tentativa de conexão bloqueada. Para desbloqueio, comunicar-se c/Depto Sistemas (7651, 7652, 7647). Se o erro não foi da sua digitação, checar quem está tentando utilizar a sua senha.'; 
  ELSIF CODIGO_ERRO = 50026 THEN 
	V_MENSAGEM := TIPO_ERRO||'-'||TO_CHAR(CODIGO_ERRO)||':'||' Campo deve respeitar o formato de dd/mm/yyyy.';  
  ELSE 
     V_MENSAGEM := TIPO_ERRO||'-'||TO_CHAR(CODIGO_ERRO)||' '||TEXTO_ERRO; 
  END IF; 
  RETURN(V_MENSAGEM); 
END; 
]] Thank you for help for help
SergioLBJr
Rank: Oracle Guru
Rank: Oracle Guru
Posts: 448
Joined: Tue, 16 Jun 2009 3:07 pm
Location: Parobé - RS
Sérgio Luiz Bonemberger Junior
Programador Junior
Parobé RS

[]s

I doubt much that this function is your problem.

Do the following:
Display the result of your SELECT:

Select all

 
declare  
  cursor c_teste is  
    select  1  
    from   RAMO_CARAC_BEM_SEGURADO  
    where   cd_tipo_bem_segurado   =   :radesc.cd_tipo_bem_segurado;  
begin  
  open c_teste ;  
  if c_teste%notfound then  
    mensagem ('Tipo Bem Segurado não Cadastrado.');  
    raise form_trigger_failure;  
  else 
     mensagem ('Achei'); 
  end if;  
  close c_teste;  
exception  
   when   others   then  
      mensagem ('Problemas ao Selecionar Registro em TIPO_BEM_SEGURADO. Erro: '||sqlerrm||' - (when-validate-item - controle.cd_tipo_bem_segurado).');  
      raise form_trigger_failure;  
end; 
[code]
SergioLBJr
Rank: Oracle Guru
Rank: Oracle Guru
Posts: 448
Joined: Tue, 16 Jun 2009 3:07 pm
Location: Parobé - RS
Sérgio Luiz Bonemberger Junior
Programador Junior
Parobé RS

[]s

If I find it, he can insert.
Jezper
Rank: Programador Pleno
Rank: Programador Pleno
Posts: 36
Joined: Mon, 17 Aug 2009 11:02 am
Location: Gaspar-SC
Jeziel Peres

PL/SQL - Forms 6i

Select all

declare 
cursor c_teste is 
select cd_tipo_bem_segurado 
from RAMO_CARAC_BEM_SEGURADO 
where cd_tipo_bem_segurado = :radesc.cd_tipo_bem_segurado 
and ROWNUM = 1; 
begin 
open c_teste ; 
if c_teste%notfound then 
mensagem ('Tipo Bem Segurado não Cadastrado.'); 
raise form_trigger_failure; 
else 
mensagem ('Achei'); 
end if; 
close c_teste; 
exception 
when others then 
mensagem ('Problemas ao Selecionar Registro em TIPO_BEM_SEGURADO. Erro: '||sqlerrm||' - (when-validate-item - controle.cd_tipo_bem_segurado).'); 
raise form_trigger_failure; 
end; 

Despite being very much like Sergio and maybe do the same function, tests this because if não is that I really know what you want! !!!!!!!!!!
lelostyle
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Posts: 9
Joined: Thu, 09 Jul 2009 9:59 pm
Location: SP

Thank you very much, help from you was real importance !!!
The problem was in an old triggers here they had, and as I am new in the area and also in the company did not know.

But these last two SELECTS helped me !!!
valeu

T +
Post Reply
  • Information
  • Who is online

    Users browsing this forum: Bing [Bot] and 1 guest