Simulating AutoPurge

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
DS_SUPPORT
Premium Member
Premium Member
Posts: 232
Joined: Fri Aug 04, 2006 1:20 am
Location: Bangalore

Simulating AutoPurge

Post by DS_SUPPORT »

I have a requirement to delete some rows from hashed file based on a flag value (UPDFLG) on a periodical basis. The UPDFLG is a non key , which will contian the value either 'Y' Or 'N'.

On regular basis, say once in a month , i need to delete all the rows with the value 'N' from the Hashed File.

I can write a job, with the UV stage , and delete the rows.. But i was thinking as the RT_LOGxxx is also a hashed file, and it is deleting the records based on the settings , we give in AutoPurge.

So , is there any way , i can instruct my hashed file also, to delete the rows periodically.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

No.

Auto-purge is not as automatic as the name suggests. It is triggered by successful completion of the job. So, even if auto-purge is set to 3 days (for example) the job log will not be purged until next time the job is completed successfully (without aborting), no matter when this is.

You would need to define a similar event that would trigger a routine to purge your hashed file, and then create a mechanism (such as a job or a routine) to give effect to that purge.

It's do-able, but it can not be triggered by time alone.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DS_SUPPORT
Premium Member
Premium Member
Posts: 232
Joined: Fri Aug 04, 2006 1:20 am
Location: Bangalore

Post by DS_SUPPORT »

Thanks for the Information Ray,
create a mechanism (such as a job or a routine) to give effect to that purge.
How to delete the rows from the Hashed File, from the routine, Can you give some example for this?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

FUNCTION DeleteN(HashedFilePath)
* Error handling omitted for clarity
* Deletes records from hashed file where field #3 = "N".
Equate FIELDNO To 3  ; * adjust as required

Ans = 0

OpenPath HashedFilePath To hHashedFile
Then
   Select hHashedFile To 9
   Begin Transaction
   Loop
   While ReadNext ID From 9
       ReadU Record From hHashedFile, ID
       Then
          If Record<FIELDNO> = "N"
          Then
              Delete hHashedFile, ID
              Ans += 1
          End
       End
       End
   Repeat
   Commit
   End Transaction
End

RETURN(Ans)
Last edited by ray.wurlod on Thu Sep 18, 2008 3:30 pm, edited 3 times in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DS_SUPPORT
Premium Member
Premium Member
Posts: 232
Joined: Fri Aug 04, 2006 1:20 am
Location: Bangalore

Post by DS_SUPPORT »

The rows with the value "N" , in the column UPDFLG are eligible for deletion.

UPDFLG is a non-key column.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Hmmm...

Create a new hashed file, write the records you want to keep to it and then do the delete / rename switcheroo. Or create a VOC record (if pathed) and then use SQL to delete those records.
-craig

"You can never have too many knives" -- Logan Nine Fingers
DS_SUPPORT
Premium Member
Premium Member
Posts: 232
Joined: Fri Aug 04, 2006 1:20 am
Location: Bangalore

Post by DS_SUPPORT »

Thanks for the Information.
Post Reply