Hi.. Everyone..
How can i use field symbol ?
ex:
<FIELD> := 'FIni01'
UPDATE <FIELD> FROM <A01> WITH_KEY(#ABC)
who can tell me about <FILED> RDML Code???
field symbol
Re: field symbol
Could you explain a bit more about what you are trying to do.
Is 'Fini01' the name of a field that you want to update, or the value you want to update?
Normally if you want to update fields you would do something like:
Group_By Name(#SomeFields) Fields(#xEmployeeSurname #xEmployeeGivenName)
#xEmployeeSurname := 'MyValue'
Update Fields(#SomeFields) In_File(xEmployee) With_Key(#xEmployeeIdentification)
or
#xEmployeeSurname := 'MyValue'
Update Fields(#xEmployeeSurname #xEmployeeGivenName) In_File(xEmployee) With_Key(#xEmployeeIdentification)
You would not normally use '<FIELD>' in your code.
Is 'Fini01' the name of a field that you want to update, or the value you want to update?
Normally if you want to update fields you would do something like:
Group_By Name(#SomeFields) Fields(#xEmployeeSurname #xEmployeeGivenName)
#xEmployeeSurname := 'MyValue'
Update Fields(#SomeFields) In_File(xEmployee) With_Key(#xEmployeeIdentification)
or
#xEmployeeSurname := 'MyValue'
Update Fields(#xEmployeeSurname #xEmployeeGivenName) In_File(xEmployee) With_Key(#xEmployeeIdentification)
You would not normally use '<FIELD>' in your code.
Re: field symbol
sorry ..my mean..
<FIELD> is Dynamic field name..
<FIELD> name maybe IS 'A001' or 'A002' or 'B001' Or 'C001' .....
so... i want..
<FIELD> := (TEXT) => #A001 := 'TEXT' or #B001 := 'TEXT'
UPDATE <FIELD> FROM <FILE> WITH_KEY(#AA)
= > UPDATE #A001 FROM <FILE> WITH_KEY(#AA) OR UPDATE #B001 FFROM <FILE> WITH_KEY(#AA)
<FIELD> is Dynamic field name..
<FIELD> name maybe IS 'A001' or 'A002' or 'B001' Or 'C001' .....
so... i want..
<FIELD> := (TEXT) => #A001 := 'TEXT' or #B001 := 'TEXT'
UPDATE <FIELD> FROM <FILE> WITH_KEY(#AA)
= > UPDATE #A001 FROM <FILE> WITH_KEY(#AA) OR UPDATE #B001 FFROM <FILE> WITH_KEY(#AA)
Re: field symbol
I think there is no commonly used feature like that in RDML/RDMLX code.
If you are reading data using SELECT_SQL, the SQL instruction can be a string, so you can build up the string any way you want.
That would allow you to specify the field name at run time.
See
https://docs.lansa.com/14/en/lansa015/c ... free_p.htm
Or depending on what you want to do with your code, you might get what you want by calling a subroutine that receives the field name and the value, and maps it into the appropriate field using a CASE statement.
Others may have additional suggestions.
If you are reading data using SELECT_SQL, the SQL instruction can be a string, so you can build up the string any way you want.
That would allow you to specify the field name at run time.
See
https://docs.lansa.com/14/en/lansa015/c ... free_p.htm
Or depending on what you want to do with your code, you might get what you want by calling a subroutine that receives the field name and the value, and maps it into the appropriate field using a CASE statement.
Code: Select all
subroutine CONVERT parms(#Name #Value)
CASE #Name
When = 'A001'
#A001 := #Value
When = 'A002'
#A002 := #Value
...
endcase
endroutineRe: field symbol
/* function where you want to "dynamically" set a field to a value */
/* #FIELD contains the name of the field you want to set without leading # */
/* #VALUE contains the value you want to set it to */
/* The field you want to set the value for must be used in this function */
Exchange Fields(#FIELD #VALUE)
Call Process(*DIRECT) FUNCTION(DYNAMIC)
<do whatever with the field>
/* DYNAMIC function that sets the field to the value */
FUNCTION OPTIONS(*DIRECT)
Use Builtin(EXCHANGE_ALPHA_VAR) With_Args(#FIELD #VALUE)
Return
If you want to set a numeric value, use EXCHANGE_NUMERIC_VAR in the above code instead of EXCHANGE_ALPHA_VAR. If #FIELD & #VALUE are both defined as fields in the data dictionary then this will work without defining them in each function. Alternatively, use INCLUDE in both functions. This may not be optimal as far as performance is concerned.
As far as doing I/O is concerned, I don't know how to do that in RDML.
/* #FIELD contains the name of the field you want to set without leading # */
/* #VALUE contains the value you want to set it to */
/* The field you want to set the value for must be used in this function */
Exchange Fields(#FIELD #VALUE)
Call Process(*DIRECT) FUNCTION(DYNAMIC)
<do whatever with the field>
/* DYNAMIC function that sets the field to the value */
FUNCTION OPTIONS(*DIRECT)
Use Builtin(EXCHANGE_ALPHA_VAR) With_Args(#FIELD #VALUE)
Return
If you want to set a numeric value, use EXCHANGE_NUMERIC_VAR in the above code instead of EXCHANGE_ALPHA_VAR. If #FIELD & #VALUE are both defined as fields in the data dictionary then this will work without defining them in each function. Alternatively, use INCLUDE in both functions. This may not be optimal as far as performance is concerned.
As far as doing I/O is concerned, I don't know how to do that in RDML.
Re: field symbol
Just thinking out loud here, but it looks like you are trying to dynamically build field / values and then update a table with those fields.
You might be able to do this with a variant and a keyed collection.
The update command is not dynamic so you will have to build up a custom update SQL string. Should be doable by spinning through the collection and appending the field for each item. You will likely have to use the variant functions to determine types while building up the sql.
Then you could use the SQL free format to execute your update string, STD_NUM is just a dummy field as I think you have to have at least one.
- Joe
You might be able to do this with a variant and a keyed collection.
Code: Select all
define_com class(#PRIM_KCOL<#PRIM_VAR #STD_TEXT>) name(#MyFields)
#MyFields<'MyField1'> := 'My Value'
#MyFields<'MyField2'> := 205
Then you could use the SQL free format to execute your update string, STD_NUM is just a dummy field as I think you have to have at least one.
Code: Select all
#wk_Sql := "my update string"
select_sql Fields(#STD_NUM) Using(#wk_Sql)
endselect.
Re: field symbol
The other thing that occurs to me is that this is perhaps a code generation question, so that may mean creating and using a template to generate the requisite code.
It would also be useful to know what the actual problem is that needs an answer like dynamic field processing.
It would also be useful to know what the actual problem is that needs an answer like dynamic field processing.