ken bohnenkamp
14th October 2011, 20:20
I have a table I am reading through in Baan (we will call it arcom001 for this purpose). One of the fields in table arcom001 (we will call it arcom001.fled for this purpose) contains the field name of another table (we will say the value of field arcom001.fled is 'armcs013.stor' for this purpose)

As I read through arcom001, I need to somehow use the value of of
arcom001.fled to set the value of armcs013.stor to some value.
The resulting code might look something like this:

armcs013.stor = some value


Not really sure how to do this. Anyone have any idea.

JaapJD
14th October 2011, 21:54
If I understand your question correctly, I think the put.var() function can do exactly what you want to do:
ret = put.var(pid, arcom001.fled, somevalue)
If the value of arcom001.fled is "armcs013.stor", the field armcs013.stor will have the value "somevalue" after this line has been executed.

MilindV
16th October 2011, 16:25
put.var() assignes value to extern variables

I think, put var will work, only if the table armcs013 is declared in script.

If value of table field arcom001.fled will always contain field name of table armcs013 then declaring this table in the script will do. But if there is possibility that field arcom001.fled may contain table field name of other tables as well you need to declare those tables in your script as well.

So basically, u need to figure out in advance, which table fields names, table arcom001.fled will contain, and declare all (hard-code) tables in your script.

mark_h
17th October 2011, 03:16
Or use dynamic sql to build the query. You can search on Dynamic SQL. I have never used it for updating a record, but it should work.

JaapJD
17th October 2011, 09:28
@MilindV, @ken_bohnenkamp: If arcom001.fled may contain values that refer to table fields of different tables, you can use the db.bind() function to create the variables dynamcally. So, it is not needed to declare the tables.
@mark_h: Dynamic SQL does not work for updating tables. You still need to do the assignments.

ken bohnenkamp
17th October 2011, 14:13
The put.var function is exactly what I was looking for and will work for my situation. Thanks to all for the help and quick response.