Skip to main content
marcot0005
June 28, 2022
Question

Getting cdt data from a dse

  • June 28, 2022
  • 17 replies
  • 0 views

I have an expression that takes in a dse and spits out the column names of everything in that dse. Unfortunately, the way it does this is by querying the dse and then running a!keys() on the first entry of the result to figure that all out. While this works perfectly well when the dse has values in it, it will error out if the table is empty. So is there any way to get the same information directly from a DSE that doesn't have data in it? 

17 replies

csteward
June 28, 2022

I haven't had a use case to do this with a DSE input, but I bet someone here will have a trick for you.

Only thing I have done similar is created a view (MSSQL) based on the DB's underlying INFORMATION_SCHEMA.COLUMNS details.  Used primarily in our COE for debugging truncation errors (when we have slack on field length validations in the interface - older environment).  Then I have an interface where you can select the underlying table, and it will display all of the data points by column. 

SELECT TOP (100) PERCENT ROW_NUMBER() OVER (ORDER BY TABLE_NAME) AS Row, 
cast(TABLE_CATALOG as varchar(100)) 'server',
cast(TABLE_SCHEMA as varchar(100)) 'schema',
cast(TABLE_NAME as varchar(100)) 'tableName',
cast(COLUMN_NAME as varchar(100)) 'columnName',
cast(IS_NULLABLE as varchar(10)) 'nullable',
cast(DATA_TYPE as varchar(100)) 'dataType',
cast(CHARACTER_MAXIMUM_LENGTH as int) 'maxLength'
FROM INFORMATION_SCHEMA.COLUMNS

stefanhelzle0001
Brainy
June 28, 2022

If this is static, why not just create a CDT from it? Then do a!keys() on that CDT.

marcot0005
June 28, 2022

Because it's not static. I basically have to figure out what the table looks like from the dse input so I can populate/query the table regardless of which table it is. 

stefanhelzle0001
Brainy
June 28, 2022

OK. Just out of curiosity, what is your use case?