Home » Developer & Programmer » Forms » updatind & inserting!!!!
updatind & inserting!!!! [message #274190] Mon, 15 October 2007 00:07 Go to next message
Dream
Messages: 11
Registered: June 2007
Location: UAE
Junior Member
hi there,

i would like to ask if anyone can answer me to give me clear idea about

updating current record and at the same time inserting new one with new ID


an example:
if i want to renew card...i want to let user add changes and the new changes will be saved as new data with new ID


hope the idea clear

i will really apperciate your help!!!

Dream
Re: updatind & inserting!!!! [message #274221 is a reply to message #274190] Mon, 15 October 2007 02:22 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Create an on-update trigger and manually perform an insert into your table using the new values. Remember to use 'standard.commit' to save your change.

David
Re: updatind & inserting!!!! [message #274239 is a reply to message #274221] Mon, 15 October 2007 03:23 Go to previous messageGo to next message
Flyhard
Messages: 21
Registered: April 2007
Location: Germany
Junior Member
djmartin wrote on Mon, 15 October 2007 09:22

Remember to use 'standard.commit' to save your change.

David


Nice. Self committing updates.... Seriously though, don't use a commit in your on-update trigger unless you want to commit ALL changes in your transaction. If you need a commit, use a stored procedure with autonomous transaction turned on.
Re: updatind & inserting!!!! [message #274244 is a reply to message #274239] Mon, 15 October 2007 03:48 Go to previous messageGo to next message
Dream
Messages: 11
Registered: June 2007
Location: UAE
Junior Member
thanks alot for all answering BUT

it do save changes but not creating NEW record with new ID???


the changes which user will add will be save as NEW RECORD

i really hope the idea clear

sorry and i do apperciate your help

may god bless you
Re: updatind & inserting!!!! [message #274369 is a reply to message #274239] Mon, 15 October 2007 20:38 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Per,

If I hadn't suggested using 'standard.commit' the next posting would have said "I did the insert but there's nothing in the database!" As the form does not 'see' the change of database state associated with the manual 'insert', the form will not do or ask whether a commit is desired when the user exits the form.

Most of the people posting in this forum are newbies. Yes, "a stored procedure with autonomous transaction turned on" is a better solution but I doubt these guys know about autonomous transactions. There is also the issue of whether the database version they are using supports it.

Also, pleae be careful about using the word 'transaction' in a Forms / Oracle environment - we'll end up with a "flame war' about its meaning.

David
Re: updatind & inserting!!!! [message #274370 is a reply to message #274244] Mon, 15 October 2007 20:38 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Tara,

Please post your code and PLEASE use 'code' tags.

David
Re: updatind & inserting!!!! [message #274450 is a reply to message #274370] Tue, 16 October 2007 01:59 Go to previous messageGo to next message
Dream
Messages: 11
Registered: June 2007
Location: UAE
Junior Member
dear all,

the idea of the system... is whenever person need to renew ID card [ pass card] then user of the system will just change some details such as expiry data and issue data and when user click on save then it will save as new record with new ID and old data will remain the same but with notic that it have been renewed!!!!

hope its clear now!!

Re: updatind & inserting!!!! [message #274452 is a reply to message #274190] Tue, 16 October 2007 02:09 Go to previous messageGo to next message
Flyhard
Messages: 21
Registered: April 2007
Location: Germany
Junior Member
You could do the changes in a dialog of a non database block, and then use it to create a new record in the DB Block (last_record; next_record;) This way you are still using the Commit of Forms for commiting.
Re: updatind & inserting!!!! [message #274466 is a reply to message #274452] Tue, 16 October 2007 03:00 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Agreed. But the 'insert' in the on-update will work, as will calling a database procedure with the new values and get it to do the 'insert' for you.

David
Re: updatind & inserting!!!! [message #274478 is a reply to message #274466] Tue, 16 October 2007 03:41 Go to previous messageGo to next message
Dream
Messages: 11
Registered: June 2007
Location: UAE
Junior Member
thanks Flyhard & David


i did write trigger on update and isnide the trigger i wrote insert code ...it gives me msg that its insert but when i check there is NO new data!!!!
Re: updatind & inserting!!!! [message #274668 is a reply to message #274478] Tue, 16 October 2007 14:47 Go to previous messageGo to next message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Did you COMMIT?
Re: updatind & inserting!!!! [message #274685 is a reply to message #274668] Tue, 16 October 2007 17:26 Go to previous messageGo to next message
mnanias
Messages: 40
Registered: September 2007
Location: AMERICA
Member
Hi,
I have a similar issue,I created a data block and i have 2 columns in it and those are related a table in DB now i should be able to update the changes made in one of those columns in that block one column is textbox and the other one is display item so now the value which is changed in text box should be updated for that i have a button called 'save' so when i click on that button it should get saved so for this i wrote the code in on-commit trigger and i did commit in when-button-pressed and when i run the code i am getting msg record updated and that to for many times how many i say ok it kept on popping up i don't know y and one more thing i have till is i also have a block which displays set of records from some other table.I wrote a simple code to update but still i am getting the error please help me in this
please let me know if i need to do any changes.

Thank you
Re: updatind & inserting!!!! [message #274693 is a reply to message #274685] Tue, 16 October 2007 19:08 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
I can't read this stuff. Use some punctuation!!!!! Then I might be able to read and understand it.

David
Re: updatind & inserting!!!! [message #274694 is a reply to message #274668] Tue, 16 October 2007 19:09 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
@Per,

What did I say about "I did the insert but there's nothing in the database!"

David
Re: updatind & inserting!!!! [message #274982 is a reply to message #274694] Thu, 18 October 2007 00:52 Go to previous messageGo to next message
Dream
Messages: 11
Registered: June 2007
Location: UAE
Junior Member
thanks alot Smile

i wrote this code in when button pressed


begin 
    if (updating) then
      insert into tbl_one
       (	                              
filed1 ,                                                               
filed2,                                        
filed3                                      
)
     
  values
        ( '	
:block_name.filed1 ,                                                                 
:block_name.filed2 ,                                        
:block_name.filed3 ' );

end if;

end;


and i got error

indentifier 'UPDATING' must be declared

[Updated on: Thu, 18 October 2007 00:54]

Report message to a moderator

Re: updatind & inserting!!!! [message #275226 is a reply to message #274982] Thu, 18 October 2007 22:37 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Put the code, without the 'IF' test in the 'on-update' trigger of your data block. Make sure you have a 'standard.commit' after your insert.

David
Previous Topic: set_menu_itme_property
Next Topic: HOW TO USE UTL_FILE PACKAGE IN ORACLE DEVELOPER
Goto Forum:
  


Current Time: Sun Feb 02 21:53:02 CST 2025