Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Is there a way to generate script from a variable ?
case:
field A contains 'load field1 as field_1'
variable = fieldvalue(fieldA)
how do I get this in the script ? I tried
$(variable) from table;
but when loading this is the result:
fieldvalue(fieldA) from table;
You would presumably use the first one.
This works fine as well:
Load * INLINE [
Field
Load 1 as field2 autogenerate(1)
];
Let SomeVariable = FieldValue('Field',1);
$(SomeVariable);
When doing this sort of thing, I'd recommend using debug mode to look at how the variables are getting populated and read.
By using field- or table-functions the names must be wrapped with single-quotes like:
let variable = fieldvalue('fieldA', 1);
and the appropriate index-value must be specified.
Further the field-values mustn't be wrapped with any quotes but they must contain the appropriate quoting for values and field-names, like:
load 'String' as [new field], FieldX as "FieldY"
and then you could use it like you did:
table: $(variable) from Source;
This works fine:
set SomeVariable = 'Load 1 as field autogenerate(1)';
$(SomeVariable);
yes, it works when the variable is hardcoded.
But in this case the field contains the script, and when I define the variable to read the fieldvalue, it doesnt put this in the script, only the definition of the variable.
it puts 'fieldvalue(fieldA)' iso 'load field1 as field_1'
Sounds like you haven't defined your variable correctly, then... perhaps you used SET where you should have used LET? You didn't include the actual code so it's hard to say.
I've tried several ways.
You would presumably use the first one.
This works fine as well:
Load * INLINE [
Field
Load 1 as field2 autogenerate(1)
];
Let SomeVariable = FieldValue('Field',1);
$(SomeVariable);
When doing this sort of thing, I'd recommend using debug mode to look at how the variables are getting populated and read.
By using field- or table-functions the names must be wrapped with single-quotes like:
let variable = fieldvalue('fieldA', 1);
and the appropriate index-value must be specified.
Further the field-values mustn't be wrapped with any quotes but they must contain the appropriate quoting for values and field-names, like:
load 'String' as [new field], FieldX as "FieldY"
and then you could use it like you did:
table: $(variable) from Source;