5.30.9 METADATA

The METADATA command is used to access the database table column name, column type, column precision and column scale information.

Syntax:

Command

Keyword

Value

Developer notes

METADATA

TABLE

value

Required. Used to indicate the table you want to retrieve the metadata for.

 

Lists and Variables

This command requires a working list to return the table metadata back to. This working list should be made available in the TO_GET portion of this JSM_COMMAND. The working list will require four fields in this sequence:

1.  Column name

2.  Column type

3.  Column precision

4.  Column scale.

You may size the fields to fit the information you are expecting back from the remote database. Different databases may have different lengths and types for this information.

Example

RDML

* Define the JSM command and message fields

DEFINE FIELD(#JSMSTS) TYPE(*CHAR) LENGTH(020)

DEFINE FIELD(#JSMMSG) TYPE(*CHAR) LENGTH(256)

DEFINE FIELD(#JSMCMD) TYPE(*CHAR) LENGTH(256)

 

Define the fields and list that meta data will be returned back into

DEFINE FIELD(#COLNAME) TYPE(*CHAR) LENGTH(030)

DEFINE FIELD(#COLTYPE) TYPE(*CHAR) LENGTH(030)

DEFINE FIELD(#COLPRCSN) TYPE(*DEC) LENGTH(003) DECIMALS(0)

DEFINE FIELD(#COLSCALE) TYPE(*DEC) LENGTH(003) DECIMALS(0)

 

DEF_LIST NAME(#WRKLST) FIELDS(#COLNAME #COLTYPE #COLPRCSN #COLSCALE) TYPE(*WORKING)

 

Prepare and execute the command

CHANGE FIELD(#JSMCMD) TO('METADATA TABLE(TBLNAME) SERVICE_LIST(COLNAME,COLTYPE,COLPRCSN,COLSCALE)')

USE BUILTIN(JSM_COMMAND) WITH_ARGS(#JSMCMD) TO_GET(#JSMSTS #JSMMSG #WRKLST)

RDMLX

Define Field(#JSMSTS) Type(*CHAR) Length(020)

Define Field(#JSMMSG) Type(*CHAR) Length(256)

Define Field(#JSMCMD) Type(*CHAR) Length(256)

Define Field(#JSMHND) Type(*Char) Length(4)

 

Define the fields and list that meta data will be returned back into

Define Field(#COLNAME) Type(*CHAR) Length(030)

Define Field(#COLTYPE) Type(*CHAR) Length(030)

Define Field(#COLPRCSN) Type(*DEC) Length(003) DECIMALS(0)

Define Field(#COLSCALE) Type(*DEC) Length(003) DECIMALS(0)

 

Def_List Name(#WRKLST) Fields(#COLNAME #COLTYPE #COLPRCSN #COLSCALE) Type(*WORKING)

 

Prepare and execute the command

#JSMCMD := 'Metadata Table(TBLNAME)'

Use Builtin(JSMX_COMMAND) With_Args(#JSMHND #JSMCMD) To_Get(#JSMSTS #JSMMSG)