Solved

apex logical delete

Posted on 2012-03-28
11
860 Views
Last Modified: 2012-03-28
Hi
in my application i have
I have a form with report and buttons add row, delete and cancel.

this is tabular form with checkboxes. when i clicke on delete button after checking the check boxes it is deleting in the database completely but my requirement
i want to customize the delete process and when checkbox checked
that record should update in emp table as logical_delete='Y'

How can we customize the delete as follow in a process associated with delete button
update emp set logical_delete='Y' where check box checked is true.
 
 thanks in advance.
0
Comment
Question by:vsarma50
  • 5
  • 3
  • 3
11 Comments
 
LVL 73

Expert Comment

by:sdstuber
ID: 37776873
Are you letting APEX manage the dml for you automatically?  If so, you'll have to change it and write your own processing instructions on submit.
0
 
LVL 20

Expert Comment

by:gatorvip
ID: 37776916
Create a PL/SQL page process whose only action is to perform the update while looping through your tabular form.
Set the execution point for this process (under Conditions) to the Delete button being pressed.
Disable the current deletion by setting its conditional clause to Never (or remove it altogether)

Your loop will look something like this:

for i IN 1..APEX_APPLICATION.G_F01.COUNT
loop

if apex_application.g_f<nn>(i) = <value>  then
update emp 
set logical_delete='Y'
where.... ;
end if;
end loop;

Open in new window


where you need to replace <nn> and <value> with your actual values
0
 

Author Comment

by:vsarma50
ID: 37777046
i didn't understand the below line as I want the selected to be deleted. but how can iget the row selector name. here my chekbox created by apex is
if apex_application.g_f<nn>(i) = <value>  then

if apex_application.g_f [row selector] (i) = 'checked'  then
of
if apex_application.g_f EMPID(i) = TRUE  then

giving me error
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 20

Expert Comment

by:gatorvip
ID: 37777090
Typically I get the <nn> values by looking at the page source of the generated HTML code.  Typically it's a two digit number.

The checkbox value is whatever you allow it to be when you create the checkbox
0
 

Author Comment

by:vsarma50
ID: 37777754
when i wrote code as follow it is deleting all rows i want to delete only selected row

for i IN 1..APEX_APPLICATION.G_F01.COUNT
loop
if APEX_APPLICATION.G_F01(i)=1 THEN
update emp set LOGICAL_DELETE ='Y';
--where empID=APEX_APPLICATION.G_F01(i);
end if;
end loop;

if i have condition nothing getting updated. else all records are getting deleted.
please advice.
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 37777759
you have removed the where clause on your update statement.

that means if you have any rows selected you will update all of them
and, you'll update all of them for each row you selected.

so, you need to put the where clause back on, but fix it so that it chooses the correct row.
0
 

Author Comment

by:vsarma50
ID: 37777769
with condition removed nothing is deleted i tried that
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 37777803
>>with condition removed nothing is deleted i tried that

that's surprising.  it "should" delete everything when the condition is removed.
if it's not, then you're either not getting into the loop, or the if condition is false for every element.  in either case, having or not having the condition would be irrelevant then.



it looks like you have copied gatorvip's template FOR and IF verbatim

Do you have the correct value? Do you have the correct item name?
0
 

Author Comment

by:vsarma50
ID: 37777834
i apologize i mean type error.

>>with condition removed everything is deleted i tried that

and with condition nothing is removed/deleted.

Do you have the correct value? Do you have the correct item name?

how to get the correct item name i checked in page source. but could not found any 2 digit number

could you please give me example of the syntax you posted. thanks.
0
 
LVL 20

Accepted Solution

by:
gatorvip earned 500 total points
ID: 37778029
>>for i IN 1..APEX_APPLICATION.G_F01.COUNT
>>if APEX_APPLICATION.G_F01(i)=1 THEN
>>where empID=APEX_APPLICATION.G_F01(i);

You are using the same array here, which I doubt is what you want. If G_F01 holds the empid values, then your checkbox array will most likely going to be a higher index.

Search the page source code for ' <input type="checkbox" name=   '  and get the fnn index from there.

Also, did you explicity give the checkbox the value 1 (or 0) in the Lists of Values definition for the checkbox? If not, your verification will fail as the assignment is not implicit.
See the docs here:
http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21672/toc.htm#CACHEAGC
for a brief description and example on using checkboxed. The default behavior changed drastically between 3.2-4.1.
0
 

Author Closing Comment

by:vsarma50
ID: 37778690
thanks i will check my code .
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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
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.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

770 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