SQL iQuery Script Built-in Functions

Retrieve Data from a User Space

USRSPC

The USRSPC() built-in function returns the content of a user space (*USRSPC) object. The user space and location within the user space are specified. The data from the user space is returned, usually into a Session Variable. This built-in function is similar to the DTAARA built-in function which works similarly but with data areas.

Syntax

The USRSPC built-in function returns the contents of the user space specified on the first parameter, using the optional starting position and length parameters to extract the data.

Parameters

  1. The qualified name of a user space whose content is retrieved. This can be in the form: library/usrpsc or simply usrspc without a qualified library name.
  2. The starting position within the user space.
  3. The Length of the data to be returned.

A user space object type is *USRSPC that can be created using a number of different methods. The CRTUSRSPC CL command in COZTOOLS is one, the QUSCRTUS API is another. SQL iQuery Script also has a CRTUSRSPACE command that allows you to create user spaces.

Example:
The user space SAVEDSTUFF was created in QTEMP and the data '01REG12Acme Tools' is stored in it starting in position 1. The following script retrieves the Region code from the user space.


eval &region = usrspc('qtemp/savedStuff', 3,5);
#msg The Region Code is "&Region"

The output written to the joblog is:

The Region Code is "REG12"