Configuring and Using PSDB

This topic describes how the PSDB is configured and used. The topics included are:

Defining the Parameter File

The lines in the parameter file cannot exceed 512 characters (including comments). It is possible to use lower or upper case letters or a mixture of both. PSDB converts everything sent to the database to capital letters (only strings surrounded by a pair of ("") or a pair of ("") are not converted). The PSDB interface interprets the parameter file line by line. The interpretation of a line depends on the first character in the line (leading blanks are stripped). The different PSDB keywords are described below. Lines not starting with a PSDB keyword are interpreted as part of a SQL statement and are to the string that holds the SQL statement.

Empty lines are skipped and lines starting with an exclamation mark "!" are also skipped.

STATEMENT

The parameter file consists of several statements. A parameter file statement defines one or more commands (SQL statements) that are sent to the database. Each parameter file statement can be executed from Infor M3 SWB.

A statement definition starts by declaring the name of the statement in square brackets:

[<Statement name>]

Statement Description
@TITLE

During the execution of a statement, you can display the statement in Infor M3 SWB description. This text is written by using a title definition line:

@TITLE=<Text describing statement>

@CONVERTCHARS

The @CONVERTCHARS line is used to state that fields of type CHAR should be converted. The conversion means that all characters received from the database are converted to the actual Windows character set, and all characters sent to the database are converted from the actual Windows character set. To receive national characters from the database, you might require to use this option. Likewise you might require to use the option when inserting data with national characters into the database from Infor M3 SWB. The @CONVERTCHARS line has only effect within the statement is placed.

@ARRAY

If @ARRAY is used an array buffer is used when sending or receiving data. This means that several lines are sent and received simultaneously. The PSDB keeps track of when to retrieve or send lines from the database again. This can give a performance gain.

The syntax of the @ARRAY line is:

@ARRAY=<Array size>

Array size is the size of the used array buffer. The @ARRAY line has only effect within the statement is placed.

@COL and @WCOL

These types of lines define the mapping between the database fields and the Infor M3 SWB fields. A @COL or @WCOL line consists of six elements separated by semicolons. The @WCOL is used like the @COL when inside a WHERE clause in a statement. The syntax of the @COL and @WCOL lines are:

<Column definition>;<SQL type>;<Functions>;<APP field name>;<from position:To position>;<Comment>

Column definition:

This element contains, in addition to @COL= or @WCOL, the name of the database column in question. You can also state a fixed value.

SQL type:

This element defines the SQL type of the database column.

Functions:

Defines if one or more PSDB function is used.

APP field name:

This element states the Infor M3 SWB field name. The Infor M3 SWB field name is specified using symbolic names. A symbolic name contains both data type, offset and length information.

From position:To position:

If the Infor M3 SWB field is a character field, you can address only a part of the field by specifying a from and a to position within the field. If this element is left blank the whole field is used.

Comment:

Any comment.

These types of lines are used when data is taken from or inserted into Infor M3 SWB.

@LINKED

A parameter file statement defines one or more commands (SQL statements) that are sent to the database. The commands can be linked together within a statement by the @LINKED line. After the first command definition in the statement, write @LINKED on a line and define the next command.

The linked commands are executed sequentially.

@SKIP

This is used when you want to skip execution of a particular command.

SQL Data Types (Database Data Types)

These SQL data types can be used in the @COL/@WCOL lines:

