How to you add columns definitions / result set to the dataset at runtime?

Hi,

I need to add some columns to a dataset at runtime via Java.

I able to get to the dataset, via .findDataset() method.
I can also set columnHints via StructureFactory.createColumnHints()

But how do I add the actual result set definition for newly created columnHints().
I tried to play with CachedMetaData and ResultSetColumn but that led nowhere - I am getting nulls instead of expected List.

Anyone had luck adding columns at runtime to a dataset?

Best Answers

  • Accepted Answer

    Newbie,

    I'd suggest moving your question to a product support category in these forums if you are a customer.

    Please note that questions to the developer network are typically peer-to-peer, best effort responses, not guaranteed responses. If you are a customer of the product about which you're inquiring, please consider moving this post to the product forum where it may receive more attention from our experts.

    David Sciuto

  • Accepted Answer

    Newbie,
    Please note that questions to the developer network are typically peer-to-peer, best effort responses, not guaranteed If you are a customer of the product about which you're inquiring, please consider moving this post to the product forum where it may receive more attention from our experts.

    David Sciuto

Answers

  • edited June 2018

    This is essentially what I want to duplicate using Java. I can do columnHints, but can not figure out how to do cachedMetaData and resultSet

         <list-property name="columnHints">
                        <structure>
                            <property name="columnName">CITY</property>
                            <property name="analysis">dimension</property>
                            <text-property name="displayName">CITY</text-property>
                            <text-property name="heading">CITY</text-property>
                        </structure>
                    </list-property>
                    <list-property name="parameters"/>
                    <structure name="cachedMetaData">
                        <list-property name="resultSet">
                            <structure>
                                <property name="position">1</property>
                                <property name="name">CITY</property>
                                <property name="dataType">string</property>
                            </structure>
                        </list-property>
                    </structure>
                    <property name="dataSource">Data Source</property>
                    <list-property name="resultSet">
                        <structure>
                            <property name="position">1</property>
                            <property name="name">CITY</property>
                            <property name="nativeName">CITY</property>
                            <property name="dataType">string</property>
                            <property name="nativeDataType">12</property>
                        </structure>
                    </list-property>
    
  • Can you help answer this question?

    We have noticed this question is over 30 days old and hasn't received a response. We're turning to you, the community, to help answer it.

    This generic response is intended to prompt discussion in this post. The question remains open to your answers, suggestions, and best practices.

    If you posted this question, what additional information can you provide to help us respond to you? Were able to resolve the issue? Please share your solution here with others. If you still need additional help, though, please let us know. Your question and its resolution are important to us, and we want to help.

    • Please note that questions to the developer network are typically peer-to-peer, best effort responses. If you are a customer of the product about which you're inquiring, please consider moving this post to the product forum where it may receive more attention from our experts.

    • Additionally, note that posting questions to General may not be answered by a product expert. The General forum is for non-product questions. Please be sure to post your product-specific questions to the proper product forum.

    David Sciuto

  • @David Sciuto said:
    Can you help answer this question?

    We have noticed this question is over 30 days old and hasn't received a response. We're turning to you, the community, to help answer it.

    This generic response is intended to prompt discussion in this post. The question remains open to your answers, suggestions, and best practices.

    If you posted this question, what additional information can you provide to help us respond to you? Were able to resolve the issue? Please share your solution here with others. If you still need additional help, though, please let us know. Your question and its resolution are important to us, and we want to help.

    • Please note that questions to the developer network are typically peer-to-peer, best effort responses. If you are a customer of the product about which you're inquiring, please consider moving this post to the product forum where it may receive more attention from our experts.

    • Additionally, note that posting questions to General may not be answered by a product expert. The General forum is for non-product questions. Please be sure to post your product-specific questions to the proper product forum.

    Your reply did not help at all unfortunately.

  • This doesn't directly answer your question, but hopefully it is an easier method. In the beforeFactory event of the data set, you can change the query and thus the columns returned by the data set using the queryText property. For example:

    this.queryText = "select customername, customernumber, country from customers";

    Is there a requirement that prevents you from modifying queryText?

    Jeff F.
    Customer Support Engineer I
    OpenText
  • @jfranken
    Thanks for your reply. I actually figured out how to update / modify dataset definition at a runtime. I am able to fully replicate dataset's xml definitions/representations through java runtime for classic database/dataset pair. Currently, I am doing the same (reverse engineering) for POJO based dataset. While treatment is very much similar, there are some nuances.

    When I have some free time, I will reply to this thread with a tutorial on how to do it for community's benefit.

  • @jfranken said:
    This doesn't directly answer your question, but hopefully it is an easier method. In the beforeFactory event of the data set, you can change the query and thus the columns returned by the data set using the queryText property. For example:

    this.queryText = "select customername, customernumber, country from customers";

    Is there a requirement that prevents you from modifying queryText?

    If I understand correctly, the *this.queryText * only updates the query. It does not add/rename/map the actual dataset columns.

  • I have attached two examples. Querytext.rptdesign shows how to swap columns using the queryText property. You are correct that it is limited in what it can do. DynamicColumnsandQuery.rptdesign Is more complex. It illustrates how to change the query and table columns dynamically.

    Jeff F.
    Customer Support Engineer I
    OpenText
Sign In or Register to comment.