Question
1
Replies
86
Views
Hexaware
Posted: July 3, 2020
Last activity: July 4, 2020
Clear pyAttachStream data from BLOB of Data-WorkAttach-File table
Hi Team,
We are looking for any utility or SQL queries to delete pyAttachStream data from BLOB for Data-WorkAttach-File table. The Idea is to remove only attachment content from table by leaving all meta data.
Any suggestions would be helpful.
Hi Bhanuprakash,
Removing pyAttachmentStream from pc_data_workattach table will make the file data NULL. So if the users try to open any existing attachment from UI or if they try to download it will thrown an error or will be shown as blank. If you are not concerned with the outcome then any of the below approaches can be followed to remove the content of the file.
1st approach :
pyAttachmentStream is not an exposed column in the data pc_data_workattach table which Data-WorkAttach-File class is mapped to. As it is not exposed column a utility can be written in Pega.
Following is the procedure:
1. Write an Utility with Start and End Date Times.
2. Browse the list of attachments based on the above date time ranges. Fetch the pzInsKey as part of the Obj-Browse.
3. Once the data is browsed loop the data and open each record by doing Obj-Open-By-Handle with acquire lock enabled
4. Now do the Property-Remove and specify pyAttachmentStream property or do Property-Set and assign the value with empty Quotes.
5.Now do Obj-Save on the step page
6. Once the entire loop is completed perform a Commit.
2nd approach :
Expose the pyAttachmentStream column in the table and perform an update query like below which will set all the records data to null.
UPDATE pc_data_workattach SET pyAttachmentStream = "";