Home DADE
New Blog Posts: Merging Reports - Part 1 and Part 2

NexusDB VIEWS

edited April 2006 in DADE
Does RBuilder v10 have support for nexusDB VIEWS ?

They don't appear in the tables list on the data tab with v9

thanks
Ron

Comments

  • edited April 2006

    - open daNexus.pas and find the method implementation for
    TdanxSession.GetTableNames.

    - the TdanxSession.GetTableNames method is calling
    TnxDatabase.GetTableNames to get the list of available table names. If there
    is another similar call that can get the list of View names, then try adding
    some code to this method. If that works, then post the mods here and we can
    add them for the next release. (I do not have NexusDB installed).



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited April 2006
    Thanks Nard,

    Not as simple as that unfortunately, and I'm getting a bit out of my depth

    Modifying daNexus.pas is simple to have the view listed as a table.
    Getting the field list is another story

    TdaMetaData.GetFieldsFromDataSet: Unable to open dataset: CCV_CASE_90

    I'm gettin a little concerned that playing with this code will
    upset reporting from the other databases I use (oracle, SQLserver).

    would this have anything to do with TnxTable not being able to see nexusDB
    views ??
    (only accessible via Tnxquery)

    Ron
    D7, nexusDB 2.05.5, RB9.02
  • edited April 2006

    - Limit your code mods to the daNexus.pas unit. It is isolated to Nexus and
    will not affect any other database connectivity. Perhaps make a copy of the
    unit and then play with it.

    - TnxQuery is being used by the daNexus plugin. (I searched daNexus.pas and
    TnxTable is never used.)

    - Trace the RB Source starting at the method
    TdaMetaData.GetFieldsFromDataSet. That method will create an instance of the
    TdanxDataSet class. Put a break point in TdanxDataSet .SetDataName and
    TdanxDataSet.SetActive.

    // this line will create an instance of the TdanxDataSet
    lDataSet := FSession.CreateDataSet(Self, FDatabaseName);

    // this line will resul in a call to TdanxDataSet.SetDataName
    // the dataname is the name of a table (or view in your case)
    lDataSet.DataName := aMetaTable.SQLName;

    // this line will result in a call to TdansDataSet.SetActive
    lDataSet.Active := True;






    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited April 2006
    thanks Nard

    I'll have a play

  • edited April 2006
    Nard,

    here is the DADE mod for accessing nexusDB v2 views.

    note that the associated TnxDatabase cannot be set to "readonly" for a
    TnxQuery to query a view (not sure why)

    cheers
    Ron

    //===========================================================
    procedure TdanxSession.GetTableNames(const aDatabaseName: string; aList:
    TStrings);
    var
    lDatabase: TnxDatabase;
    lQuery: TnxQuery;
    begin

    {get the database}
    lDatabase := TnxDatabase(GetDatabaseForName(aDatabaseName));
    {Database must be active to get table names}
    lDatabase.Connected := True;

    {get list of table names from a table object}
    if lDatabase.Connected then
    begin
    lDatabase.GetTableNames(aList);
    end;

    {get list of view names from a query object}
    if (lDatabase.Connected) and (lDatabase.ReadOnly = False) then
    begin
    {create a temporary NexusDB query}
    lQuery := TnxQuery.Create(Self);
    try
    {assign databae and SQL properties}
    lQuery.Database := lDatabase;
    lQuery.SQL.Text := 'select VIEW_NAME from #views';

    {set query to active}
    lQuery.Active := True;
    lQuery.First;

    {append the view name to the list of tables}
    while lQuery.EOF=false do
    begin
    aList.Append(lQuery.Fields[0].AsString);
    lQuery.Next;
    end;
    finally
    lQuery.Free;
    end;
    end;

    end;
  • edited April 2006

    Thanks for providing that code. We can add this to the daNexus.pas source
    code. Are most developers that use Nexus, using Nexus v2? Is there a a
    predefined IFDEF that we can put around the code so that it will be included
    only when v2 is present?




    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited April 2006
    Good point .... modified code below

    cheers

    //==================================================================
    procedure TdanxSession.GetTableNames(const aDatabaseName: string; aList:
    TStrings);
    var
    lDatabase: TnxDatabase;
    lQuery: TnxQuery;
    begin

    {get the database}
    lDatabase := TnxDatabase(GetDatabaseForName(aDatabaseName));
    {Database must be active to get table names}
    lDatabase.Connected := True;

    {get list of table names from a table object}
    if lDatabase.Connected then
    begin
    lDatabase.GetTableNames(aList);
    end;

    {$IFDEF NEXUS2}
    {get list of view names from a query object}
    if (lDatabase.Connected) and (lDatabase.ReadOnly = False) then
    begin
    {create a temporary NexusDB query}
    lQuery := TnxQuery.Create(Self);
    try
    {assign databae and SQL properties}
    lQuery.Database := lDatabase;
    lQuery.SQL.Text := 'select VIEW_NAME from #views';

    {set query to active}
    lQuery.Active := True;
    lQuery.First;

    {append the view name to the list of tables..}
    while lQuery.EOF=false do
    begin
    aList.Append(lQuery.Fields[0].AsString);
    lQuery.Next;
    end;
    finally
    lQuery.Free;
    end;
    end;
    {$ENDIF}

    //===================================================================
This discussion has been closed.