Uniface User Forum

 View Only
  • 1.  Verify Pathname after changing it dynamically

    Posted 04-04-2024 08:34

    Hello,

    I used the "open" and "close" instruction to connect on differents databases, changing the PathName of the connector $MQL.

    However, I want to verify if the connection is done on the correct database after open a new one, even if the $Status = 0.

    (I have cases where I put something wrong in the pathname, and $Status=0 however)

    Is there a Uniface instruction which can give me the pathname actually used?

    Thanks



    ------------------------------
    Jérémie CEDOLIN
    Proges Plus
    Willems FR
    ------------------------------


  • 2.  RE: Verify Pathname after changing it dynamically

    Posted 04-05-2024 04:46
    Edited by Osman Shariff 04-05-2024 04:46

    Would this work using Sql Server 

    sql "SELECT DB_NAME()",$path

    {test the result}



    ------------------------------
    Osman Shariff
    ------------------------------



  • 3.  RE: Verify Pathname after changing it dynamically

    PARTNER
    Posted 04-05-2024 06:07

    On MySql it appears that would be 
    SQL "select DATABASE()",$path



    ------------------------------
    Iain Sharp
    Head of Technical Services
    Pci Systems Ltd
    Sheffield GB
    ------------------------------



  • 4.  RE: Verify Pathname after changing it dynamically

    Posted 5 days ago

    Thanks for the answer, it's ok with "select database()" on MySQL



    ------------------------------
    Jérémie CEDOLIN
    Proges Plus
    Willems FR
    ------------------------------



  • 5.  RE: Verify Pathname after changing it dynamically

    Posted 5 days ago

    However, I do it by another way:
    I create a parameter in a file of each database, with the same key but a different value.

    After the "open" instruction, I read this parameter and check if the value returned is the one that is expected.



    ------------------------------
    Jérémie CEDOLIN
    Proges Plus
    Willems FR
    ------------------------------



  • 6.  RE: Verify Pathname after changing it dynamically

    Posted 5 days ago

    That would work, but why bother when a perfectly working way already exists without the maintenance.  I can't see the purpose.



    ------------------------------
    Osman Shariff
    ------------------------------



  • 7.  RE: Verify Pathname after changing it dynamically

    Posted 4 days ago

    And if you have such a file/table, I guarantee you that the next time you make a copy for a test environment, you will forget to change the content and it can happen that the wrong database is supplied with updates!

    But how about writing a view that collects and returns all relevant/necessary information.
    At https://dev.mysql.com/doc/refman/8.0/en/information-functions.html you can find some more functions.
    If the name of the view is kept generic (e.g. 'SysInfos') and the column names are also generic, you can even set up this view on other database systems and get a standardized return of what you are dealing with.  [A first column in the view should then contain "MQL" in your case :-)]
    Ingo



    ------------------------------
    Ingo Stiller
    Aareon Deutschland GmbH
    ------------------------------



  • 8.  RE: Verify Pathname after changing it dynamically

    Posted 4 days ago

    BTW. For MS-SQL possible properties are listed here:
    https://learn.microsoft.com/en-us/sql/t-sql/functions/serverproperty-transact-sql

    And what about such View (for MS-SQL):
    create view SpecialSysInfo
    as 
    select 
    'MSS' as DbmsType
    ,(select SERVERPROPERTY ( 'MachineName' ))    as ServerName
    ,(select SERVERPROPERTY ( 'InstanceName' )) as DbmsInstName
    ,(select DB_ID())        as DbId
    ,(select DB_NAME())      as DbName
    ,(select host_name())    as Local_CompName
    ,(select host_id())      as Local_CompID
    ,(select user_name())    as Local_UserName
    ,(select user_id())      as Local_UserId
    go

    Ingo



    ------------------------------
    Ingo Stiller
    Aareon Deutschland GmbH
    ------------------------------