Avatar of NiceMan331
NiceMan331 asked on

delete details record

hi
what is the code to delete details record in the form
thanx
Oracle Database

Avatar of undefined
Last Comment
NiceMan331

8/22/2022 - Mon
flow01

basicaly

go_block('details');
delete_record;

But somehow I expect this might  not bring you the behaviour you want. If that is true , try telling some more.
David VanZandt

Is this really an Oracle question, with ADF, or an old Forms app?  And are you trying to resolve something specific to the form, as compared to the underlying SQL?  Versions and specifics, please.
ASKER
NiceMan331

oracle 10g
forms 6i
i have form : master/details
i want to set the cursor on one record on the details then click the button to delete it
exactly as you use shift f6
Your help has saved me hundreds of hours of internet surfing.
fblack61
flow01

add a when_button_pressed trigger to the button

begin
  delete_record;
end;

beware : it could mimic shift f6 also when the cursor is in the master block
ASKER
NiceMan331

yes , it was my mistake
i forget to put the button on the details block
it is ok now
but still one issue :
this button now included in the navigation of the record
how i can avoid it from the navigation to let the cursor move directly to the next record without passing that button ?
i know putting it on the master will solve the issue , but what about the current issue
ASKER
NiceMan331

another question :
after deleting the same record , could it undo by another button ?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
David VanZandt

Assuming your delete button does an auto-commit, I'd advise a qualified no.  Once the transaction has been committed, a prior state may be recovered with flashback logs -- but I'd hate to see that coded into a control.
flow01

Navigation
look at the properties of your button ,
keep it enabled but set keyboard and mouse navigation to no.

The delete_record marks the row as deleted within the Oracle form and the record is not yet deleted in the database. The changes are applied to the database if you use the POST or COMMIT build-ins.
Oracle forms by default asks to commit  al the changes made in the form that are  not yet committed,
if you don't accept  the delete will not be posted to the database , but also al other changes in this form after the last commit will be lost.

You can also issue a savepoint you can return to (as does oracle forms when entering a new form), but unless very much needed I would relay on standard behaviour of Oracle Forms. Deviation without knowledge is asking for trouble.
Mark Geerlings

In addition to setting "keyboard and mouse navigation to no" for this button, also go to the properties page for the previous item in the details block and choose a value for "Next Navigation Item" to the item in this block that you want the cursor to skip ahead to when the user presses the [Tab] key, and go to the properties page for the next item in this block (or the first item, if this "delete" button is the last item in the block) and choose a value for "Previous Navigation Item" that the cursor should skip back to if the user presses [Shift]-[Tab].

"after deleting the same record , could it undo by another button ?"
The simple answer: no.

First, how could this button know which record you would want it to undelete?  Then, depending on exactly what action you have the "delete" button do, reversing that action could be complex, expecially if you include a "post" or "commit" in the delete button.  If the delete button just does a "delete_record" then you could easily reverse that with a "clear_block".  But, this will reverse more than just any deletes that have been done.  This will undo everything since the latest save.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
flow01

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
NiceMan331

sorry for delay
i were in hospital
flow are right
i tried setting navigation keyboard & mouse to no , it is enough
correct
actually the question answered already , if you like , i could open a new question for the next

regarding delete record , your logic is correct also if the record previously saved
then no need to accept the changes when the form ask
but my issue is if i'm posting new main record , having for example 1000 records as details
ok , while typing those thousands , i deleted one record , then i found that it should not be deleted , here the total record not yet saved in the database
is there any way to retrieved that deleted record ?
flow01

Yes.  Create  a extra table simular to your detail-records . (detail_del)
Create a procedure with a  pragma autonomous_transaction  to store records ,
and as argument the record_type of the detail-record.  In the procedure insert the (detail_del) record.

call the procedure before issuing the delete_record built in.

Lot's of trouble ahead :  do you also want to store updates, if there are more deleted records how to retrieve the good one,  what to happens if you delete, enter a new record your self with the same primary key and try to get back the deleted_record and so on.
ASKER
NiceMan331

Create a procedure with a  pragma autonomous_transaction  to store records ,

is it special procedure ? i didn't hear before about it
but any how , i understood your idea , it is really smart one

do you also want to store updates
if there are more deleted records how to retrieve the good one,  

here i would like to retrivet the last one delted or updated , it is enough for me
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Mark Geerlings

"is it special procedure?"
Yes, this would be a "special" or at least a custom procedure, since you would need to write this for your application.

"i didn't hear before about it"
What exactly do you mean by "it" here?  Do you mean this: "pragma autonomous_transaction"?

That is a way to have a procedure commit its work independent of whether your main application does a commit, or not.

" i understood your idea, it is really smart one"
Be careful!  Adding complexity is not always a good idea.

"I would like to retrieve the last one deleted or updated".  This could get complex.  Will there only be one user doing this work at a time?  Most applications allow multiple poeple to make changes at about the same time.  Do you have to be able to retrieve the latest one for the current user?
ASKER
NiceMan331

"I would like to retrieve the last one deleted or updated".  This could get complex.  Will there only be one user doing this work at a time?  Most applications allow multiple poeple to make changes at about the same time.  Do you have to be able to retrieve the latest one for the current user?



actuallt they are one use only
ASKER
NiceMan331

flow
i will accept your solution
i will try your suggestions regarding deleting the table
if i fail , i will post a new topic
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23