Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

How to obtain columns name (Table's Field) in a table using java SDK


Omid Mar 13, 2020 05:59 PM

I have three data loggers and my java application is fetching data from all them periodically. Having the table name I can easily pull the values from that table, however what I want to do is first obtain the list of available tables and tables' field for each of my data loggers and then grab the values. My question is how I can obtain the list of all tables and then for any specific table how to obtain the table's field (columns names)?

The class TableDef holds the meta-data for one table on a Campbell Scientific datalogger, however I do not see any method that performs what I want.


jtrauntvein Mar 13, 2020 09:41 PM

The Datalogger class in the SDK has two methods that will probably be of interest to you:

- get_tables_count(): Returns the number of tables that are currently known

- get_table(int table_no): Returns the table associated with the specified zero-based index.


Omid Mar 15, 2020 10:29 PM

Hi

This is not what I need. As I mentioned in my question, I need the table's field (columns name). I need something like "get_column_name()" in the "ValueName" class. I think all tables' field must be available in the tables definition when we use GetTableDefsTran transaction, however I can not find a way to access them.


jtrauntvein Mar 16, 2020 02:07 PM

Class TableDef has a public member, columns, which is a vector of ColumnDef objects.  Each ColumnDef object has the means to describe one or more array members that this object represents.  You can use the ColumnDef.get_values_count() method to obtain the number of fields represented by a column and can then use the ColumnDef.format_name() method in order to create a string that uniquely identifies each field represented by a ColumnDef object.


Omid Mar 16, 2020 08:13 PM

Thanks for your help. I finally got it, however It seems that the columns TimeStamp and RecordNumber are not part of the table field. Am I correct?


jtrauntvein Mar 17, 2020 01:53 AM

Timestamp and record number are metaproperties associated with the record and are not a part of the table definition.

Log in or register to post/reply in the forum.