Harvest

Expand all | Collapse all

Command to locate/get info from package?

Jump to Best Answer
  • 1.  Command to locate/get info from package?

    Posted 12-10-2017 06:44 PM

    Good afternoon,

     

    I have a process that executes the command hco to download a specific package from a specific project. When the user chooses the wrong proyect (from a combo box) or the package is not in the required state, the hco command downloads nothing and the error message I show says that.

     

    Is there a command to find info from a specific package in a project? Such as which state or environment it is located? Or to check if it is in the project? What I'm trying to do is show more info on the error using those commands, for example :

     

    - "Package *** is not located in the selected project"

    - "Package *** is not located in the state YYY in the selected project, it is in the ZZZ state"



  • 2.  Re: Command to locate/get info from package?
    Best Answer

    Posted 12-12-2017 07:54 AM

    To enhance the error message return of an SCM transaction would require for this to be an enhancement

    for which you would have to submit a new "Idea" to be voted on.

     

    To provide a list of packages associated to a state or states within a project there is no command line utility

    for this, however, the user can use the hsql command line to run a custom SQL query against the database

    to get this list of packages, then view the results .dat file.

     

    Example:

    hsql -b broker -usr userid -pw pswd -t -f "QueryForListOfPackages.sql" -o "C:\temp\hsqlresults.dat"

     

    QueryForListOfPackages.sql:

     

    SELECT HARENVIRONMENT.ENVIRONMENTNAME,
      HARSTATE.STATENAME,
      HARPACKAGE.PACKAGENAME
    FROM HARENVIRONMENT
    INNER JOIN HARSTATE
    ON HARENVIRONMENT.ENVOBJID = HARSTATE.ENVOBJID
       LEFT JOIN HARPACKAGE ON HARPACKAGE.STATEOBJID = HARSTATE.STATEOBJID
       WHERE HARENVIRONMENT.ENVIRONMENTNAME = 'YourProjectName'
    ORDER BY HARSTATE.STATEORDER, HARPACKAGE.PACKAGENAME



  • 3.  Re: Command to locate/get info from package?

    Posted 12-12-2017 10:23 AM

    Since you have said that your user selects a project from a drop down list, so I am guessing that you're using either the HSDK or JHSDK in a custom program you have created.  Would this be correct?

     

    You could use SQL to get a list of packages in a specific project:

    select packagename

    from harpackage

    where envobjid = (select envobjid from harenvironment where environmentname = 'My Project');

     

    Or to get a list of packages in a specific project and state:

    select packagename

    from harpackage

    where envobjid = (select envobjid from harenvironment where environmentname = 'My Project')

    and stateobjid = (select stateobjid from harstate where statename = 'My State');

     

    Or find the project and state for a package:

    select environmentname, statename

    from harpackage, harstate, harenvironment

    where harpackage.stateobjid = harstate.stateobjid

    and harpackage.envobjid = harenvironment.envobjid

    and packagename = 'My Package';

     

    Let me know if this helps.