views:

344

answers:

6

Kind of a follow up to my self-answered question about finding the column names.

In UniVerse you can't query a file for all of its columns unless the @ phrase in your file's dictionary is set to all of the tables columns. If it isn't how do you query a table for all of its column's values?

So I can get the total column listing (column name & display name) using:

LIST DICT file NAME

This will return a listing of all columns and their display names. How do I then query the table for all of the columns it has?

LIST file

Will only query it for LIST file @id (@id is the only thing in @).

UPDATE I found a blog -- a living breathing person who id using a version of UniVerse older than mine!! where he complains about the same thing, but says there is no solution shy of updating @ with all of the columns, please god someone prove him (Dan Watts) wrong.

What if you have a 200 column table and you want SELECT * to return all 200 columns? Sorry, but you’ll have to enter all 200 column names in that "@" record. And if you add, delete or rename a column, you’ll have to remember to edit that "@" record. I feel your pain! This cumbersome approach dates back to UniVerse’s ODBC driver, and I suppose they can’t change it now without breaking a lot of applications. You can find the details described in inscrutable IBM-ese in the UniVerse ODBC Guide.

A: 

Try

LIST file ALL

Of course, there is a limit to how many it can actually do, so it may file. What do you actually want to achieve?

Also, more generally, you should visit Rocket Software's U2 Site. You will be able to download the full manual set there.

There is also a mailing list that usually gives fast responses to help people out. You can find details of that at the U2 User Group site.

