# How to delete all records from view ?

**URL:** <https://techcommunity.softwareag.com/t/how-to-delete-all-records-from-view/97877>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes\
**Created:** [July 29, 2011, 2:08pm UTC](https://techcommunity.softwareag.com/t/how-to-delete-all-records-from-view/97877 "2011-07-29T14:08:00Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Artur\_Paciorkowski](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Artur\_Paciorkowski](https://techcommunity.softwareag.com/u/Artur_Paciorkowski)\
**Post date:** [July 29, 2011, 2:08pm UTC](https://techcommunity.softwareag.com/t/how-to-delete-all-records-from-view/97877/1 "2011-07-29T14:08:00Z")

</div>

Is possible to delete all records from defined view without reading them (like below):

```auto
READ VIEWNAME BY ISN
   DELETE
   END TRANSACTION
END-READ
```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [July 29, 2011, 3:59pm UTC](https://techcommunity.softwareag.com/t/how-to-delete-all-records-from-view/97877/2 "2011-07-29T15:59:31Z")

</div>

This is possible with an Adabas direct call (even from Natural, let me know if you want to know more), but not with regular Natural DML (which makes sense as it also shields programmers from inadvertently deleting a file’s contents with a single call).

Two comments re. your example:

- use a physical read instead of reading by ISN, this will speed it up
- don’t issue an ET after every single DELETE, do it conditionally after every ‘n’ calls

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [July 29, 2011, 3:59pm UTC](https://techcommunity.softwareag.com/t/how-to-delete-all-records-from-view/97877/3 "2011-07-29T15:59:43Z")

</div>

If it is Adabas you can with direct Adabas Command E1 refresh the file (delete all records). The file must also have the option PGMREFRESH=YES.

---

<div class="post-metadata">

**Author:** ![Steve\_Robinson](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/steve_robinson/32/107_2.png) [@Steve\_Robinson](https://techcommunity.softwareag.com/u/Steve_Robinson)\
**Post date:** [July 29, 2011, 4:11pm UTC](https://techcommunity.softwareag.com/t/how-to-delete-all-records-from-view/97877/4 "2011-07-29T16:11:07Z")

</div>

Just to add to Wolfgang’s important guidelines for deleting all the records from a file:

Your “viewname” should have but one field, namely the physically first field in the fdt.

steve

---

<div class="post-metadata">

**Author:** ![Ralph\_Zbrog](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/ralph_zbrog/32/78_2.png) [@Ralph\_Zbrog](https://techcommunity.softwareag.com/u/Ralph_Zbrog)\
**Post date:** [July 29, 2011, 11:02pm UTC](https://techcommunity.softwareag.com/t/how-to-delete-all-records-from-view/97877/5 "2011-07-29T23:02:25Z")

</div>

DELETE doesn’t require any fields in the view. All you need is the view name.

```auto
DEFINE DATA LOCAL 
1 EMP VIEW EMPLOYEES 
END-DEFINE 
READ EMP PHYSICAL 
  DELETE 
  IF *COUNTER > 49 
    THEN 
      END TRANSACTION 
  END-IF 
END-READ 
END TRANSACTION 
END
```

Emptying a file programmatically is not recommended if there are MANY records, or if you are going to do this repeatedly (to the same file). In those situations, use the PGMREFRESH option (via Natural), or the ADADBS utility to REFRESH the file (batch or via Adabas Online System).

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [August 10, 2011, 6:20pm UTC](https://techcommunity.softwareag.com/t/how-to-delete-all-records-from-view/97877/6 "2011-08-10T18:20:19Z")

</div>

Hello,

Be very careful with Natural when you want to delete all records in a view (DDM).  
Have you checked that there is only one view (Natural DDM) associated with the physical file (Adabas FDT)?  
If so, are you sure it will be always the case?  
Personally, in our company, we have banned the use of READ BY ISN and READ PHYSICAL.

To delete all records in one view, we recommend:

1. For Natural, if the number of records permits:

```auto
DEFINE DATA LOCAL 
1 EMP VIEW EMPLOYEES 
1 #COUNTER (I2) 
END-DEFINE 
READ EMP BY EMP-NUM 
  DELETE 
  ADD 1 TO #COUNTER 
    IF #COUNTER> 49 
    THEN 
      END TRANSACTION 
      RESET #COUNTER 
  END-IF 
END-READ 
END TRANSACTION 
END 
```

1. Or, use of Utility, if the number of records is important.

```auto
ADAULD FILE = nnn, SORTSEQ = AD 

ADALOD UPDATE FILE = nnn, DDISN
```

Best Regards

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [August 10, 2011, 6:21pm UTC](https://techcommunity.softwareag.com/t/how-to-delete-all-records-from-view/97877/7 "2011-08-10T18:21:53Z")

</div>

Hello,

Be very careful with Natural when you want to delete all records in a view (DDM).  
Have you checked that there is only one view (Natural DDM) associated with the physical file (Adabas FDT)?  
If so, are you sure it will be always the case?  
Personally, in our company, we have banned the use of READ BY ISN and READ PHYSICAL.

To delete all records in one view, we recommend:

1. For Natural, if the number of records permits:

```auto
DEFINE DATA LOCAL 
1 EMP VIEW EMPLOYEES 
1 #COUNTER (I2) 
END-DEFINE 
READ EMP BY EMP-NUM 
  DELETE 
  ADD 1 TO #COUNTER 
    IF #COUNTER> 49 
    THEN 
      END TRANSACTION 
      RESET #COUNTER 
  END-IF 
END-READ 
END TRANSACTION 
END 
```

1. Or, use of Utility, if the number of records is important.

```auto
ADAULD FILE = nnn, SORTSEQ = AD 

ADALOD UPDATE FILE = nnn, DDISN
```

Best Regards

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [August 10, 2011, 7:03pm UTC](https://techcommunity.softwareag.com/t/how-to-delete-all-records-from-view/97877/8 "2011-08-10T19:03:00Z")

</div>

Assuming “all records in a view” means “all records on the file” - to delete them use ADADBS REFRESH

---

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [August 11, 2011, 2:33pm UTC](https://techcommunity.softwareag.com/t/how-to-delete-all-records-from-view/97877/9 "2011-08-11T14:33:24Z")

</div>

> [@Wolfgang Winter](#):
>
> ADADBS REFRESH

ADADBM REFRESH 😉

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [August 11, 2011, 7:59pm UTC](https://techcommunity.softwareag.com/t/how-to-delete-all-records-from-view/97877/10 "2011-08-11T19:59:52Z")

</div>

> [@Matthias](#):
>
> > [@Wolfgang Winter](#):
> >
> > ADADBS REFRESH
> 
> ADADBM REFRESH 😉

Mainframe → ADADBS  
OpenSystems → ADADBM

😉

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 3:00pm UTC](https://techcommunity.softwareag.com/t/how-to-delete-all-records-from-view/97877/11 "2021-04-02T15:00:40Z")

</div>


