Conditional Auto query in FormBuilder

From: Timothy H. White <MauiSpike_at_yahoo.com>
Date: 14 Jul 2003 18:01:43 -0700
Message-ID: <3a8bdeb1.0307141701.ca9dd76_at_posting.google.com>



Greetings,

I'm having a difficult time getting the following scenario to work: I would like my form to automatically query the database upon navigation out of the first item, taking the following actions:

  1. If no records are retrieved from the query: leave the value entered in the first item, position focus on the next item, and allow the user to enter a new record.
  2. If a record was found: populate the form with the data for that record, position focus on the next item, and allow the user to modify the data for that record.

I am currently using the following in the WHEN-NEW-ITEM-INSTANCE trigger for the second item on the form:



Declare
	ctrNum number(6);
	tmp_where varchar2(1000);

Begin
	-- return immediately if container not entered
	if :rc51.container is null then
		return;
	end if;
	
	if :system.mode = 'NORMAL' then
		go_block('rc51');
	

-- check if rec exists for this container.
-- if exists, do nothing via exception.
select container into ctrNum from rc51 where container = :rc51.container; ctrNum := :rc51.container; clear_block(NO_VALIDATE); tmp_where := get_block_property('rc51', default_where); set_block_property('rc51', default_where, 'where container = ' || ctrNum); execute_query; set_block_property('rc51', default_where, tmp_where); end if; EXCEPTION WHEN NO_DATA_FOUND THEN NULL;

End;


I can't get into the second item (this trigger keeps getting fired). I am limited in the triggers I can use for this, since I'm calling restricted built-in's.

Any ideas are greatly appreciated. Received on Tue Jul 15 2003 - 03:01:43 CEST

Original text of this message