compile Insert RTI_MVBFS_SERVER_PLUGIN_D3_SOURCE
/*
* This insert contains the source for a program to install on the D3 server
* The program will support efficient record selection
* I used conditional compilation to prevent compiling in oi
*/
#UNDEFINE _IGNORE_THE_FOLLOWING_
#IFDEF _IGNORE_THE_FOLLOWING_
SUBROUTINE RTI_MVBFS_SERVER_PLUGIN_D3(METHOD, COMMANDS, ACTIVELIST, UNIQUEID, RESULTS)
*
*
* THIS SUBROUTINE IS USED FOR EXECUTING A CHAIN OF QUERIES ON D3, RETURNING THE KEYS TO OI
* SEE RTI_CHAIN_SELECT.
*
* 01/31/19   rjc  Created
* 02/07/19   rjc  Pass in unique list id
* **********************************



EQU TRUE TO 1, FALSE TO 0
EQU AM TO CHAR(254), VM TO CHAR(253), SVM TO CHAR(252), FM TO CHAR(254)

RESULTS = "NO RECORDS SELECTED"
LISTID = 'RTI_SERVER_SELECT_':UNIQUEID

*
* Did they pass in some keys?
* If so, make an active select list
*

LISTFILE = 'POINTER-FILE'
   
OPEN LISTFILE TO F_LISTS ELSE
    STOP
END

IF ACTIVELIST NE '' THEN
  
      WRITE ACTIVELIST ON F_LISTS, LISTID

      EXECUTE 'GET-LIST ':LISTID
   
END


*
* Run the commands
*
EXEC.ERR = ""

CMD_CNT = DCOUNT(COMMANDS, AM)

FOR WHICH_COMMAND = 1 TO CMD_CNT-1

   CMD = COMMANDS<WHICH_COMMAND>
   IF CMD # "" THEN
      data CMD
   END
   
NEXT WHICH_COMMAND

EXECUTE COMMANDS<CMD_CNT> ;* OPTIONALLY "CAPTURING" OR "RETURNING" CLAUSE

*
* Pass  back the keys
*
EXECUTE 'SAVE-LIST  ' : LISTID

READ RESULTS FROM F_LISTS, LISTID ELSE
   RESULTS = "ERROR"
END

    
EXECUTE 'DELETE-LIST  ' :LISTID


RETURN
#ENDIF
