How to set a value for all records? - Printable Version +- LiveCloud Forums (https://forums.livecloud.io) +-- Forum: General (https://forums.livecloud.io/forumdisplay.php?fid=1) +--- Forum: General (https://forums.livecloud.io/forumdisplay.php?fid=3) +--- Thread: How to set a value for all records? (/showthread.php?tid=483) |
How to set a value for all records? - stamatis - 04-22-2021 Hi all, I'm probably missing something basic here, so grateful for any help. I've recently modified a table with the addition of 3 new keys and would like to set a default value for all records for these 3 keys. I know i can read the entire table into an array, loop through this in liveCode, make the changes and then do an update back to liveCloud. However this is cumbersome; i had envisaged that i may be able to use batchMerge, or batchUpdate to do this and simply pass "*" as the cdbRecordID, but this does not work - cdb_result shows me the error is The specified cdbRecordID is invalid: * Is there a way to do this directly? If not will just process in LiveCode and update all records, but am hoping i've missed something more straightforward... Many thanks Stam RE: How to set a value for all records? - efrain.c - 04-22-2021 Hi Stam, You are correct, batchMerge and batchUpdate do no accept "*" for cdbRecordID. You can use cdb_list(yourTableName, "cloud") to get a line delimited list of all the recordIDs in a table. Then repeat for each line to populate the array for a batchMerge. Let me know if you need any help or run into any issues. - Efrain RE: How to set a value for all records? - stamatis - 04-22-2021 (04-22-2021, 06:17 PM)efrain.c Wrote: Hi Stam, Thanks Efrain, I wasn't aware of cdb_list, will use that... Best regards Stam PS: It would be good to have a function that replaces all values -- similar to 'replace field contents' command in FileMaker Pro, where you can replace the field in all records of a table with a static value, an auto-incrementing serial number or a formula/function (and it's mighty fast)... Any mileage in submitting that as a feature request for this? |