Dan McGrath
Thanks for the comment, i've been struggling quite publicly on SO with UniVerse, I had [a question](http://stackoverflow.com/questions/2016486/ibm-universe-learning-materials) about learning materials and found both of those resources previously. `LIST <file> ALL` does not work with me either, and I can't find docs on it in either the 10.3 or 10.1 (version I'm using). Getting `RetrieVe: syntax error. Unexpected symbol. Token was "ALL". Scanned command was LIST (table redacted) ALL;`
Evan Carroll
Sorry, I'm actually a UniData developer, which is the sister product to UniVerse. Although they are very similar, there are small differences. Depending on how many DICTs there are, maybe you could do it manually. Eg, LIST <file> <mydict1> <mydict2> ...
Dan McGrath
The filename for a dictionary in UniVerse is stored (typically) as a function of the filename of the file it defines (D_foo for foo) etc. I'm just too new to know how to take the output of the command in the question, and get all of those columns expressly, or how to query for the equiv of ALL columns without having to state them individually.
Evan Carroll
when you call about D_foo, that is the dictionary FILE. This is the file that stores all the dictionary ITEMS for FOO. By doing LIST DICT foo, it displays all the dictionary ITEMS stored in D_foo. Everything it lists under @ID is something you can use in place of <mydict1>, etc.
Dan McGrath
+2  A: 

LIST ALL does not work on Universe.

One thing you can do is LIST.ITEM or LIST-ITEM depending on your flavor. This will list every attribute in the file that has data in it like this:

>LIST.ITEM ACTIVITY
LIST.ITEM ACTIVITY 06:52:10pm  14 Jan 2010  PAGE    1

1
001 LEXMARK MULTI PRINT
002 THD
003 PJ
007 10355
009 Y
010 CAGNEW
011 15349
012 52111
014 1ý2ý3ý4ý5
015 Deinstall Make/ModelýDeinstall LocationýSigned Off ByýData/Voice AvailableýR
elocated Location
016 1ý2ý3ý4ý5

2
001 OMN
002 OMN
003 PJ
004 OMN*8437
005 6
009 N
010 CAGNEW
011 15349
012 51958

>  

If you're looking to do something with the data then write a program and do something like this:

OPEN "ACTIVITY" TO F.ACTIVITY ELSE STOP
SELECT F.ACTIVITY
LOOP
    READNEXT ID ELSE EXIT
    READ R.ACTIVITY FROM F.ACTIVITY, ID THEN
    ..................
    END
REPEAT
Mike Roosa
Right, so the solution to this problem (getting `LIST.ITEM` with parseable column names or display names, or making a query with the columns by name listed in `LIST DICT`) is to use UniBASIC? That's ok, that's the next thing I was going to try. I guess I'll get to reading the next mound of IBM text.
Evan Carroll
You could very quickly and easily write your own LIST routine. Write a program called LISTALL. It would take one argument such as filename and would read the dict for the file, get all the fields in that file and dynamically build the correct LIST command and then execute it.
Mike Roosa
A: 

A couple of points:

IBM's ADO.NET provider Dan refers to will not be part of UniVerse (or UniData) going forward. The IBM U2 business (including UniVerse) was sold to Rocket Software last fall, and a couple of pieces didn't make the transition.

Second, there are a couple of standard PHrases for DICTionaries. @ is the default listing to CRT. @SELECT specifies the fields returned from a SQL style SELECT.

>ED DICT VOC @SELECT
New record.

----: I
0001= PH
0002= NAME TYPE
0003= 
Bottom at line 2.
----: FI
"@SELECT" filed in file "DICT VOC".
>SELECT * FROM VOC;
NAME.......... TYPE

VERIFY.SQL     V
DIVX           V
INVISIBLE      K
QUIT.KEY       X
LEADING        K
DELETE.LIST    V
...
Ross Morrissey
As pointed about by JackieB, the statement about the ADO.NET provider is incorrect. Please see http://www.rocketsoftware.com/u2/products/u2-net/ where it is clearly listed.
Dan McGrath
You are correct, I understand that Rocket has an agreement with IBM to continue supporting this.
Ross Morrissey
+1  A: 

For most Universe/Pick installations, the programmers usually build some standardized shorthand ways to make ad hoc access to data via RECALL/RETRIEVE/ENGLISH/LIST easier. I've often seen entries in the VOC file with names like F1, F2, F3 and so on that look like "S" or "D" dictionaries. Usually they're something standard like 10 characters wide and left justified with a column heading like "Field 1". Using "*A1", "*A2" and the like seems to be another standard that's evolved for generic field names.

You can use these in any list command and if the file dictionary doesn't have an F1 (or whatever) it will use the one from the VOC file. So a command like:

LIST {filename} F1 F2 F3

Will work. It's nice because you just have to set it up once and then it's available anywhere you don't want to take the time looking up the dictionary names.

Also, there's no reason you can't set up a group type dictionary item in the VOC called "ALL.FIELDS" and stuff a gazillion "F1" type items in there. It would look like this:

001: PH 002: F1 F2 F3 F4 F5 F6 F7 F8 F9 {....} F200

Which is pretty much what your @ dictionary item would look like except it would have all of the proper dictionary items in it. For that matter, you could build an "ALL.FIELDS" dictionary item in the dictionary of the actual file and put the proper dictionary items with all of the proper formatting in there.

The caveat with this is that there is no guarantee that a UV dictionary is going to be complete and accurate as there are really no rules anywhere that force programmers to build dictionary items for data fields they use. If you care that much, you'd need to write a program to scan through the file and analyze the data to generate a report of how the fields actually work out.

If you can get to the point where the dictionary is going to be reliable, then it's worthwhile making sure that each field has one and only one corresponding "A" type dictionary item. Then it's trivial to write a program that does a SELECT on the dictionary for all of the "A" type records and builds an "ALL.FIELD" group dictionary item that lists them all. Then just make sure that everyone adding alternate dictionary items for different formatting or conversions uses only "S", "I" and "D" type items.

Personally, I find loading up the @ dictionary item with every field possible annoying when doing everyday stuff inside the PICK environment. Usually, you want stuff that fits nicely across an 80 column display with sort and totaling options that make sense. I'd prefer to see SQL stuff set up and named accordingly.

A: 

Your statement about IBM.NET is incorrect.

JackieB
Use the comment functionality to explain on his post, please do not submit an answer to comment on a specific answer. You can vote-to-delete your answer if you wish. (I the questioner never asked anything about IBM.NET)
Evan Carroll
A: 

LIST.ITEM filename. This will return all the values

ANSON THOMAS