Home » Developer & Programmer » Forms » Problem with trigger.
Problem with trigger. [message #132727] Mon, 15 August 2005 20:48 Go to next message
David_nyh
Messages: 3
Registered: August 2005
Junior Member
I have a problem.

I'm building a program where I can reserve tables in a restaurant. I have a form where I have to fill in date and if I want a table where I can smoke. Then I need to click the button tables. This button needs to display another form with all the tables except the tables reserved on the date I typed in. And only the tables where you can smoke or where you can't smoke.

I have a when_validate_item trigger on form level, on the second form 'tables'

This code works fine but only if there exist one table per date.

ex. table 2 and 3 are reserved on 16 December 2005. When I put this datum in I get all the tables. But if table 2 is the only one that is reserved on 16 December 2005 I get all tables except table 2.

When_new_form_instance on form level:

DECLARE
	sWhere VARCHAR2( 500 ) := null;
	
BEGIN
	sWhere := 'tafel_id <> ( SELECT res.tafel_id FROM reservaties res 
              WHERE res.datum = :global.datum )          	
              AND rokers = :global.roken_check_box
              AND maxpers >= :global.aantalpers'; 
              
	set_block_property( 'taf', DEFAULT_WHERE, sWhere );  
	Execute_Query;
	
IF NOT Form_Success THEN
	sWhere := 'rokers = :global.roken_check_box
       AND maxpers >= :global.aantalpers';            

	set_block_property( 'taf', DEFAULT_WHERE, sWhere );  
	Execute_Query;
	raise form_trigger_failure;
END IF;  

END;
Re: Problem with trigger. [message #132745 is a reply to message #132727] Mon, 15 August 2005 23:02 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
I am not a fan of globals. I suggest that you look at adding a control (non-database) table to your form. Place your search criteria into these 'actual' items and use them in your 'where' clause. Just remember to put a "go_block('taf');" before doing the execute_query(s).

Update: at a minimum put an 'NVL' around your globals.

David

[Updated on: Mon, 15 August 2005 23:03]

Report message to a moderator

Previous Topic: Data not enter to table
Next Topic: How to use Alerts & Messages (form6i).
Goto Forum:
  


Current Time: Fri Sep 20 04:35:28 CDT 2024