New Ranks & Badges For The Community!
Notice something different? The ranks and associated badges have gone "Star Fleet". See what they all mean HERE
Highlighted
Absent Member.. Absent Member..
Absent Member..
454 views

Getting Java Script Error:: delete terminated - could not access row id(display,process.option)

Jump to solution

Hello Experts,

My intention is to delete Eventout data on weekly basis. I have written the following JS to achieve the same. It's working fine while records are there. But, while no records are found, then it is throwing error as delete terminated - could not access row id(display,process.option). 

Please let me know how to overcome so that if no records found, it will print as "No Records Found" instead of throwing error.

PurgeEventout()

function PurgeEventout()
{
var fpurge = new SCFile("eventout");
var rc;
var time = new Date();
var timecalc = 4560*80000;
var tempbefore = new Date(time.getTime() - timecalc);

var type = "page"
//var type = "email/page/pmc"
//var qry = "evtype=\"" + type + "\" and evsysseq=\"0000000100296836\""

var qry = "evtype=\"" + type +"\""
// + "\" and evexpire<\"" + tempbefore +"\""

rc = fpurge.doSelect( qry );
//print(tempbefore)

do
{
if ( tempbefore > fpurge.evexpire)
{
//print(fpurge.evexpire)
fpurge.doDelete()
}

}while(fpurge.getNext() == RC_SUCCESS)

print("script complete")
}

 

Regards,

Avi

 

 

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

You need to check if the query returns as well as the getnext. Try following script:

function PurgeEventout() {
    var fpurge = new SCFile("eventout");
    var rc;
    var time = new Date();
    var timecalc = 4560 * 80000;
    var tempbefore = new Date(time.getTime() - timecalc);

    var type = "page"
        //var type = "email/page/pmc"
        //var qry = "evtype=\"" + type + "\" and evsysseq=\"0000000100296836\""

    var qry = "evtype=\"" + type + "\""
        // + "\" and evexpire<\"" + tempbefore +"\""

    rc = fpurge.doSelect(qry);
    //print(tempbefore)

    while (rc == RC_SUCCESS) {
        if (tempbefore > fpurge.evexpire) {
            //print(fpurge.evexpire)
            fpurge.doDelete()
        }
        rc = fpurge.getNext();
    }

    print("script complete")
}

PurgeEventout();

View solution in original post

3 Replies
Highlighted
Commander
Commander

Use "while" statement instead of "do-while" statement. 

Highlighted
Micro Focus Expert
Micro Focus Expert

You need to check if the query returns as well as the getnext. Try following script:

function PurgeEventout() {
    var fpurge = new SCFile("eventout");
    var rc;
    var time = new Date();
    var timecalc = 4560 * 80000;
    var tempbefore = new Date(time.getTime() - timecalc);

    var type = "page"
        //var type = "email/page/pmc"
        //var qry = "evtype=\"" + type + "\" and evsysseq=\"0000000100296836\""

    var qry = "evtype=\"" + type + "\""
        // + "\" and evexpire<\"" + tempbefore +"\""

    rc = fpurge.doSelect(qry);
    //print(tempbefore)

    while (rc == RC_SUCCESS) {
        if (tempbefore > fpurge.evexpire) {
            //print(fpurge.evexpire)
            fpurge.doDelete()
        }
        rc = fpurge.getNext();
    }

    print("script complete")
}

PurgeEventout();

View solution in original post

Highlighted
Absent Member.. Absent Member..
Absent Member..

Thanks a lot to both of you.

Appreciate your response. Using While() instead of doWhile() literally resolved my issue.

I am accepting it as Solution.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.