Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I am trying to apply hash128() function on loaded records but I don't really know the name of the loaded fields neither their number .
Besides , the number of the fields is variable .
I tried hash128(*) but it doesn't work. Is there any possible way to solve this problem?
Thank you,
You can use system functions to query the name and number of fields in a table.
Iterate over the field names and create variable with a concatenated string of your field names, then expand the variable in your hash128() function as argument.
System functions (from the help).
Returns the number of fields in a previously loaded table.
Examples:
LET a = NoOfFields('tab1');
Load *, NoOfFields( ) from abc.csv;
Returns the name of the field with the specified number within a previously loaded table.
If the function is used within a load statement, it must not reference the table currently being loaded.
Examples:
LET a = FieldName(4,'tab1');
T1:
Load a, b, c, d from abc.csv
T2:
Load FieldName (2, 'T1') Autogenerate 1;
I think we need to know a bit more about what you're trying to do here.
Hash128 is usually used to create a composite key of a number of known fields because it is smaller and faster than a concatenate of the fields
You can use system functions to query the name and number of fields in a table.
Iterate over the field names and create variable with a concatenated string of your field names, then expand the variable in your hash128() function as argument.
System functions (from the help).
Returns the number of fields in a previously loaded table.
Examples:
LET a = NoOfFields('tab1');
Load *, NoOfFields( ) from abc.csv;
Returns the name of the field with the specified number within a previously loaded table.
If the function is used within a load statement, it must not reference the table currently being loaded.
Examples:
LET a = FieldName(4,'tab1');
T1:
Load a, b, c, d from abc.csv
T2:
Load FieldName (2, 'T1') Autogenerate 1;
Example using QVD file here: Re: How to apply a hash function to all fields
That's almost a circular reference in discussions