Reference dynamic VARA columns by name

Idea created by Michael_Lowry on Jul 18, 2018
    New
    Score1
    • Michael_Lowry

    A specific value may be read from a VARA object using GET_VAR or a {VARA,KEY,COLUMN} reference. The column must be addressed by number, not by name.

     

    Static VARA objects have five numbered columns, but dynamic VARA objects like SQL and EXEC VARAs have a header row with column names. It should be possible to read values from such VARAs by addressing the column by name.

     

    In the example below, an SQL VARA lists the status of AE server processes. 

     

    This script tries to read the value of the PROCESS_TYPE column of the row WP002.

    :SET &Vara_Name#   = UC4.AE_PROCS_ALL_WITH_STATUS.VARA_SQLI
    :SET &Vara_Key#    = WP002

    :SET &Vara_Column# = 2
    :PRINT "Reading VARA &Vara_Name#, row &Vara_Key#, column '&Vara_Column#'"
    :SET &Value# = GET_VAR(&Vara_Name#,&Vara_Key#,&Vara_Column#)
    :PRINT "Value: &Value#"

    :SET &Vara_Column# = PROCESS_TYPE
    :PRINT "Reading VARA &Vara_Name#, row &Vara_Key#, column '&Vara_Column#'"
    :SET &Value# = GET_VAR(&Vara_Name#,&Vara_Key#,&Vara_Column#)
    :PRINT "Value: &Value#"

    This produces the following result:

    U00020408 Reading VARA UC4.AE_PROCS_ALL_WITH_STATUS.VARA_SQLI, row WP002, column '0000000000000002'
    U00020408 Value: 2
    U00020408 Reading VARA UC4.AE_PROCS_ALL_WITH_STATUS.VARA_SQLI, row WP002, column 'PROCESS_TYPE'
    U00020408 Value: WP002

     

    Referencing the column by number works fine, and returns the expected value, 2.

    Referencing the column by name does not work, and returns only the key/first column instead of the correct value.

    This should work, and should return the value from the named row and column. In other words, it should be possible to reference dynamic VARA columns by name.