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

If I understand your question correctly, you want all the records from two tables that have the same value for a common key. The following batchQuery should do the trick. Let me know if you have any questions or if I misunderstood your question.

Code:
local tTableName1, tTableName2, tTableID1, tTableID2, tProductCode, tDataA, tOutputA
local tTarget, tMode, tResultFormat, tCollapseArray
local tCount, tDataGridA, tKeys

//GET TABLEIDS FOR TABLES NEED TO CONSTRUCT QUERY
put cdb_tableID(tTableName1) into tTableID1
put cdb_tableID(tTableName2) into tTableID2

//CONSTRUCT QUERY FOR TABLE 1
put "ProductCode" into tDataA[tTableID1][1]["key"]
put "=" into tDataA[tTableID1][1]["operator"]
put tProductCode into tDataA[tTableID1][1]["value"]

//CONSTRUCT QUERY FOR TABLE 2
put "ProductCode" into tDataA[tTableID2][1]["key"]
put "=" into tDataA[tTableID2][1]["operator"]
put tProductCode into tDataA[tTableID2][1]["value"]

put "cloud" into tTarget
put "batch" into tMode
put "recordData" into tResultFormat
put false into tCollapseArray

//QUERY BOTH TABLES FOR EVERY RECORD THAT CONTAINS THE GIVEN tProductCode IN THE ProductCode KEY
put cdb_batchQuery(tDataA, tTarget, tMode, tResultFormat, tCollapseArray) into tOutputA

put 0 into tCount

//CLEAR DATAGRID
set the dgData of group "datagrid" to empty

//REPEAT FOR EACH TABLE IN THE OUTPUT ARRAY
repeat for each key xTableID in tOutputA
    //GET ALL KEYS FOR THE TABLE WE ARE CURRENTLY PROCESSING
    put cdb_tableKeys(xTableID) into tKeys
   
    //REPEAT FOR EACH RECORD FOR THE CURRENT TABLE
    //THE OUTPUT ARRAY ALSO CONTAINS THE INDEX (1 IN THIS CASE) SO WE NEED TO REFERENCE IT TO ACCESS THE RECORDIDS
    repeat for each key xRecordID in tOutputA[xTableID][1]
         //INCREMENT tCount FOR EVERY RECORD (NEEDED TO FORMAT THE ARRAY FOR THE DATAGRID)
         add 1 to tCount
         
         //DISPLAY THE RECORDID IF WANTED
         //COMMENT OUT OR REMOVE IF NOT
         put xRecordID into tDataGridA[tCount]["recordID"]
         
         //REPEAT FOR EVERY KEY IN THE TABLE TO DISPLAY ALL COLUMNS OF THE RECORDS
         repeat for each item xKeyName in tKeys
              put tOutputA[xTableID][1][xRecordID][xKeyName] into tDataGridA[tCount][xKeyName]
         end repeat
    end repeat
end repeat

//POPULATE DATAGRID
set the dgData of group "datagrid" to tDataGridA
  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: 2 Guest(s)