Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
How to get the names of the columns created by a query
raravind
Currently I am generating an rpt design file using DEAPI where i hard code teh names of teh columns
(EmployeeNumber,firstname,lastname,jobtitle and email)
But I want to get the column names dynamically after the query is created.(from the query given here )
"select EmployeeNumber,firstname,lastname,jobtitle ,email from EmployeeDetails"
As soon as the query is created i want to get the names of the colums using Apis.What and How shud i do
Find more posts tagged with
Comments
mwilliams
Hi raravind,<br />
<br />
The following code can be used in your dataSet script to access the column names. This code adds all the names and types to a string that you can output to your report. You should be able to modify this script to assign each column name to a different variable as well if you want them separately for your column headers.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
crs = reportContext.getReportRunnable().getDesignInstance().getDataSet("Data Set").getCachedResultSetColumns();
iii = crs.size()
rsp = crs.iterator();
str = "";
while( rsp.hasNext() ){
cc = rsp.next();
str = str + cc.getName() +"--"+ cc.getColumnDataType() + " n";
}
</pre>
<br />
Hope this helps.
raravind
i deeply express my regards for the help rendered by u sir!
I wud be very happy to get ur help for one more query of mine
This is teh code u gave (with interfaces and class references)
/*IReportContext reportContext = null;
List crs = reportContext.getReportRunnable().getDesignInstance().getDataSet("Sample Derby Data Set").getCachedResultSetColumns();
int iii = crs.size();
Iterator rsp = crs.iterator();
String str = "";
while( rsp.hasNext() )
{
IResultSetColumn cc = (IResultSetColumn) rsp.next();
str = str + cc.getName() +"--"+ cc.getColumnDataType() + " n";
System.out.println("The columns are"+str);
}*/
over here how do i get this IReportContext reference(which i refenced to null in first line) from so that it can be used for my rptdesign file directly?
I am a novice programmer and finding it difficult to lick this with my design file.
pls do help me out ......... as soon as possible