Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Changing ColumnHint/Alias based on DataSet Results
nedbert9
I'm curious if column aliases can be programmatically changed based on another DataSet's result values.
So, there would be a dependency of the second dataset to be updated on the first dataset with results defining the column names.
Reason for this. I'm pivoting data in Oracle with dynamic SQL and DECODE to a generic type object. The meaning of the columns will be variable, hence needing some way to assign the appropriate column name.
Find more posts tagged with
Comments
mwilliams
Hi nedbert9,
Can you explain this in a little more detail? How would the second dataSet change based on the first one? Can you walk through an example scenario?
nedbert9
Thanks, Michael.
Square one. I'm using a pivoting technique in Oracle to take a vertically oriented data set and pivot to horizontal. For example.
source:
id type value
1 test 0
1 test2 1
output:
id col1 col2
1 0 1
Ok, so, using this technique what is left is generic column names, e.g. col1, col2. There are other techniques in Oracle that are complex that might solve this issue, but the above technique is common practice.
Now, I have a second data set that contains what I would like to be column headings for the first.
col1 col2
test test2
Accomplishing this in older versions of Oracle is almost impossible. That is, pivoting a data set that has variable number of pivot anchor values, which may change and reorder as new data is added, and at the same time trying to put a descriptive column name on the result. The trouble is the variability and hence not being able to assign static column names within the Oracle procedure.
So, I was left to wonder if BIRT might have an API to access the data set/result set alias names. Further, if so, if I could query one data source where the output would be used as column names, enumerate the column names, while applying the column names through the API to the second data set's alias properties.
Just thought of something. I suppose for any subsequent executions of the report, changing the column aliases like I'm proposing, would invalidate the table definitions on the report. Ah, well. Might have answered my question.
I did find documentation about the StructureFactory class and the ColumnHint subclass to read/write an alias within report scripts. Problem is that calls to ColumnHint are only valid in certain run-time script sections. I believe it's BeforeFactory. Secondly, I'm foggy on the logic needed to take one data set's results and pass it through this API to assign the alias names to the second data set.
If it is even possible. Doing what I describe would create a dependency on the second data set to the data set containing the would-be column names. Data set one would have to be executed before second data set, etc.
mwilliams
nedbert9
Do you need the aliases set for binding purposes? Or just to get the column name correct on the column?