KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Retrieving an array from a stored procedure
PRODUCT: 4D Server | VERSION: 2004.4 | PLATFORM: Mac & Win
Published On: July 14, 2006

Using 4D Client, you can read a variable such an array in a process executed on the server machine (stored procedure) using the GET PROCESS VARIABLE command. Below is a sample code that shows how to do this:

`ClientMethod
C_LONGINT(spErrCode)
ARRAY TEXT(myarr1;0)
$spProcessID:=Execute on server("MStoreProc1";32*1024;"Server 1")

Repeat
   DELAY PROCESS(Current process;300)
   GET PROCESS VARIABLE($spProcessID;spErrCode;spErrCode)
   If (Undefined(spErrCode))
      spErrCode:=1
   End if
Until (spErrCode<=0)
GET PROCESS VARIABLE($spProcessID;myarr1;myarr1)
spErrCode:=1
SET PROCESS VARIABLE($spProcessID;spErrCode;spErrCode)

`-------------------------------------------------------------------------------------------------------------------

`Method: MStoreProc1
`Description: Stored Procedure that will return array.
C_LONGINT(spErrCode)
ARRAY TEXT(myarr1;0)
   ` Operation is not finished yet, set spErrCode to 1
spErrCode:=1
myarr1:=APPEND TO ARRAY(myarr1;"AAA")
myarr1:=APPEND TO ARRAY(myarr1;"BBB")
myarr1:=APPEND TO ARRAY(myarr1;"CCC")

spErrCode:=0
   ` Wait until the requester Client got the result back
Repeat
   DELAY PROCESS(Current process;1)
Until (spErrCode>0)