Welcome Guest | My Membership | Login

Tech Tip: Formatting Queries Without A Dictionary Descriptor in UniVerse

Article

Log onto any MultiValue application that has been in existence for three years, find a commonly used file, say CUST, and list it’s dictionary. What do you see? Definitions for LNAME, LAST.NAME, L.NAME, LST.NAME, LNAME40, etc. Upon closer examination you discover that field (attribute) is also defined as X, XX, PGM030.LNAME.RPT, and on and on. Log on to an application that has been in use for 30 years and you could find several hundred dictionary entries for a file with only 20 fields.

Obviously what has happened is that if LNAME is originally defined as 15 characters wide and a report wants to use it in a column 13 characters wide, there you go. Another dictionary entry. Then in an ad hoc query, someone wants the data in a column 20 characters wide. Plop. There’s another “temporary” definition that never gets cleaned up.

In UniVerse there is a solution to this problem. All of the formatting things you can do from a dictionary descriptor you can do from the command line, or from within a Paragraph, Proc, EXECUTE, etc.

Staying with column width as an example, it’s quite simple. In your query statement, after naming the column you want displayed, simply add the justification and width specification with the FMT keyword. For example,

 

LIST CUST LNAME FMT “35L”

 

Conversion codes are simply specified with the CONV keyword.

 

LIST CUST LNAME FMT “35L” BAL.DUE CONV “MD24,$”

 

Column headings, anyone? The key word is COL.HDG. Also notice that the column heading text can include the ‘L’ option to break the heading into multiple lines.

 

LIST CUST LNAME FMT “35L” BAL.DUE CONV “MD2,$” COL.HDG “Amt’L’Owed”

 

But what if you want to perform a calculation or some kind of string manipulation? Then you have to use an I-descriptor, don’t you? As you might suspect, the answer is no. Anything you can code in the expression of an I-descriptor can be done on the command line using the EVAL keyword. Let’s combine the last name and the first initial to give us the names of the customers listed.

 

LIST CUST EVAL “LNAME:’, ‘:FNAME[1,1]”

 

While these are useful for ad hoc queries, these keywords can also be used to write permanent reports that are relatively immune to someone changing a descriptor and having it affect your report, like making it switch to non-columnar format, for example. Remembering that a line can end in an underscore character to indicate “continued on the next line,” you might write a Paragraph like this.

PA
SORT CUST WITH BAL.DUE > “0” _
EVAL “LNAME:’, ‘:FNAME[1,1]” FMT “30L” COL.HDG “Name” _
BAL.DUE CONV “MD2,$” FMT “10R” COL.HDG “Amt Owed” _
HEADING “Customer Owing Us Money” _
LPTR

For additional command line formatting abilities, see chapter 3 of the UniVerse Guide to Retrieve manual.

 

# # #          # # #          # # #

 

Related Articles

  • Convert C#/VB.NET Date/Time to Internal Date

    This Article will show you how to convert a C# or VB.NET Date/Time object into an Internal MultiValue Date. It will show you how to do it using the ICONV functions, and well as how to generate an Internal Date without using the ICONV function.

  • Convert Internal Date into C#/VB.NET Date/Time

    This article will show how to convert a MultiValue (PICK) Internal Date into a DateTime object that you can use in C# and VB.NET. The article will cover how use the OCONV statement, as well as, how to generate the DateTime object without using the OCONV statement.

  • Numeric to Alpha Translation

    Database: D3, Advanced Pick, AREV, jBase, Mentor/PRO, mv*Base, mvEnterpise, OpenInsight, OpenQM, Reality, Ultimate, UniVerse, UniData, UniVision

    The attached subroutine will convert a numeric values to their alphabetic values. The number "4" converts to "four"; "25" converts to twenty five, etc. There is also an option that will allow you to change a numeric value into an alphabetic count. For example, 4 converts to "forth", "25" converts to twenty-fifth.


Return to top