# DC\_ARCHIVE directory format

**URL:** <https://forum.kx.com/t/dc-archive-directory-format/13683>\
**Category:** Community Support\
**Tags:** imported, other\
**Created:** [January 25, 2022, 12:00am UTC](https://forum.kx.com/t/dc-archive-directory-format/13683 "2022-01-25T00:00:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![leades](https://avatars.discourse-cdn.com/v4/letter/l/b5a626/32.png) [@leades](https://forum.kx.com/u/leades)\
**Post date:** [January 25, 2022, 12:00am UTC](https://forum.kx.com/t/dc-archive-directory-format/13683/1 "2022-01-25T00:00:00Z")

</div>

[https://learninghub.kx.com/forums/topic/dc\_archive-directory-format](https://learninghub.kx.com/forums/topic/dc_archive-directory-format)

Hello,

For the DC\_ARCHIVE template, you must put in a directory for the analytic to act on. What if the directory path includes a date? For example, …/hdb/{date}/data.

Any help is greatly appreciated

Many Thanks

Luke

---

<div class="post-metadata">

**Author:** ![leahs](https://avatars.discourse-cdn.com/v4/letter/l/13edae/32.png) [@leahs](https://forum.kx.com/u/leahs)\
**Post date:** [January 26, 2022, 12:00am UTC](https://forum.kx.com/t/dc-archive-directory-format/13683/2 "2022-01-26T00:00:00Z")

</div>

Hello Damian,

Thanks for reaching out here.

[DC\_ARCHIVE](https://code.kx.com/platform/archive_files/") is an inbuilt file maintenance mechanism in KX Control. It allows you to archive and delete files in a Unix sense.

However, it seems clearer now (and correct me if I am wrong) that you are continuously ‘upserting’ to a flat table within the HDB daily, and your intention is to delete older rows in that table.

In this case, the archive solution is not appropriate as that is for files only.

In order to delete rows older than 7 days in that flat table, you can avail of another inbuilt process template in Control called DS\_EXEC\_ANALYTIC. The process template allows for scheduled execution. I have documented the implementation steps here: [DS\_EXEC\_ANALYTIC Template](https://community.kx.com/t5/Community-Blogs/DS-EXEC-ANALYTIC-Template/ba-p/11682")

In your case, your target process will be the relevant HDB and the supplied analytic should work to delete the rows in that flat table.

Useful links for your analytic logic and for dealing with flat tables:

[https://code.kx.com/q/ref/get/](https://code.kx.com/q/ref/get/")

[https://code.kx.com/q/ref/get/#set](https://code.kx.com/q/ref/get/#set")

[https://code.kx.com/q/ref/delete/#table-rows](https://code.kx.com/q/ref/delete/#table-rows")

In summary, the archiving process template is great for managing file maintenance. However, when maintaining a flat table, we recommend the use of DS\_EXEC\_ANALYTIC here for scheduled execution of row removal.

Please let me know if you encounter any issues with the above or have any further questions.

Kind regards,

Leah

---

<div class="post-metadata">

**Author:** ![lkerr2](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/lkerr2/32/57_2.png) [@lkerr2](https://forum.kx.com/u/lkerr2)\
**Post date:** [January 26, 2022, 12:00am UTC](https://forum.kx.com/t/dc-archive-directory-format/13683/3 "2022-01-26T00:00:00Z")

</div>

Hi Luke,

Thanks for your question!

In the instance of archiving older dates in a HDB using the DC\_ARCHIVE template, you would have to act upon the entire date partition anyway (as removing specific columns only within some partitions would break your HDB)

So in your example, your directory would be …/hdb/

and you would use the numDaysOlderThan parameter to archive dates older than X days.

Hope this helps!

Laura

---

<div class="post-metadata">

**Author:** ![damholda](https://avatars.discourse-cdn.com/v4/letter/d/a9adbd/32.png) [@damholda](https://forum.kx.com/u/damholda)\
**Post date:** [January 26, 2022, 12:00am UTC](https://forum.kx.com/t/dc-archive-directory-format/13683/4 "2022-01-26T00:00:00Z")

</div>

Hi Laura,

Thanks for response, actually Luke from support was asking on my behalf. What we are trying to do is to have temporary table within HDB that only keeps records for 7 days. We dont care about old data in that “schema” so we want to purge it to save space. We were told by support that “archive” functionality can do that but from what you saying that is not feasible. Do you have any alternatives where we can discard data for specific schema or maybe limit it so it overwrites oldest data ../hdb/{data}/tempTable ?

Thanks

Damian
