Home » Developer & Programmer » Forms » insert into database problem
insert into database problem [message #466966] Wed, 21 July 2010 15:38 Go to next message
klmn
Messages: 6
Registered: July 2010
Junior Member
I have a form and 2 blocks(master-detail) and try to add a new record when I press "insert record" button from toolbar. But there occurs a problem. If I don't write 'CLEAR_FORM' just after calling "button_proc" procedure, record is not added into database.I couldn't understand why. Please somebody help.
Re: insert into database problem [message #466967 is a reply to message #466966] Wed, 21 July 2010 15:51 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
"Insert record" just opens a new (empty) record. Then - what? You fill in some values? What does the "button_proc" do? Did you, perhaps, forget to COMMIT?
Re: insert into database problem [message #466968 is a reply to message #466967] Wed, 21 July 2010 15:58 Go to previous messageGo to next message
klmn
Messages: 6
Registered: July 2010
Junior Member
No, I didnt forget. Actually I tried this with generic toolbar which was used in many examples, I did not change anything but it cannot insert. Interesting thing is whenever I add a 'CLEAR_FORM' , it accomplishes task. It is so meaningless why it does this.
Re: insert into database problem [message #466978 is a reply to message #466968] Wed, 21 July 2010 19:29 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
Again what does button_proc do?
Re: insert into database problem [message #467011 is a reply to message #466978] Thu, 22 July 2010 00:50 Go to previous messageGo to next message
klmn
Messages: 6
Registered: July 2010
Junior Member
BUTTON_PROC PROCEDURE DOES FOLLOWINGS;
PROCEDURE button_proc IS
  action varchar(80);

  -- hide a button (for ENTER_-, EXECUTE_- or CANCEL_QUERY)
  PROCEDURE show_off(item_name VARCHAR2) IS
  BEGIN
    IF NOT Id_Null(Find_Item(item_name)) THEN
      Set_Item_Property(item_name, ENABLED,PROPERTY_FALSE);
    END IF;
  END;

  -- try to show a button (for the two query-states. If there is no button to show,
  -- return FALSE to the calling procedure.
  FUNCTION show_on(item_name VARCHAR2) RETURN BOOLEAN IS
  BEGIN
    IF NOT Id_Null(Find_Item(item_name)) THEN
	    Set_Item_Property(item_name,DISPLAYED,PROPERTY_TRUE);
      Set_Item_Property(item_name,ENABLED,PROPERTY_TRUE);
      RETURN TRUE;
    ELSE
      RETURN FALSE;
    END IF;
  RETURN NULL; END;

BEGIN    
  action := Get_Item_Property(NAME_IN('SYSTEM.TRIGGER_ITEM'),ITEM_NAME);

  IF action = 'ENTER_QUERY' THEN
    -- only hide the ENTER_QUERY button, if there are EXECUTE_QUERY and (!!) CANCEL_QUERY
    -- buttons. Otherwise an existing EXECUTE_QUERY button will be shown.
    IF show_on('EXECUTE_QUERY') AND show_on('CANCEL_QUERY') THEN
      show_off('ENTER_QUERY');
    END IF;
  END IF;
  IF action IN ('EXIT_FORM', 'EXIT','QUIT') THEN
    action := 'EXIT_FORM';
    IF NAME_IN('SYSTEM.MODE')='ENTER-QUERY' THEN
      Do_Key('EXIT_FORM');
    END IF;
  END IF;
  IF action = 'CANCEL_QUERY' THEN 
    action := 'EXIT_FORM';
  END IF;
 
  Do_Key(action);
 
 IF NAME_IN('SYSTEM.MODE') != 'ENTER-QUERY' THEN
    IF show_on('ENTER_QUERY') THEN
      show_off('EXECUTE_QUERY');
      show_off('CANCEL_QUERY');
    END IF;
  END IF;
  
  
END;


[EDITED by LF: applied [code] tags]

[Updated on: Thu, 22 July 2010 00:51] by Moderator

Report message to a moderator

Re: insert into database problem [message #467013 is a reply to message #467011] Thu, 22 July 2010 00:54 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
There's no COMMIT in that procedure. But, there's no CLEAR_FORM either.

I didn't quite understand: where and how do you commit? Where did you use CLEAR_FORM?
Re: insert into database problem [message #467030 is a reply to message #467013] Thu, 22 July 2010 01:20 Go to previous messageGo to next message
klmn
Messages: 6
Registered: July 2010
Junior Member
First of all thank you for replying.

I have 'TOOLBAR' block and for example one of its items is COMMIT_FORM button. Here whenever I pressed this button, BUTTON_PROC gets its name and accomplishes commiting task.

I used CLEAR_FORM just after whenever I call BUTTON_PROC. I mean that , I created 'WHEN-BUTTON-PRESSED' trigger under 'TOOLBAR' block and in this trigger I wrote followings;

button_proc;
CLEAR_FORM;
Re: insert into database problem [message #467060 is a reply to message #467030] Thu, 22 July 2010 03:00 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I see; but, why not
button_proc;
commit;
instead?
Re: insert into database problem [message #467150 is a reply to message #467060] Thu, 22 July 2010 06:01 Go to previous message
klmn
Messages: 6
Registered: July 2010
Junior Member
It is omitted someway and I couldn't recognize. There must be a "COMMIT" Smile Thank you
Previous Topic: Vertical Scrollbal Issue
Next Topic: disable shift+tab
Goto Forum:
  


Current Time: Fri Sep 20 03:58:03 CDT 2024