About dataProviders and SQLs

Hello,

I’m trying to develop an application to store in database the iwebi reports information. The most important thing is to store the data providers and sql information.
I know how to get the dataproviders information, and I know to get the SQL (the code is at the end of the post). But I’ve got a big problem…how to know which dataprovider goes with which sql???. For example, if I’ve got a dataprovider which id is DP1; I need to know which one is the SQL of this DP1.
I need to link dataproviders information with SQLs information…

  /*****************************************************************************/
  public static Hashtable getInfoDP (IInfoObject inform) throws SDKException {

    final Hashtable result = new Hashtable();    
    
    final IWebiDocDataProviders dps = ( (IWebi) inform).getDocumentDataProviders();    

    final int numDP = dps.count();
    for (int i = 0; i < numDP; i++) {
        final IWebiDocDataProvider dp = dps.item(i);
        final String idSql = dp.getID();
        final String nameSql = dp.getName();
        final String universe = dp.getDataSourceName();        
        final String idUniverse = dp.getDataSourceID();        

        final Hashtable query = new Hashtable();
        query.put(NAME_SQL,nombreSql);
        query.put(ID_SQL,idSql);
        query.put(NAME_UNIVERSO,universe);
        query.put(ID_UNIVERSO,idUniverse);
        result.put("n"+i, query);
    }

    return result;
  }

  /******************************************************/    
  public static Hashtable getSQLs (ReportEngine reportEngine, int docID) throws ServerException{

   final Hashtable result = new QaDictionary();   

   final DocumentInstance document = reportEngine.openDocument(docID);
   final DataProviders dp = document.getDataProviders();
   final int numDP = dp.getCount();

   //For every dataProvider
   for (int i = 0; i < numDP; i++) {
       final SQLDataProvider sqlDp = (SQLDataProvider) dp.getItem(i);

       //Get sql
       final SQLContainer sqlCont = sqlDp.getSQLContainer();
       final SQLSelectStatement sqlStatement = (SQLSelectStatement) sqlCont.getChildAt(0);
       final String sql = sqlStatement.getSQL();       

       //Store sql's
       final Hashtable has = new Hashtable();
       has.put(SQL_COMPLETA, sql);       
       result.put("n" + i, has);
   }

   return result;
  }

Best Regards,
//Laura


LauraMR (BOB member since 2010-09-21)

[Moderator Note: Moving from General Discussion to SDK]


Marek Chladny :slovakia: (BOB member since 2003-11-27)

Just a guess here, since I haven’t worked with it myself, but since SQLDataProvider is a subinterface of DataProvider, you should be able to call the same methods for your sqlDp object (sqlDp.getID(), sqlDP.getName(), etc.).

Joe


joepeters :us: (BOB member since 2002-08-29)

Thank you very much for your prompt reply.
Ok! I’m going to try with this. I’m also new with this SDK and I didn’t realise about that.
I’ll tell you what happens…

Thanks a lot for your help!!


LauraMR (BOB member since 2010-09-21)

Great! It works!!

Thank you!


LauraMR (BOB member since 2010-09-21)

you’re welcome :slight_smile:


joepeters :us: (BOB member since 2002-08-29)