Visual RPG Language Reference  

DCLMEMORYFILE - Declare Memory File as ADO.NET Dataset

Declares a memory file that results in an ADO.NET Dataset object. The file can be created and accessed similar to an externally described database file even though it is cached in memory. Currently, the memory file description is externally described as System i or DataGate Windows database file.

DCLMEMORYFILE
Name
(MemoryFile name) Org (*ARRIVAL) DbDesc (Database Object | Character Expression) FileDesc (*NAME | Character Expression) XmlDesc (Character Expression) AddRec (*NO | *YES) ImpOpen (*YES | *NO) RnmFmt (*NONE | Old Format name, New Format name, ...) Subfile(*NONE | Format name, RRN name, ...) Prefix (prefix name, [Length]) Access (*PRIVATE | *PUBLIC | *PROTECTED | *INTERNAL) Shared (*NO | *YES)

Parts

Name

Required. Name of a memory file.  Must be a valid Visual RPG name, such as:

  • The name of the variable already defined.

  • A string literal, which defines an *OBJECT variable of a particular type. The string literal must represent:

  • a valid program id registered on your system at compile time.

  • a valid class id registered on your system at compile time.

  • a valid interface name registered on your system at compile time.

  • A name of the form Library.Object, where Library is the name of one of the libraries selected in the new object libraries dialog, and Object is valid object name within that library.

Note: Using the MemoryFile name, you can then get to its fields and properties. Please note that methods are reserved for use by the ASNA.Visual RPG compiler, so use the corresponding Visual RPG command if applicable.

Org

Optional. Specifies if the file is a Sequential (*Arrival ) file. The default is *ARRIVAL.

  • *ARRIVAL (default) - the file is a Sequential file.

DbDesc

Optional.  Database description.  Specifies the database to use during compile-time to access the File Description.

  • Database Object declaration whose DbName specifies where the compiler will acquire the file description.  Database Objects are defined with the DCLDB command.

  • Character expression - the Database Name to get the description from.  Used in conjunction with FileDesc.

FileDesc

Optional. File description. Takes the description of the named file as the bases to layout the memory file. Used in conjunction with DbDesc.

This parameter must be a character literal, so the file description can be accessed at compile time.

  • *NAME (default) - uses the parameter Name to find the file to obtain the description of the file's layout.

  • Character expression - the description of the database file.

XmlDesc

Optional. This parameter can be either an XML string containing the schema layout for the memory file or alternatively it can have a local PC file name containing the schema. This parameter must be a character literal, so the file description can be accessed at compile time.

If the character literal begins with a '<', then the string is interpreted to be the XML Schema, otherwise it is interpreted to be a reference to a text file containing the schema.

When referencing a text file, you can provide either an absolute or a relative path to the file.

  • An absolute path uses the standard Uniform Resource Identifier syntax (like the one used to address web pages).

  • A relative path starts with a period followed by the list of folders leading to the file location. The ‘current directory’ referenced by the period is considered to be the same as the one where the source file containing the DclMemoryFile resides.

Examples:

DclMemoryFile Rel . . . .XmlDesc(“./mySchema.xsd”)

DclMemoryFile Abs . . . XmlDesc(“file:///C:/Def/mySchema.xsd”)

DclMemoryFile Ftp . . . .XmlDesc(“ftp://ftp.myCompany.com/Def/mySchema.xsd”)

AddRec

Optional. You must use the AddRec (*YES) option if you wish to add a record to the file.

ImpOpen

Optional. Implicit Open. Specifies whether the file will automatically be opened when the program is first run. If the implicit open is unsuccessful, a run-time error will occur. The default is *YES.

  • *YES (default) - the file will automatically be opened when the program is first run. If the implicit open is unsuccessful, a run-time error will occur.

  • *NO - the file will not automatically be opened when the program is first run.

RnmFmt

Optional. Rename Format. Renames the old format to a new format to avoid clashes with duplicate format names. *NONE is the default.

For single format files, you can specify RNMFMT (New Format name) - which will automatically rename the only format in the file to the New Format name. If you specify the syntax "Old format name, New Format name for single format files, the Visual RPG compiler will ignore the Old Format name.Prefix.

Subfile

Optional.  The Subfile keyword is used to internally define the subfiles that are specified in the memory file.  The Format name identifies the name of the subfile record format and the RRN name identifies the name of the numeric field to be associated with the subfile to communicate the relative-record-number.  Each subfile format name with its corresponding RRN name, must be listed in the single Subfile keyword.

The relative-record number of any record retrieved by a READC or CHAIN operation is placed into the field identified by the RRN parameter.  This field is also used to specify the record number used in WRITE operations to the subfile.  The field name specified as the rrn field parameter must be defined as numeric with zero decimal positions.

Prefix

Optional. Allows the specification of a string which is to be prefixed to the field names of an externally described record format. The characters specified (prefix name) are prefixed to all fields defined in all record formats of the file.

You can also optionally specify a numeric value (length) to indicate the number of leading characters in the existing name to be replaced. If a length is not specified or is zero, the string is prepended to the name.

  • If a length is specified, it must be a numeric constant containing a value between 0 and 13 with no decimal places. Specifying a value of zero is the same as not specifying a length at all.

  • The length parameter must not be greater than or equal to number of characters in the name to be prefixed. That is, the resulting name cannot be the same as the prefix string after the prefix is applied. 

Access

Optional. The type of access to the member. The default is *PRIVATE.

  • PRIVATE (default) - access to the member is accessible only from within their declaration context, including from members of any nested types, for example from within a nested procedure or from an assignment expression in a nested enumeration.

  • *PUBLIC - access to the member is accessible from anywhere within the same project, from other projects that reference the project, and from an assembly built from the project.

  • *PROTECTED - access to the member is accessible only from within the same class, or from a class derived from this class.

  • *INTERNAL - access to the member is accessible from within the same project, but not from outside the project.

Shared

Optional. Indicates that one or more declared programming elements are shared. Shared elements are not associated with a specific instance of a class or structure. You can access them by qualifying them either with the class or structure name, or with the variable name of a specific instance of the class or structure. *NO is the default, indicating that the file will not be shared.

  • *NO (default) - this file will not be shared.

  • *YES - this file will be shared.

Remarks

The following is a listing of the fields and properties that you can use by specifying the "name" of the memory file as declared with DCLMEMORYFILE Name (MemoryFile Name).

See Also

MemoryFile Members
DCLDB