ResultSet / SQL.StatementResult: How to know if a column value is $list'ed
I'm breaking my head trying to figure how to solve this issue.
When using SQL, If the column (property) is populated with at least one value and is a %List, then I can check if it's $listvalid and $listlength(column) > 0.
Now let's suppose there's no data inserted for that column on next row.
I can't simply use $listvalid because $listvalid("") = 1. Yeah, empty values is a $list for Caché.
So my question is, how do I discover if the regarding column is indeed a %List independently of being empty or not when retrieving it's value via SQL?
I tried checking for the row metadata to discover any %List reference, but with no success.
Any ideas?
Hi Rubens,
Is this what you are after...
set rs=statement.%Execute() set meta=rs.%GetMetadata() set colmeta=meta.columns.GetAt(1) set runtimeType=colmeta.property.RuntimeType
Sean.
Oh, cool.
Too bad that %ResultSet for Caché 2010 doesn't have this property metadata though.
I guess I'll need to workaround it and disable the feature I'm trying to implement.
That's perfect to diagnosticate which infos I've available. I didn't know about that %Display method on metadata.
But ultimately I need this info for internal management.
What about...
Nice approach.
I got almost everything I need, except the property name. When the column is not aliased I can take it's name normally from label and colName.
However it breaks when SQL column is aliased, both colName and label refers to the same aliased column.
By the way, you can get it using:
Notice that columns must be an instance of %ResultSet.MD.Column.
Wellll technically NULL is a valid value for all datatypes. I think what you want to do is to interrogate the metadata information which you can do like so:
Note that you can do this even without running the query! You can look at %SQL.StatementMetadata in the Class Reference for more methods and properties that can help you.
Note 2 - Sean's method is also perfectly valid. The only advantage to mine is that you don't have to run the query.