added sysprog entities
This commit is contained in:
220
SYSPROG/APPROW/SYSENV%003AWAREHOUSE_TEMPLATE.json
Normal file
220
SYSPROG/APPROW/SYSENV%003AWAREHOUSE_TEMPLATE.json
Normal file
@ -0,0 +1,220 @@
|
||||
{
|
||||
"header": {
|
||||
"version": 1,
|
||||
"type": "record",
|
||||
"approw-key": "WAREHOUSE_TEMPLATE"
|
||||
},
|
||||
"body": {
|
||||
"record1": {
|
||||
"<1>": "function WP_{procname}(Instruction, Handle, Info)",
|
||||
"<2>": "",
|
||||
"<3>": "*****************************************************************************",
|
||||
"<4>": "*",
|
||||
"<5>": "* Name : WP_{procname}",
|
||||
"<6>": "* Description: Warehouse Procedure",
|
||||
"<7>": "*",
|
||||
"<8>": "* LH Table : {table}",
|
||||
"<9>": "{datasetcomment}",
|
||||
"<10>": "{sqltablecomment}",
|
||||
"<11>": "*",
|
||||
"<12>": "* History (Date, Initials, Notes)",
|
||||
"<13>": "* {date} cwp Generated by the Create Warehouse Procedure wizard.",
|
||||
"<14>": "*",
|
||||
"<15>": "*****************************************************************************",
|
||||
"<16>": "",
|
||||
"<17>": "declare function SQLExp_Select",
|
||||
"<18>": "",
|
||||
"<19>": "$insert Logical",
|
||||
"<20>": "$insert DS_Equates",
|
||||
"<21>": "$insert XO_Equates",
|
||||
"<22>": "",
|
||||
"<23>": "equ CRLF$ to \\0D0A\\",
|
||||
"<24>": "",
|
||||
"<25>": "******",
|
||||
"<26>": "* Main",
|
||||
"<27>": "******",
|
||||
"<28>": " Ret = TRUE$",
|
||||
"<29>": " on Instruction gosub CreateTables, ClearTables, DropTables, ProcessInit, ProcessRecord, ProcessTerm",
|
||||
"<30>": " return Ret",
|
||||
"<31>": "",
|
||||
"<32>": "",
|
||||
"<33>": "*******************",
|
||||
"<34>": "* Create SQL Tables",
|
||||
"<35>": "*******************",
|
||||
"<36>": "* Instruction [in ] - 1",
|
||||
"<37>": "* Handle [in ] - Query Handle (hQry)",
|
||||
"<38>": "* Ret [out] - TRUE$ on success, FALSE$ otherwise",
|
||||
"<39>": "CreateTables:",
|
||||
"<40>": "{createscript}",
|
||||
"<41>": "return",
|
||||
"<42>": "",
|
||||
"<43>": "",
|
||||
"<44>": "******************",
|
||||
"<45>": "* Clear SQL Tables",
|
||||
"<46>": "******************",
|
||||
"<47>": "* Instruction [in ] - 2",
|
||||
"<48>": "* Handle [in ] - Query handle (hQry)",
|
||||
"<49>": "* Ret [out] - TRUE$ on success, FALSE$ otherwise",
|
||||
"<50>": "ClearTables:",
|
||||
"<51>": "{clearscript}",
|
||||
"<52>": "return",
|
||||
"<53>": "",
|
||||
"<54>": "",
|
||||
"<55>": "*****************",
|
||||
"<56>": "* Drop SQL Tables",
|
||||
"<57>": "*****************",
|
||||
"<58>": "* Instruction [in ] - 3",
|
||||
"<59>": "* Handle [in ] - Query handle (hQry)",
|
||||
"<60>": "* Ret [out] - TRUE$ on success, FALSE$ otherwise",
|
||||
"<61>": "DropTables:",
|
||||
"<62>": "{dropscript}",
|
||||
"<63>": "return",
|
||||
"<64>": "",
|
||||
"<65>": "",
|
||||
"<66>": "**********************************",
|
||||
"<67>": "* Initialize Warehousing Procedure",
|
||||
"<68>": "**********************************",
|
||||
"<69>": "* Instruction [in ] - 4",
|
||||
"<70>": "* Handle [in ] - Connection handle (hXO)",
|
||||
"<71>": "* [out] - @fm-delimited DataSet handles (hDS)",
|
||||
"<72>": "* Info [in ] - Requested warehouse type (e.g. FULL, UPDATES)",
|
||||
"<73>": "* [out] - LH table name",
|
||||
"<74>": "* cursor #0 [out] - A select list of keys to warehouse",
|
||||
"<75>": "* @reccount [out] - Number of keys in the select list",
|
||||
"<76>": "* Ret [out] - TRUE$ on success, FALSE$ otherwise",
|
||||
"<77>": "ProcessInit:",
|
||||
"<78>": " Table = \"{table}\"",
|
||||
"<79>": "{datasetnames}",
|
||||
"<80>": " DSHandles = \"\"",
|
||||
"<81>": "",
|
||||
"<82>": " * the SQLExp_Select function selects the LH records to warehouse;",
|
||||
"<83>": " * by encapsulating this functionality in a separate procedure,",
|
||||
"<84>": " * addition warehouse types can be added without requiring changes",
|
||||
"<85>": " * to individual Warehouse Procedures",
|
||||
"<86>": " clearselect 0",
|
||||
"<87>": " Ret = SQLExp_Select(Table, Info)",
|
||||
"<88>": "",
|
||||
"<89>": " if Ret then",
|
||||
"<90>": " * create DataSets",
|
||||
"<91>": " Count = count(DSNames, @fm) + (DSNames # \"\")",
|
||||
"<92>": " for i = 1 to Count",
|
||||
"<93>": " hDS = DSInstance(DSNames<i>, Handle)",
|
||||
"<94>": " if hDS else",
|
||||
"<95>": " Ret = FALSE$",
|
||||
"<96>": " end",
|
||||
"<97>": " while Ret",
|
||||
"<98>": " DSHandles<i> = hDS",
|
||||
"<99>": " next i",
|
||||
"<100>": "",
|
||||
"<101>": " * if one DataSet failed creation, destroy all DataSets",
|
||||
"<102>": " if Ret else",
|
||||
"<103>": " for i = 1 to Count",
|
||||
"<104>": " hDS = DSHandles<i>",
|
||||
"<105>": " if hDS then",
|
||||
"<106>": " DSMethod(hDS, DS_DESTROY$)",
|
||||
"<107>": " DSHandles<i> = 0",
|
||||
"<108>": " end",
|
||||
"<109>": " next i",
|
||||
"<110>": " end",
|
||||
"<111>": " end",
|
||||
"<112>": "",
|
||||
"<113>": " * return DataSet handles in Handle parameter",
|
||||
"<114>": " Handle = DSHandles",
|
||||
"<115>": "",
|
||||
"<116>": " * return LH table name in Info parameter",
|
||||
"<117>": " Info = Table",
|
||||
"<118>": "return",
|
||||
"<119>": "",
|
||||
"<120>": "",
|
||||
"<121>": "************************",
|
||||
"<122>": "* Warehouse an LH Record",
|
||||
"<123>": "************************",
|
||||
"<124>": "* Instruction [in ] - 5",
|
||||
"<125>": "* Handle [in ] - @fm-delimited DataSet handles (hDS)",
|
||||
"<126>": "* Info [in ] - if TRUE$, the Warehouse Procedure must first remove",
|
||||
"<127>": "* any existing data from the warehouse which corresponds",
|
||||
"<128>": "* to this record",
|
||||
"<129>": "* @id [in ] - the ID of the LH record",
|
||||
"<130>": "* @record [in ] - the LH record",
|
||||
"<131>": "* @mv [in ] - zero (all)",
|
||||
"<132>": "* @dict [in ] - the table's dictionary file handle",
|
||||
"<133>": "* Ret [out] - TRUE$ on success, FALSE$ otherwise",
|
||||
"<134>": "ProcessRecord:",
|
||||
"<135>": " * calculate \"base\" key fields",
|
||||
"<136>": "{calcbasefields}",
|
||||
"<137>": "",
|
||||
"<138>": " * delete existing data",
|
||||
"<139>": " if Info then",
|
||||
"<140>": " * set DataSet arguments (the base key fields)",
|
||||
"<141>": " Args = \"\"",
|
||||
"<142>": "{argnames}",
|
||||
"<143>": "",
|
||||
"<144>": " Vals = \"\"",
|
||||
"<145>": "{argvalues}",
|
||||
"<146>": "",
|
||||
"<147>": " Count = count(Handle, @fm) + (Handle # \"\")",
|
||||
"<148>": " for i = 1 to Count",
|
||||
"<149>": " Ret = DSSetProperty(Handle<i>, DS_ARG$, Vals, Args)",
|
||||
"<150>": " next i",
|
||||
"<151>": "",
|
||||
"<152>": " * execute DataSets",
|
||||
"<153>": " for i = 1 to Count",
|
||||
"<154>": " Ret = DSMethod(Handle<i>, DS_EXECUTE$)",
|
||||
"<155>": " while Ret",
|
||||
"<156>": " next i",
|
||||
"<157>": "",
|
||||
"<158>": " * delete all rows from DataSets",
|
||||
"<159>": " if Ret then",
|
||||
"<160>": " for i = 1 to Count",
|
||||
"<161>": " DSGetProperty(Handle<i>, DS_ROWCOUNT$, RowCount)",
|
||||
"<162>": " DSSetProperty(Handle<i>, DS_ROWID$, 1)",
|
||||
"<163>": " for iRow = 1 to RowCount",
|
||||
"<164>": " DSMethod(Handle<i>, DS_DELETE$)",
|
||||
"<165>": " next iRow",
|
||||
"<166>": " next i",
|
||||
"<167>": " end",
|
||||
"<168>": " end",
|
||||
"<169>": "",
|
||||
"<170>": " * insert new data",
|
||||
"<171>": " if Ret and len(@record) then",
|
||||
"<172>": " * calculate all used fields",
|
||||
"<173>": "{calcotherfields}",
|
||||
"<174>": "",
|
||||
"<175>": "{filldatasets}",
|
||||
"<176>": " end",
|
||||
"<177>": "return",
|
||||
"<178>": "",
|
||||
"<179>": "",
|
||||
"<180>": "*********************************",
|
||||
"<181>": "* Terminate Warehousing Procedure",
|
||||
"<182>": "*********************************",
|
||||
"<183>": "* Instruction [in ] - 6",
|
||||
"<184>": "* Handle [in ] - @fm-delimited DataSet handles (hDS)",
|
||||
"<185>": "* Ret [out] - TRUE$ on success, FALSE$ otherwise",
|
||||
"<186>": "ProcessTerm:",
|
||||
"<187>": " * destroy all DataSets",
|
||||
"<188>": " Count = count(Handle, @fm) + (Handle # \"\")",
|
||||
"<189>": " for i = 1 to Count",
|
||||
"<190>": " hDS = Handle<i>",
|
||||
"<191>": " if hDS then",
|
||||
"<192>": " DSMethod(hDS, DS_DESTROY$)",
|
||||
"<193>": " Handle<i> = 0",
|
||||
"<194>": " end",
|
||||
"<195>": " next i",
|
||||
"<196>": "return",
|
||||
"<197>": "",
|
||||
"<198>": "",
|
||||
"<199>": "**********************",
|
||||
"<200>": "* Execute a SQL Script",
|
||||
"<201>": "**********************",
|
||||
"<202>": "* Handle [in ] - Query Handle (hQry)",
|
||||
"<203>": "* Script [in ] - SQL Script",
|
||||
"<204>": "* Ret [out] - Cumulative result: Assumed to start as TRUE$, failure sets to FALSE$, never reset to TRUE$",
|
||||
"<205>": "ExecuteScript:",
|
||||
"<206>": " Ret = (Ret and QryMethod(Handle, QRY_EXECUTE$, Script))",
|
||||
"<207>": " QryMethod(Handle, QRY_CANCEL$)",
|
||||
"<208>": "return",
|
||||
"<209>": ""
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user