Home » Developer & Programmer » Forms » del many records (form developer 6i second release)
del many records [message #280888] Thu, 15 November 2007 01:54 Go to next message
ashraf_al_ani
Messages: 92
Registered: October 2007
Location: Iraq
Member
Dear all

I have a form that preview about 4 records
I want a command to delete them all by one press of button

best regards
Re: del many records [message #280893 is a reply to message #280888] Thu, 15 November 2007 02:26 Go to previous messageGo to next message
Littlefoot
Messages: 20891
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
You'll have to code it; something like
GO_BLOCK('that_block');
LOOP until the end of the block
  DELETE_RECORD;
Re: del many records [message #280895 is a reply to message #280888] Thu, 15 November 2007 02:39 Go to previous messageGo to next message
ashraf_al_ani
Messages: 92
Registered: October 2007
Location: Iraq
Member
Dear Brother
the code didnt work
it deleted only the first record from 4
so please is there any way else


best regards
Re: del many records [message #280899 is a reply to message #280895] Thu, 15 November 2007 02:44 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
Set the query all records property to Yes.

MHE
Re: del many records [message #280918 is a reply to message #280888] Thu, 15 November 2007 03:11 Go to previous messageGo to next message
ashraf_al_ani
Messages: 92
Registered: October 2007
Location: Iraq
Member
Dear

Ive set the property to yes
and the same problem happened
only the first record has been deleted
pls if there is any way else

best regards
Re: del many records [message #280974 is a reply to message #280918] Thu, 15 November 2007 05:14 Go to previous messageGo to next message
Littlefoot
Messages: 20891
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Did you
LF

LOOP until the end of the block
If not, no wonder only the first record was deleted.
Re: del many records [message #280979 is a reply to message #280888] Thu, 15 November 2007 05:32 Go to previous messageGo to next message
ashraf_al_ani
Messages: 92
Registered: October 2007
Location: Iraq
Member
I hope if u can tell me how c is the way and how to write the loop pls my block name is called emp

best regards
Re: del many records [message #280982 is a reply to message #280974] Thu, 15 November 2007 05:38 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
I tested and found that the "query all records" property is not necessary.

Here's what I did:
-- table creation script
CREATE TABLE rubbish( col1 NUMBER
                    , col2 VARCHAR2(50)
                    )
/

INSERT INTO rubbish
SELECT LEVEL
     , TO_CHAR(TO_DATE(LEVEL, 'J'),'Jsp')
FROM   dual
CONNECT BY LEVEL <= 30
/
COMMIT
/


I created a simple form (Forms 10g):
- data block wizard: take table RUBBISH as source, select all columns
- layout wizard: select all columns - tabular design - 4 records displayed
- create control block with 2 buttons (BT_EXIT and BT_DELETE_ALL)
- position buttons on the same canvas
- BT_EXIT gets a WHEN-BUTTON-PRESSED trigger with 'exit_form(no_validate);'. A nice, clean way to exit our form.
- BT_DELETE_ALL gets code as suggested by LF:
Declare
   v_b_exit BOOLEAN := FALSE;
Begin
   GO_BLOCK('RUBBISH');
   FIRST_RECORD;
   LOOP
      DELETE_RECORD;
    
      EXIT WHEN v_b_exit;

      IF :SYSTEM.LAST_RECORD = 'TRUE' THEN
         v_b_exit := TRUE;
      END IF;
   END LOOP;
End;


To make things complete, I created a when-new-form-instance trigger to fetch the data from my table at startup.

MHE
Re: del many records [message #280991 is a reply to message #280888] Thu, 15 November 2007 06:09 Go to previous messageGo to next message
ashraf_al_ani
Messages: 92
Registered: October 2007
Location: Iraq
Member
Dear brother
I knew Ive tired u
but i wrote the code and the same problem happened
but i didnt understand the:
"I created a when-new-form-instance trigger to fetch the data from my table at startup."

best regards


Re: del many records [message #281000 is a reply to message #280991] Thu, 15 November 2007 06:34 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
The when-new-form-instance trigger constains this code:
Begin
  GO_BLOCK('RUBBISH');
  Execute_Query;
End;
That's it.

MHE
Re: del many records [message #281009 is a reply to message #280888] Thu, 15 November 2007 06:55 Go to previous messageGo to next message
ashraf_al_ani
Messages: 92
Registered: October 2007
Location: Iraq
Member
Dear
No it didnt solve the problem
only the first record has been deleted


any ideas??

best wishes
Re: del many records [message #281015 is a reply to message #281009] Thu, 15 November 2007 07:05 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
ashraf_al_ani wrote on Thu, 15 November 2007 13:55

No it didnt solve the problem
Of course not, it's a small test case and example.
ashraf_al_ani wrote on Thu, 15 November 2007 13:55

only the first record has been deleted
From the 'rubbish' table? I find that hard to believe.
ashraf_al_ani wrote on Thu, 15 November 2007 13:55

any ideas??
Try to recreate my example it's all in there.

In your delete button's code, do you LOOP through the records like I showed. I can post my form, but it's 10g and you probably can't open it.

MHE
Re: del many records [message #281028 is a reply to message #280888] Thu, 15 November 2007 07:31 Go to previous messageGo to next message
ashraf_al_ani
Messages: 92
Registered: October 2007
Location: Iraq
Member
Dear Maaher
Ive wrote this:

when button pressed:

Declare
v_b_exit BOOLEAN := FALSE;
Begin
GO_BLOCK('emp');
FIRST_RECORD;
LOOP
DELETE_RECORD;

EXIT WHEN v_b_exit;

IF :SYSTEM.LAST_RECORD = 'TRUE' THEN
v_b_exit := TRUE;
END IF;
END LOOP;
End;
emp is the name of the table and the data block


and at the same form
trigger when new form instance Ive wrote

Begin
GO_BLOCK('emp');
Execute_Query;
End;


So i didnt of course delete from the rabish table as u say

So if there is any error please tell me
Re: del many records [message #281035 is a reply to message #281028] Thu, 15 November 2007 07:49 Go to previous messageGo to next message
Littlefoot
Messages: 20891
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
What does the status line say? Is there any error message? If so, which one?
Re: del many records [message #281453 is a reply to message #280888] Sat, 17 November 2007 00:39 Go to previous messageGo to next message
ashraf_al_ani
Messages: 92
Registered: October 2007
Location: Iraq
Member
Dear all

there is no any mistacs
but just the first record will be deleted and not all the 4th records


so
any other ways....

best regards

Re: del many records [message #281479 is a reply to message #281453] Sat, 17 November 2007 03:29 Go to previous messageGo to next message
Littlefoot
Messages: 20891
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
But this IS the way to do that ...

You might, however, create a sample form based on Scott's schema (for example, EMP table) and attach it to your next message so that someone could take a look at it.
Re: del many records [message #281568 is a reply to message #281479] Sun, 18 November 2007 07:26 Go to previous messageGo to next message
mudabbir
Messages: 235
Registered: April 2006
Location: Kuwait
Senior Member

try this in the WHEN-BUTTON-PRESSED trigger

Declare
  i number := 1;
Begin
while i = 1 loop
  if :emp.column1 is not null then --( Checks if there is a record to delete?)
    delete_record;
  else
    next_record;
  End if;
  if :system.LAST_RECORD = 'TRUE' then
    if :emp.column1 is not null then 
      delete_record;
      i:=2;
    else
      i:=2;
    end if;
  end if;
end loop;
end;
Re: del many records [message #281569 is a reply to message #281568] Sun, 18 November 2007 07:28 Go to previous messageGo to next message
mudabbir
Messages: 235
Registered: April 2006
Location: Kuwait
Senior Member

Sorry please add these lines after the "Begin"

GO_BLOCK('emp');
FIRST_RECORD;
Re: del many records [message #281732 is a reply to message #280888] Mon, 19 November 2007 02:44 Go to previous message
ashraf_al_ani
Messages: 92
Registered: October 2007
Location: Iraq
Member
many many thanks for you friend
it works correct
Previous Topic: Detail+post_query
Next Topic: How I create Search Like Lov Search using text item
Goto Forum:
  


Current Time: Sun Dec 04 18:36:11 CST 2016

Total time taken to generate the page: 0.17815 seconds