Home » Developer & Programmer » Forms » Saving Forms
Saving Forms [message #292043] Mon, 07 January 2008 10:10 Go to next message
daibatzu
Messages: 34
Registered: September 2007
Member
Hello, I am creating a form to save data to a table. Now, this table has columns like last_updated_by, last_update_date e.t.c. For my forms I am using the commit_form PL SQL code for saving the form. Is there a way for me to update these values each time a form is saved without showing them on the form? Also, how can I get the name of the person who updates the data as well, in other words a record history?
Thanks
Re: Saving Forms [message #292057 is a reply to message #292043] Mon, 07 January 2008 10:42 Go to previous messageGo to next message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
daibatzu

... without showing them on the form
Change their "Visible" properties to "No" (or set its Canvas to <Null>).
Quote:

how can I get the name of the person who updates the data
Use the GET_APPLICATION_PROPERTY built-in:
declare
  l_username varchar2(30);
begin
  l_username := get_application_property(username);
  -- now do something with this value, such as
  UPDATE your_table SET
    last_updated_by = l_username,
    last_update_time = sysdate
  WHERE ...
end;
Re: Saving Forms [message #292113 is a reply to message #292043] Mon, 07 January 2008 21:27 Go to previous messageGo to next message
mintomohan
Messages: 104
Registered: November 2006
Location: India
Senior Member
hi,

you can write the following code in the PRE-INSERT trigger of the data block.

:BLOCK.LAST_UPDATED_BY := :GLOBAL.APPLICATION_USER;
:BLOCK.LAST_UPDATE_DATE := SYSDATE;


You can create a global variable called APPLICATION_USER to store the name of the user.

Minto
Re: Saving Forms [message #292152 is a reply to message #292043] Tue, 08 January 2008 01:25 Go to previous messageGo to next message
daibatzu
Messages: 34
Registered: September 2007
Member
Wow, thanks a lot guys
Re: Saving Forms [message #292411 is a reply to message #292152] Tue, 08 January 2008 21:59 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
You could also write a database trigger to populate these fields.

Have you handled updates as well as inserts? Do you need to know who deleted a record?

David

Up: Doh, I had 'how' instead of 'who' again.

[Updated on: Wed, 09 January 2008 19:30]

Report message to a moderator

Re: Saving Forms [message #292502 is a reply to message #292043] Wed, 09 January 2008 01:40 Go to previous messageGo to next message
daibatzu
Messages: 34
Registered: September 2007
Member
Hi djmartin, those are good points. I've only been able to save using commit_form on the "when button pressed" condition.
How about if I wanted to use the save button in oracle instead.
How would I write the PL code for saving the form details in that situation?
I'm googling into writing database triggers at the moment.
Re: Saving Forms [message #292777 is a reply to message #292502] Wed, 09 January 2008 19:34 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
I am a strong believer in database triggers for populating 'audit' fields therefore I DON'T write code in my forms to save these details. But if I did I would put it into the pre-insert and pre-update triggers. The delete information would have to be handled a different way.

The supplied 'save' button works with the triggers I mentioned above.

David
Re: Saving Forms [message #292941 is a reply to message #292043] Thu, 10 January 2008 03:56 Go to previous message
daibatzu
Messages: 34
Registered: September 2007
Member
That's an interesting tip. Thank you.
Previous Topic: How to capture the Oracleforms error
Next Topic: Scanning directly from oracle forms
Goto Forum:
  


Current Time: Sun Dec 11 02:31:28 CST 2016

Total time taken to generate the page: 0.11432 seconds