• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
LiveCloud arrays and Datagrid
#5
Hi sid,

The code I provided will only work for a read. This is because the output for a batchQuery is slightly different than the output for a read. A batchQuery has two more layers in the output array, the tableID and the query index. The code below will massage the output of a batchQuery into the format for a datagrid.

Code:
local tInputA, tOutputA, tTableID, tKeys, tCount, tDataA, tRecordID
   
    put cdb_TableID("testTable") into tTableID
    put cdb_tableKeys("testTable") into tKeys
   
    put "date" into tInputA[tTableID]["query2"]["key"]
    put "<=" into tInputA[tTableID]["query2"]["operator"]
    put "12/13/19" into tInputA[tTableID]["query2"]["value"]
    put "date" into tInputA[tTableID]["query1"]["key"]
    put ">=" into tInputA[tTableID]["query1"]["operator"]
    put "12/01/19" into tInputA[tTableID]["query1"]["value"]
   
    put cdb_batchQuery(tInputA,"cloud","logicalAND","recordData") into tOutputA
   
    put 0 into tCount
    repeat for each key xRecordID in tOutputA[tTableID][1]
         add 1 to tCount
         
          put tOutputA[tTableID][1][xRecordID]["cdb"]["cdbRecordID"] into tRecordID
         repeat for each item xKeyName in tKeys
              put tOutputA[tTableID][1][xRecordID][xKeyName] into tDataA[tCount][xKeyName]
         end repeat
    end repeat


cdb_tableKeys returns all the keys in a table. We repeat through each of these keys to get the data for all of the columns of a record like you want. As for tResultFormat, we want to use "recordData" in this case. "recordData" gives the entire record while "resultList" only gives the recordID of the records. We will fix the documentation to include the "into", thanks for pointing that out.

Hope this helps! Let me know if you have any question.
  Reply


Messages In This Thread
LiveCloud arrays and Datagrid - by Bizbuzz - 11-21-2019, 11:01 AM
RE: LiveCloud arrays and Datagrid - by efrain.c - 11-21-2019, 07:03 PM
RE: LiveCloud arrays and Datagrid - by Papa Cann - 02-23-2020, 03:47 PM
RE: LiveCloud arrays and Datagrid - by efrain.c - 02-24-2020, 06:26 PM
RE: LiveCloud arrays and Datagrid - by sid - 12-14-2019, 11:27 PM
RE: LiveCloud arrays and Datagrid - by sid - 12-16-2019, 09:31 PM
RE: LiveCloud arrays and Datagrid - by efrain.c - 12-17-2019, 02:14 AM
RE: LiveCloud arrays and Datagrid - by sid - 12-17-2019, 09:54 PM
RE: LiveCloud arrays and Datagrid - by sid - 12-18-2019, 10:20 PM
RE: LiveCloud arrays and Datagrid - by sid - 12-19-2019, 10:12 PM
RE: LiveCloud arrays and Datagrid - by sid - 02-14-2020, 02:56 PM
RE: LiveCloud arrays and Datagrid - by efrain.c - 02-14-2020, 08:47 PM
RE: LiveCloud arrays and Datagrid - by sid - 02-15-2020, 07:52 PM
RE: LiveCloud arrays and Datagrid - by sid - 02-24-2020, 07:52 PM
RE: LiveCloud arrays and Datagrid - by efrain.c - 02-24-2020, 09:17 PM
RE: LiveCloud arrays and Datagrid - by sid - 02-24-2020, 09:39 PM
RE: LiveCloud arrays and Datagrid - by sid - 06-26-2020, 11:34 PM

Forum Jump:


Users browsing this thread: 4 Guest(s)