Reetika
Reetika

Reputation: 1237

How to fetch data for multiple values of a parameter one by one

I have multiple values for one parameter i want to fetch data for each query for every value of parameter in Birt report. i'm getting data only for one value of parameter not all. m using Scripted data source.Open and fetch methods.Thanks

Open in DataSet

 importPackage(Packages.com.abc.test.events);

var TlantNo = params["tlant"].value;
var reqNo = params["Number"].value;

poreEvents = new StdPoreReqEvents();
poreEvents.setReqNo(reqNo);
poreEvents.setTlantNo(TlantNo);
poreEvents.open();

fetch

var poreRO = poreEvents.fetch();
if (poreRO == null) {
    return false;
} else
    {

        row["REQ_NO"] = poreRO.getReqNo();
        row["REQ_DATE"] = poreRO.getReqDate();

        return true;
    }

Upvotes: 4

Views: 3189

Answers (2)

Reetika
Reetika

Reputation: 1237

The other approach is to do this problem is by defining a dataset having output column which is the multiple value parameter Fetch that column by IN query of the multiple value parameter then pass that value means(output column value) to the other datasets as a Input/output parameter and give binding to parameter. It resolved my problem :)

Upvotes: 1

Dominique
Dominique

Reputation: 4342

A report parameter with multiple values is an array, we have to iterate on it through the scripted dataset.

In open event of the dataset, we only have to initialize a global index:

i=0;

In fetch event, process each iteration with something such the script below. Pay a special attention how we get the value of reqNo:

importPackage(Packages.com.abc.test.events);

if (params["Number"].value!=null && i<params["Number"].value.length){
    var TlantNo = params["tlant"].value;
    var reqNo = params["Number"].value[i];   

    //ETC. do here your stuff with porevents, declare poreRO, check if result is null

    row["REQ_NO"] = poreRO.getReqNo();
    row["REQ_DATE"] = poreRO.getReqDate();
    i++;  //Important: increment this even if poreRO is null, otherwise infinite loop
    return true; //should return true even if poreRO was null, to process next rows
}else{
  return false;
}

Upvotes: 2

Related Questions