/* -----------------------------------------------------------------------------------*/
/* 2011-07-10 Vrao Polavarapu */
/* Download files from PSFILE_ATTDET . This code can be used to import from
other file attachment records also.*//* 2011-07-10 Vrao Polavarapu */
/* Download files from PSFILE_ATTDET . This code can be used to import from
/* -----------------------------------------------------------------------------------*/
/* Vrao - Start */
Local File &MYFILE1, &MYFILE2;
Local SQL &crsql;
Local integer &cnt;
Local string &STRTEXT;
MessageBox(0, "", 0, 0, "READ FILE RECORD STARTED [" | %Datetime | "]");
&crsql = CreateSQL("Select count(*) from PSFILE_ATTDET where ATTACHSYSFILENAME like 'myusername%' and trunc(LASTUPDDTTM) > sysdate -24", &cnt);
/*Select ATTACHSYSFILENAME from PSFILE_ATTDET where ATTACHSYSFILENAME like 'myusername%' and trunc(LASTUPDDTTM) = to_date('07/10/2011','mm/dd/yyyy') */
MessageBox(0, "", 0, 0, "Total number of files to download: [" | &cnt | "]");
&crsql = CreateSQL("Select ATTACHSYSFILENAME from PSFILE_ATTDET where ATTACHSYSFILENAME like 'myusername%' and trunc(LASTUPDDTTM) > sysdate -24");
While &crsql.Fetch(&ATTACHSYSFILENAME);
&URL="record://PSFILE_ATTDET";
&Rt = GetAttachment(&URL, &ATTACHSYSFILENAME, "C:\Temp\" | &ATTACHSYSFILENAME);
/*if you want to read everyfile and write to a separate file, use the following code*/
/* &MYFILE1 = GetFile(&ATTACHSYSFILENAME, "r", "a", %FilePath_Absolute);
&MYFILE2 = GetFile("C:\temp\" | &ATTACHSYSFILENAME, "w", "a", %FilePath_Absolute);
While &MYFILE1.ReadLine(&STRTEXT);
&MYFILE2.WriteLine(&STRTEXT);
End-While;
&MYFILE1.Close();
&MYFILE2.Close();
*/
MessageBox(0, "", 0, 0, " Name of the file downloaded: [" | &ATTACHSYSFILENAME | "]");
End-While;
/* Vrao -End*/
No comments:
Post a Comment