I actually posted about this on another forum but that forum has been down for quite some time. So I apologize if this is a repeat for some of you.
I could have sworn there was a way to dynamically assign values to fields (whether they are program defined fields or fields in a file) by building and executing sql statements. I thought it had something to do with values() into ?. If I could simply build an SQL statement (dynamically) and provide a list of fields and update a data structure or file with them, I'm golden!
File
json string (2 records)
here is my data structure based on the file i'm attempting to update
So I have the proper API set up to parse the json string and update the datastructure above (based of TESTFILE) for the appropriate fields (the API to do this was purchased, not developed personally). The data structure has the correct values for the changed fields. BUT now i need to get the remaining values from the original record (that are missing from the json string) back into the data structure. I thought I could build an SQL statement using the "update" or "values () into" caluse, but I cannot seem to wrap my head around how I can get my SQLRPGLE program to update a field using dynamic sql. If I seriously cannot do something like this:
myfield = 'FIELDA';
myvalue = '1';
values ( :myvalue ) into :myfield
then I'm not sure I can do what i'm hoping to do. my brain is fried. I hope this makes sense. :-)
I could have sworn there was a way to dynamically assign values to fields (whether they are program defined fields or fields in a file) by building and executing sql statements. I thought it had something to do with values() into ?. If I could simply build an SQL statement (dynamically) and provide a list of fields and update a data structure or file with them, I'm golden!
File
Code:
A UNIQUE A R TESTFILE A** A FIELDA 10A A FIELDB 10A A FIELDC 10A A FIELDD 10A A FIELDE 10A A FIELDF 10A A** A K FIELDA
json string (2 records)
Code:
[ {"FIELDA":"1","FIELDB":"BLAH BLAH","FIELDC":"NNNNN"}, {"FIELDA":"1","FIELDB":"BLAH BLAHX","FIELDC":"XXXXXXX"} ]
Code:
d record e ds extname(TESTFILE) inz
myfield = 'FIELDA';
myvalue = '1';
values ( :myvalue ) into :myfield
then I'm not sure I can do what i'm hoping to do. my brain is fried. I hope this makes sense. :-)
Comment