Clear WHERE block on Monday Query?

Dicas do Oracle Forms Builder - Blocos, Itens, LOV, Canvas, Triggers, comandos, PLL, d2kwutil, FMB, Alert, menus, etc
Post Reply
erokshark
Rank: Estagiário Júnior
Rank: Estagiário Júnior
Posts: 2
Joined: Thu, 29 Jan 2015 2:17 pm

Hello.

I'm trying to make an appointment in a block with zip code, street, etc.
Query works perfectly, but I wanted the Forms to do the following:

- I execute Query by F7, usually seeks;
- When I press F8 again without F7, it should fetch all the information by cleaning the WHERE clause of the block.

follows the Trigger Key-Exeqry code

Select all

BEGIN 
  IF (get_block_property( name_in('SYSTEM.TRIGGER_BLOCK'), QUERY_ALLOWED) = 'FALSE') THEN 
    MESSAGE('Erro: Consulta não é permitida neste bloco'); 
    RAISE FORM_TRIGGER_FAILURE; 
  END IF; 
   
 
   
  IF name_in('SYSTEM.TRIGGER_BLOCK') = 'T0202' THEN 
  	IF :SYSTEM.MODE = 'QUERY' THEN 
  		set_block_property('T0202', DEFAULT_WHERE, ' '); 
  		:T0202.COD_CEP_TELA := NULL; 
  		CGBS$.DO_KEYQRY( name_in('SYSTEM.TRIGGER_BLOCK'), 'EXECUTE_QUERY', name_in('SYSTEM.MODE')); 
  	END IF; 
  	 
  	IF :T0202.COD_CEP_TELA IS NOT NULL THEN 
	  	set_block_property('T0202', DEFAULT_WHERE, 'T0202.COD_CEP = '||:T0202.COD_CEP_TELA); 
	  	CGBS$.DO_KEYQRY( name_in('SYSTEM.TRIGGER_BLOCK'), 'EXECUTE_QUERY', name_in('SYSTEM.MODE')); 
	  	set_block_property('T0202', DEFAULT_WHERE, ' '); 
	  ELSE 
    	CGBS$.DO_KEYQRY( name_in('SYSTEM.TRIGGER_BLOCK'), 'EXECUTE_QUERY', name_in('SYSTEM.MODE')); 
    END IF; 
  ELSE 
  	CGBS$.DO_KEYQRY( name_in('SYSTEM.TRIGGER_BLOCK'), 'EXECUTE_QUERY', name_in('SYSTEM.MODE')); 
  END IF; 
END;
User avatar
dr_gori
Moderador
Moderador
Posts: 5024
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

Topic moved to Forms.
User avatar
tiago_pimenta
Rank: DBA Júnior
Rank: DBA Júnior
Posts: 213
Joined: Wed, 29 Jun 2011 9:49 am
Location: Barretos / SP

Let me see if I understand, if the consultation is using F7 + F8, it's a certain query, now if it's just using F8, is there another query (WHERE)?
FernandesRE
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Posts: 11
Joined: Thu, 08 Jan 2015 9:22 pm

Did you ever try to make these validations in Pre-Query?
erokshark
Rank: Estagiário Júnior
Rank: Estagiário Júnior
Posts: 2
Joined: Thu, 29 Jan 2015 2:17 pm

I guess I did not explain very well, I wanted the code to run the query informed normally, but when performing the query (F7 + F8) and then press F8 again, the search would be rejected without the previously informed condition in F7. Follow code:

Select all

BEGIN 
  IF (get_block_property( name_in('SYSTEM.TRIGGER_BLOCK'), QUERY_ALLOWED) = 'FALSE') THEN 
    MESSAGE('Erro: Consulta não é permitida neste bloco'); 
    RAISE FORM_TRIGGER_FAILURE; 
  END IF; 
   
  -- Verifica se é o bloco do cep e se está em modo de consulta 
  IF name_in('SYSTEM.TRIGGER_BLOCK') = 'T0202' and 
  	 :SYSTEM.MODE = 'ENTER-QUERY' and 
  	 :T0202.COD_CEP_TELA IS NOT NULL THEN 
  	-- Define a condição de pesquisa 
  	set_block_property('T0202', DEFAULT_WHERE, 'T0202.COD_CEP = '||:T0202.COD_CEP_TELA); 
  end if; 
  -- Executa a query 
  CGBS$.DO_KEYQRY( name_in('SYSTEM.TRIGGER_BLOCK'), 'EXECUTE_QUERY', name_in('SYSTEM.MODE')); 
  -- Retira a condição definida anteriormente 
  IF name_in('SYSTEM.TRIGGER_BLOCK') = 'T0202' and 
  	 :SYSTEM.MODE <> 'ENTER-QUERY' and 
  	 :T0202.COD_CEP_TELA IS NOT NULL THEN 
  	set_block_property('T0202', DEFAULT_WHERE, ' '); 
  end if; 
 
 
END;
User avatar
tiago_pimenta
Rank: DBA Júnior
Rank: DBA Júnior
Posts: 213
Joined: Wed, 29 Jun 2011 9:49 am
Location: Barretos / SP

Look, I thought of you to fill some parameter when you press F7 and F8 verifies if this parameter is filled, if you have, OK, runs a "WHERE", if you do not, run another "WHERE" F8 F8 will become this parameter again.
FernandesRE
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Posts: 11
Joined: Thu, 08 Jan 2015 9:22 pm

Hello Erokshark!

In Pre-Query you could set the default_where always.

You can use a variable to mount the WHERE according to user-informed, something like:

Select all

 
DECLARE 
  vwhere varchar2(100); 
BEGIN 
   
  -- Verifica se é o bloco do cep e se está em modo de consulta 
  IF name_in('SYSTEM.TRIGGER_BLOCK') = 'T0202' and 
      :SYSTEM.MODE = 'ENTER-QUERY' and 
      :T0202.COD_CEP_TELA IS NOT NULL THEN 
     -- Define a condição de pesquisa 
     vwhere := 'T0202.COD_CEP = '||:T0202.COD_CEP_TELA; 
  end if; 
  -- Executa a query 
  set_block_property('T0202', DEFAULT_WHERE, vwhere); 
  CGBS$.DO_KEYQRY( name_in('SYSTEM.TRIGGER_BLOCK'), 'EXECUTE_QUERY', name_in('SYSTEM.MODE')); 
   
END; 
[]s
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 15 guests