How to generate and understand a list of field names in a UniData table

1.5k views Asked by At

I'm new to both UniData and Uniobjects so if I ask something that obvious I apologize.

I'm trying to write a tool that will let me export contacts from our ERP (Manage2000) that runs on UniData (v. 6.1) and can then import them into AD/Exchange.

The primary issue I'm having is that I don't know which fields (columns?) in the table (file?) are for what. I know that that there is a dictionary that has this information in it but I'm not sure how to get what I want out of it.

I found that there is a command LIST.METADATA in the current UniData documentation from Rocket but it seems that either the version of UniData that we are using is so old that it doesn't have this command in it or it was removed from the VOC file for some unknown reason.

Does anyone know how or have any tips to pull out the structure of a table so that I can know which fields are for what data?

Thanks in advance!

2

There are 2 answers

3
webthaumaturge On BEST ANSWER

At TCL:

LIST DICT contact.master

Please note that the database file name (EX: contact.master) is case sensitive. I don't have a UniData instance at the moment to provide an example output. However, it should be similar to Universe's output:

Field......... Type & Field........ Conversion.. Column......... Output Depth &
Name.......... Field. Definition... Code........ Heading........ Format Assoc..
               Number

AMOUNT.WEBB    A    1               MR22         Amt WEBB        10R    M
PANDAS.COST    A    3               MD2Z         Pandass Cost    10R    M
CREDIT.EXP.DT  A    6               D4/          Cred Exp Date   10R    M

For the example above, you can generally tell the "data type" of the field by looking at the conversion code. "D4/" is the conversion code for a date. "MD2Z" is a numeric conversion code, which we can guess is for monetary amounts. I'm glossing over the power of conversion codes, so please make sure to reference Rocket's documentation for these codes to truly understand what these fields would output. If you don't have the documentation in front of you, you can also reference this site:

http://www.koretech.com/kr_help/KU2/30/en/KMK_Prog_Conversions.htm

If you wanted to use UniObjects and C# to retrieve the field names in a file, you could use the following code:

UniCommand fieldSelectCommand = activeSession.CreateUniCommand();
fieldSelectCommand.Command = "SELECT DICT contact.master";
fieldSelectCommand.Execute();
UniSelectList resultList = activeSession.CreateUniSelectList(0);
String[] allFieldNames = resultList.ReadListAsStringArray();

Having answered your question, I would also like to make a recommendation that you check out Rocket's U2 Toolkit for .NET if you're mostly going to be selecting data from the database instead of reading and manipulating individual records:

http://www.rocketsoftware.com/products/rocket-u2-toolkit-net

Not only does it present an ADO.NET way of accessing the database, it also has a better performance version of the UniObjects library under the U2.Data.Client.UO namespace.

0
Thrown Into MV On

The Dictionary, in my opinion, is a recommendation of how the schema should behave. However, there are cases when it's not 100% accurate. You could run "LIST CONTACT.MASTER TOXML TO MYFILE.XML" which would create an xml file what you could parse.

See https://u2devzone.rocketsoftware.com/accelerate/articles/u2-xml/u2-xml#section-0 for more information.