A variable of type ColumnMetaData contains type and name information on each column in the data set. You receive such a variable when you work with a variable of type DataSetInstance and invoke the function getColumnMetaData.
element.getColumnCount() returns (INT)
element.getColumnName( index INT in ) returns (STRING)
element.getColumnDisplayName( index INT in ) returns (STRING)
The Java™ method associated with this EGL function is getColumnLabel.
element.getColumnAlias( index INT in ) returns (STRING)
element.getColumnTypeName( index INT in )returns (STRING)
The first column is number 1, not 0.
element.getColumnNativeTypeName( index INT in )returns (STRING)
The first column is number 1, not 0.
row["firstName"] + " " + row["lastName"]
You define a computed column for a data set when you are working in the Data Explorer view.
element.isComputedColumn(index INT in) returns (BOOLEAN)
element.getName()returns (STRING)
element.getExtensionID()returns (STRING)
element.getExtensionProperty(propertyName STRING in) returns (STRING)
element.setExtensionProperty
(propertyName STRING in, value STRING in)
element.getDataSource () returns (DataSourceInstance)
element.getColumnMetaData () returns (ColumnMetaData)
function setQuery( d DataSetInstance, c ReportContext )
{ eventType = beforeOpen, elementName = "dataSet" }
queryStr string;
if( region == "EUR" )
queryStr = "select region, country, city from locations
where region = \"EUROPE\"";
else
queryStr = "select region, country, city from locations
where region = \"ASIA\"";
end
d.queryText = queryStr;
end
In that example, the event handler sets one or another SQL query string in response to a business situation. The region variable is assumed to be declared and set globally, outside of the function.
package EGLDataSources;
program arrayProg type BasicProgram {}
function main()
arr customer[0];
cust customer;
cust.customerNumber = 102;
cust.firstName = "Jonathan";
cust.lastName = "Swift";
arr.appendElement(cust);
cust.customerNumber = 103;
cust.firstName = "Mark";
cust.lastName = "Twain";
arr.appendElement(cust);
designFile string = "eglDataSourcesRpt.rptdesign";
rptFile string = "eglDataSourcesArrayRpt.pdf";
myHandler arrayHandler = new arrayHandler;
rpt BIRTReport = new BIRTReport
(designFile, null, rptFile, "pdf", myHandler);
myHandler.setCustomerArray(arr);
rpt.createReportFromDesign();
end
end
record customer type basicrecord
customerNumber int;
firstName string;
lastName string;
end
package EGLDataSources;
Handler arrayHandler type BIRTHandler
index int;
customerArr customer[];
function setCustomerArray(a customer[])
customerArr = a;
end
function openFunction( d DataSetInstance )
{ eventType = openEvent, elementName = "myDataSet" }
index = 0;
end
function fetchFunction(d DataSetInstance, row UpdatableDataSetRow )
returns( boolean )
{ eventType = fetchEvent, elementName = "myDataSet" }
index = index + 1;
if( index <= customerArr.getSize() )
row.setColumnValue( "customer_num", customerArr[index].customerNumber );
row.setColumnValue( "fname", customerArr[index].firstName );
row.setColumnValue( "lname", customerArr[index].lastName );
return (TRUE);
else
return (FALSE);
end
end
end
Note that data-set column names (such as customer_num, fName, and lName) can be different from the corresponding EGL field names (such as customerNumber, firstName, and lastName).
For additional details, see the section on DataSetRow and UpdatableDataSetRow.
element.getDataSet()returns (DataSetInstance)
element.getColumnValue(index INT in)returns (ANY)
The first column is number 1, not 0.
element.getColumnValue(columnName STRING in) returns (ANY)
Those functions are also available to a variable of type UpdatableDataSetRow.
element.getName()returns (STRING)
element.getExtensionID()returns (STRING)
element.getExtensionProperty(propertyName STRING in) returns (STRING)
element.setExtensionProperty
(propertyName STRING in, value STRING in)
You might use the parameter of type DataSourceInstance to set the user ID and password used by the BIRT report engine to connect to a relational database. Here is the example code, which assumes that the variables userName and password are global and were set outside of the function:
function setUser( d DataSourceInstance, c ReportContext )
{ eventType = beforeOpen, elementName = "myDataSource" }
d.setExtensionProperty( "odaUser", userName );
d.setExtensionProperty( "odaPassword", password );
end
reportContext.setParameterValue
( parameterName STRING in, parameterValue ANY in )
reportContext.getParameterValue
( parameterName STRING in) returns (ANY)
A variable of type UpdatableDataSetRow provides a row of data to the report engine. The variable can use any of the functions described in relation to DataSetRow.
element.setColumnValue(index INT in, value ANY in)
The first column is number 1, not 0.
element.setColumnValue(columnName STRING in, value ANY in)