Solved

delete details record

Posted on 2013-12-27
16
363 Views
Last Modified: 2014-01-17
hi
what is the code to delete details record in the form
thanx
0
Comment
Question by:NiceMan331
  • 7
  • 5
  • 2
  • +1
16 Comments
 
LVL 20

Expert Comment

by:flow01
ID: 39743948
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.
0
 
LVL 23

Expert Comment

by:David
ID: 39743989
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.
0
 

Author Comment

by:NiceMan331
ID: 39744547
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
0
 
LVL 20

Expert Comment

by:flow01
ID: 39745035
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
0
 

Author Comment

by:NiceMan331
ID: 39747701
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
0
 

Author Comment

by:NiceMan331
ID: 39747702
another question :
after deleting the same record , could it undo by another button ?
0
 
LVL 23

Expert Comment

by:David
ID: 39748463
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.
0
 
LVL 20

Expert Comment

by:flow01
ID: 39748582
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.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 34

Expert Comment

by:Mark Geerlings
ID: 39748721
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.
0
 
LVL 20

Accepted Solution

by:
flow01 earned 500 total points
ID: 39748828
As far as I know changing next and previous item is not necessary, and does the form automatically skip a non-key-navigable item , but if markgeer advises it , he will probably have his reasons for it.  You can easily find out for yourself. Let's hear the result.
0
 

Author Comment

by:NiceMan331
ID: 39764352
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 ?
0
 
LVL 20

Expert Comment

by:flow01
ID: 39764637
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.
0
 

Author Comment

by:NiceMan331
ID: 39764661
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
0
 
LVL 34

Expert Comment

by:Mark Geerlings
ID: 39765110
"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?
0
 

Author Comment

by:NiceMan331
ID: 39772995
"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
0
 

Author Comment

by:NiceMan331
ID: 39789523
flow
i will accept your solution
i will try your suggestions regarding deleting the table
if i fail , i will post a new topic
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
Via a live example, show how to take different types of Oracle backups using RMAN.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now