Type Description
CHAR A string with a fixed length
DATE A date in database format
DECIMAL A decimal number (you can define length and decimal precision , for example, 'DEC 9,2' would define a DECIMAL(9,2) type
DOUBLE A decimal number of type DOUBLE (same as DECIMAL(15,6))
FLOAT A decimal number of type FLOAT (same as DECIMAL(15,6))
INTEGER An integer number. The number can be between –2147483648 and 2147483647
SMALLINT An integer number. The number can be between - 32768 and 32767
TIME A time in database format
TIMESTAMP A timestamp in database format
VARCHAR A string with variable length

It is not necessary to write more characters than necessary for a unique identification of the SQL type. An "F" is enough to state a FLOAT type, while you must write TIMES to state a TIMESTAMP type. When using the DECIMAL type it is also possible to state the maximum dimensions of the type. If no dimensions are stated the default 15,6 is used.

Data Types of Infor M3 SWB Fields

 The Infor M3 SWB fields used in the @COL/@WCOL lines are defined by using symbolic names. These symbolic names contain both data type, offset and length information. The data types are supported:

Data Type Description
CHAR Text field.
FLOAT A 4-byte floating point field.
LONG A 4-byte signed integer field that ranges from -2147483648 to 2147483647.
SHORT A 2-byte signed integer field that ranges from -32768 to 32767.

For each statement in the parameter file one or more data structures are available. Only fields within these structures can be addressed. An Infor M3 SWB field is specified in the parameter file by writing the data structure name and the field name separated by a dot.

Functions

The PSDB functions makes it possible to change the data to be sent to or the data retrieved from the database. The functions are placed in the functions element in the @COL and @WCOL lines. Several functions can be called in a single @COL/@WCOL line: Separate the functions with a pipe sign "|" and the functions are called in continuation of each other. The available PSDB functions are described below:

Function Description
BIT

This syntax of the BIT function is:

BIT(<Bit number>,<Bit set value>,<Bit not set value>) 

This result of this function depends on whether it is used during import or export:

When used during import the value of the database column field is compared with the <Bit set value>. If the match then the bit <Bit number> is set in the Infor M3 SWB field otherwise it is cleared.

When used during export the value of bit <Bit number> in the Infor M3 SWB field is examined. If the bit is set then the <Bit set value> is sent to the database, otherwise the <Bit not set value> is sent.

The type of the Infor M3 SWB field has to be LONG or SHORT.

IFEMPTY

This syntax of the IFEMPTY function is:

IFEMPTY (<value>)

This function converts an empty or blank value to another value. If the input to the function is empty or blank the argument value is returned instead. The type of the Infor M3 SWB field must be CHAR.

LTRUNC

This function removes leading blanks from a string. The type of the Infor M3 SWB field must be CHAR.

MATH

This syntax of the MATH function is:

MATH(<Mathematical expression>)

This function can make simple calculations using ordinary arithmetic operators. You can perform several calculations on the same data.

These operators are available:

  • + Addition
  • - Subtraction
  • * Multiplication
  • / Division
  • ! Inversion
  • ^ Power
  • # Square root
PMS2XD

This function converts a date value in internal Infor M3 SWB format to a LONG representation of a date value in the format YYYYMMDD. The type of the Infor M3 SWB field must be LONG.

PMS2XT

This function converts a time value in internal Infor M3 SWB format to a LONG representation of a time value in the format HHMMSS. The type of the Infor M3 SWB field must be LONG.

RTRUNC

This function removes trailing blanks from a string. The type of the Infor M3 SWB field must be CHAR.

STRIP

This function removes leading and trailing blanks from a string. The function combines the functionality of the LTRUNC and RTRUNC functions. The type of the Infor M3 SWB field must be CHAR.

TRANS

This syntax of the TRANS function is:

TRANS(x1,y1)(x2,y2)...(Default)

This function transforms data from one value to another value. The function compares the input to the function with the value stated as the x value in the syntax. If these two values match, then the function will instead return the y value. You can state a default value. The default value is used if none of the x values equals the input value. If a default value is stated it must be placed at the end of the TRANS function.

XD2PMS

This function converts a date on the format YYYMMDD to internal Infor M3 SWB format. The type of the Infor M3 SWB field has to be LONG.

XT2PMS

This function converts a time value on the format HHMMSS to internal Infor M3 SWB format. The type of the Infor M3 SWB field has to be LONG.

DECPCD

This function converts a decimal point from "," to "." in a character representation of a decimal. The type of the Infor M3 SWB field has to be CHAR.

DECPDC

This function converts a decimal point from "." to "," in a character representation of a decimal. The type of the Infor M3 SWB field has to be CHAR.