The Default State Record must be built as an SQL Table. This is not documented (I think).
You can then use the Run Control by binding as in the following example. If it is a Derived Work table, not an SQL Table, the %Bind value will be Null.
INSERT INTO PS_SOME_TEST_TBL
SELECT EMPLID, 'Test ID'
FROM
(SELECT EMPLID FROM PS_JOB
ORDER BY DBMS_RANDOM.VALUE)
WHERE ROWNUM < 101;
/* Create a set of global look-up arrays.
This will remove the need to call the db many, many times.
See CC_FUNCLIB_UOA.LOOKUP.FieldFormula for how to call/use. */
Component array of string &arrPinNumIndex;
Component array of number &arrPinNumVal;
Component array of number &arrPinNmIndex;
Component array of string &arrPinNmVal;
Local SQL &sql;
Local string &pinNm;
Local integer &pinNum, &i;
/* PIN_NUM Lookup: */
&arrPinNumIndex = CreateArrayRept("", 0);
&arrPinNumVal = CreateArrayRept(0, 0);
&sql = CreateSQL("SELECT PIN_NM, PIN_NUM FROM %Table(GP_PIN) ORDER BY 1");
&i = 1;
While &sql.Fetch(&pinNm, &pinNum)
&arrPinNumIndex [&i] = &pinNm;
&arrPinNumVal [&i] = &pinNum;
&i = &i + 1;
End-While;
/* PIN_NM Lookup: */
&arrPinNmIndex = CreateArrayRept(0, 0);
&arrPinNmVal = CreateArrayRept("", 0);
&sql = CreateSQL("SELECT PIN_NUM, PIN_NM FROM %Table(GP_PIN) ORDER BY 1");
&i = 1;
While &sql.Fetch(&pinNum, &pinNm)
&arrPinNmIndex [&i] = &pinNum;
&arrPinNmVal [&i] = &pinNm;
&i = &i + 1;
End-While;
<* Search the global array that stores cached lookup values from database.
This removes (a lot of) roundtrips between app server and db server.
Example of use:
/* previously populated arrays - index and value. */
Component array of string &arrPinNumIndex;
Component array of number &arrPinNumVal;
Declare Function GetCached PeopleCode CC_FUNCLIB_UOA.LOOKUP FieldFormula;
&x = GetCached("ZACC ALA", &arrPinNumIndex, &arrPinNumVal);
i.e. Pass it a pin name and two, synchronised arrays.
The first array contains the index, the second contains values that are returned.
Obviously only works on "2 dimensional arrays"
*>
Function BinarySearch(&arr, &srchVal, &low As integer, &high As integer) Returns integer
If (&high < &low) Then
Return - 1; /* not found */
End-If;
&mid = &low + ((&high - &low) / 2);
If &arr [&mid] > &srchVal Then
Return BinarySearch(&arr, &srchVal, &low, &mid - 1);
Else
If &arr [&mid] < &srchVal Then
Return BinarySearch(&arr, &srchVal, &mid + 1, &high);
Else
Return ∣ /* found */
End-If;
End-If;
End-Function;
Function GetCached(&srch, &arrIndex, &arrVal) Returns any
&i = BinarySearch(&arrIndex, &srch, 1, &arrIndex.len);
If &i = - 1 Then
Return 0; /* not found */
Else
Return &arrVal [&i];
End-If;
End-Function;
/* Lookup array arrays: */
Component array of string &arrPinNumIndex;
Component array of number &arrPinNumVal;
&x = GetCached("BASE PAY", &arrPinNumIndex, &arrPinNumVal);