Pages  [ 1  2  3  4 ]

An Introduction to mvServer 2.0 (continued):

 

The Vantage Server Protocol (continued)

 

Stored Procedure Execution

The following messages are part of the Stored Procedure Execution protocol category:

ExecuteProc

Element

Description

Number

39

Constant

vxExecProcCmd

Input Arguments

1 = Server Handle - The number assigned for this server session.  

2 = Database Handle - The number assigned to the database (Pick account) during the open database function.

3 = Procedure Name - The name of the process to execute (Pick subroutine name).

4 = Arguments - List (multi-valued) of arguments to pass to the process.

Output Arguments

1 = Return Code - 1=Success; 0=Failed.

2 = User Results - Values or complete result sets. Records should be delimited by a Record mark and fields should be delimited by attribute marks. This parameter can be used to return Error messages if the return code is zero.

Operation

The server first checks to see if the database number is valid and active.

The server program then checks to see if the procedure name exists in the master dictionary or Voc file of the server account. It checks to see if the first character of the first attribute is a V or P (cannot be part of a PQ, however).

The program makes an indirect CALL of the procedure (i.e. calling @Procedure). The arguments it passes are:

DBID - The database id which references a given Pick Account. This value is passed as the Database handle by the client.

ARGS - A multi-valued list of arguments passed by the client. This list of values is optional and can be a null string, or the arguments needed by the procedure being called.

RTNCD - This is a return argument supplied by the called procedure upon completion. If this value is the number one (1), the procedure has indicated that it has successfully been executed. A value of zero indicates the process has failed in some way. Error messages associated with the failure can be passed back through the RESULT parameter. The server program will pass this argument value back as the return code.

RESULT - This is a return argument supplied by the called procedure upon completion. It can either have the results of the procedure or a set of error messages that the server program will pass back to the client program. These results can be a single value, multiple values, or a set of records.

Programmer Notes:

When a client process initiates the server, the server (VSSERVER) will remain logged in as long as that process is running on the client or a Close Database and Close Connection message is sent from the client. That means, of course, all of the common variables will remain active for the duration of the process (a list of the servers common variables will be found in the INCLUDES file in the item VSCOMMON). Therefore, if the database system the programmer is on supports Named Common, the programmer will have access to those variables in the named common in their procedure(s) on the server during the entire execution of the client process.

The stored procedure may also call its on procedures, which in turn, may call other procedures. The programmer must remember that all files and procedures handled within their stored procedure program must be defined and/or compiled in the Server Account (MVSERVER).

File references used in a called stored procedure can use a special subroutine available on the MVSERVER account. This is the VSOPEN subroutine and provides to a called subroutine program, a file variable that can be used for file processing based on the VSDATABASE mapping and resulting q-pointer generated by the mapping process. The VSOPEN program has four arguments that must be passed when calling this routine. The calling syntax is as follows:

CALL VSOPEN(DBID, FILE.NAME, TYPE, FILE.REF, RTN)

Where the DBID is the Database handle passed to your stored procedure in your first argument. The FILE.NAME variable is a string containing the name of the file you want open. The TYPE variable has either the value 0 or 1. A 0 value represents the data level of the file, a 1 value represents the dictionary level of the file. The FILE.REF variable is the Pick file reference variable, returned from the VSOPEN routine. Once returned to your stored procedure program, you can use this file reference variable as you could any file variable that you opened with the standard Pick Basic OPEN statement. The RTN value is a flag indicating if the VSOPEN routine was successful in returning a valid file reference for the supplied file name. If RTN has a value of 1, the execution was successful and the FILE.REF argument has a valid file reference variable. If RTN has a zero value, the VSOPEN call failed for some reason, usually due to the supplied file name not being mapped.

Another important point to remember is that any Pick program routine used as a stored procedure cannot perform any standard input/output statements, as this will interrupt the normal client/server protocol flow between the server and the client program.

More information on stored procedures can be found later in this document

Note: The User Results parameter should have “substitute” Record Marks Char(249) delimiting records, and Attribute marks Char(254) delimiting fields. When working at the client side with dynamic array records that are sent or received from the Vantage Server, you must use the “normal” Record or Row mark (Char 255) to separate records and the Attribute mark (Char 254) to separate fields. The Channel database object HostSendMessage method, which handles all communication with the Vpmv20.dll file, converts the delimiters before passing them to and from the Vpmv20 DLL functions.  A Record mark (Char 254) is converted to the needed “substitute” Record Mark Char(249) when going to the Pick Host and is reversed when data is going to the client. Therefore, in your client code, when dealing with a result set from a stored procedure, you should expect multiple records to be delimited by the Record or Row mark (Char 255), and fields to be delimited by Attribute marks (Char 254). The reason for using a substitute character such as Char(249) for a Record or what is also known as a segment mark (Char 255) is that most Pick Host systems can not deal with a segment mark in data programmatically because this is a reserved delimiter.

 

Database Mapping Functions

The following messages are part of the Database Mapping protocol category:

Database Collection

Element

Description

Number

61

Constant

vxDbCollectionCmd

Input Arguments

1 = Server Handle - The number assigned for this server session.

2 = Data to Retrieve - 1 - Mapped; 128 - Unmapped; 255 - All Data.

Output Arguments

1 = Return code - 0 = Nothing available, n = Number of accounts sent back.

2 = Databases - A multi-valued list of Database (account) names.

3 = Database Attribute - An associated (to Databases) multi-valued list of 1s (mapped) or 128 (unmapped).

Operation

The server does a select of the SYSTEM or UV.ACCOUNT file (the name of this file will be different for various Pick implementations, but this is the file that contains the accounts names).

The server reads in each entry of the System file. It will check to see if it is a valid looking account (depends on the type of machine, on a standard Pick machine the first attribute would have a D). If the account looks like a valid account, it will then set a pointer to the master dictionary or Voc file of the account and open it. If the file does not open, that account will not be considered.

The program then checks to see if this database (account) has been mapped and exists in the VSDATABASE file.

The server makes a list of the accounts that meet the “Data to Retrieve” criteria defined by the client.

Table Collection

Element

Description

Number

62

Constant

vxTableCollectionCmd

Input Arguments

1 = Server Handle - The number assigned for this server session.

2 = Data to Retrieve - 1 Mapped; 2 Q-Pointer; 4 D-Pointer (actual file); 8 Virtual Table (MV); 16 Virtual Table (SV);  32 System Q-Pointer; 64 Base for Virtual Table; 128 Unmapped; 255 All.

3 = Database Name - The Name of the Account the files are to come from.

Output Arguments

1 = Return code - 0 No files found; n - Number of files returned

2 = Tables - A multi-valued list of table (file) names.

3 = Table Attributes - An associated multi-valued list (to Tables) that will return the attribute(s) each file met.

4 = Table Path - An associated multivalued list (to Tables) that will display the Database Name or Table Name.

Operation

The server reads the Database (account) name from the System, determining if it is a valid account.

If so, the server will set a q-pointer to the master dictionary or Voc file of the account, opening that file.

If the Client desires only mapped files, the server will select the VSDATABASE file for all of the file definitions associated with the Account passed. If the client desires both mapped and unmapped or only unmapped, the server will select the file opened above for any record appearing to be a real file, or a pointer to a file.

The server will then go through each file or q-pointer and determine the following:

Mapped - Is the file in the VSDATABASE file.

Not Mapped - Is the file not in the VSDATABASE file.

Q-Pointer - Is the file a q-pointer.

D-Pointer - Is the file a Real file.

System Pointer - Is the file a pointer to the System File or UV.ACCOUNT File.

Base/Virtual File - Is the file a BASE file (i.e. it has an associated multi-valued list of virtual files).

The server will add the file to be sent back to the client, if, based on the above criteria, it meets the clients Data to Retrieve specifications.

Field Collection

Element

Description

Number

63

Constant

vxFieldCollectionCmd

Input Arguments

1 = Server Handle - The number assigned for this server session.

2 = Data to Retrieve - 1 Mapped; 2 Synonym field; 4 Key or Unique Field; 8 Modifiable Field; 64 Mapped to a Virtual Table;  128 Unmapped; 255 All.

3 = Table Path - The Database (Account) Name and the Table (File) Name where the fields (dictionary items) can be found.

Output Arguments

1 = Return code - 0 Nothing found; n - Number of fields returned

2 = Fields - A multi-valued list of the fields found.

3 = Field Attributes - An associated multi-valued list (to fields) which returns the attribute(s) each field met.

4 = Field Type - An associated multi-valued list (to fields) which will return the Visual Basic field types: 0 for Undefined; 1 for Boolean; 2 for Byte, 3 for Number (small integer); 4 for Number (long integer), 5 for Currency, 6 for floating point (Single), 7 for floating point (Double), 8 for Date/Time, 9 for Binary, 10 for Text (String), 11 for Long Binary, 12 for Memo.

5 = Field Position - An associated multi-valued list (to fields) which will return the ordinal (attribute number) position.

6 = Field Delimiter Position - An associated multi-valued list (to fields) which will return the delimiter position codes if a concatenated field.

7 = Field Size - An associated multi-valued list (to fields) which will return the length of each field.

Operation

The server looks at the Table Path and reads the VSDATABASE file. Using the information, it opens the DICTIONARY of the file (table) within the account (database).

The server then selects the dictionary and reads in each dictionary record. It then determines if the record is a valid dictionary item (please refer to Database Mapping section for a definition of a valid field). The program checks if the field is:

Mapped - Resides in the VSDATABASE file.

Not Mapped - Does not exist in the VSDATABASE file.

Modifiable - Can this field be updated.

Key Field - Does the server consider the field a Key Field.

Virtual Field - Has this field been mapped to a virtual table.

The server will add the field to be sent back to the client, if, based on the above criteria, it meets the clients Data to Retrieve specifications.

Set Database Map

Element

Description

Number

71

Constant

VxSetDbMapCmd

Input Arguments

1 = Server Handle - The number assigned for this server session.

2 = Action – 0 for Unmap; 1 for map.

3 = Database List - A multivalued list of Database (account) names to be set.

Output Arguments

1 = Return Code - 1=Success; 0=Failed.

2 = Errors - Error messages if the return code is zero.

Operation

Documentation current not available.

Set Table Map

Element

Description

Number

72

Constant

VxSetTableMapCmd

Input Arguments

1 = Server Handle - The number assigned for this server session.

2 = Action – 0 for Unmap; 1 for map.

3 = Database Name - The name of the Database (account).

4 = Table List - A multivalued list of table (file) names to be set.

Output Arguments

1 = Return Code - 1=Success; 0=Failed.

2 = Errors - Error messages if the return code is zero.

Operation

Documentation current not available.

Set Field Map

Element

Description

Number

74

Constant

vxSetFieldMapCmd

Input Arguments

1 = Server Handle - The number assigned for this server session.

2 = Action – 0 for Unmap; 1 for map.

3 = Table Path - The name of the Database (account) and Table (File) name delimited by the back slash character (\).

4 = Field List - A multivalued list of Field (Attribute) names to be set.

5 = Field Attribute List – A multivalued list of Field attributes to set with. Value 2 for synonym field; 4 for key or unique field; 8 for modifiable field; and 64 for mapped to virtual table.

Output Arguments

1 = Return Code - 1=Success; 0=Failed.

2 = Errors - Error messages if the return code is zero.

Operation

Documentation current not available.

Set Virtual Map

Element

Description

Number

73

Constant

vxSetVirtualMapCmd

Input Arguments

1 = Server Handle - The number assigned for this server session.

2 = Action – 0 for Unmap all fields of virtual table and delete virtual table; 1 for map or creation of virtual table.

3 = Database Name - The name of the Database (account).

4 = Virtual Table List - A multivalued list of Virtual Table names to be set.

5 = Base Name List – A multivalued list of Base Table names that the corresponding Virtual Table names are to be based on.

Output Arguments

1 = Return Code - 1=Success; 0=Failed.

2 = Errors - Error messages if the return code is zero.

Operation

Documentation current not available.

 

Security Functions

The following messages are part of the Security Function protocol category:

User Collection

Element

Description

Number

51

Constant

vxUserCollectionCmd

Input Arguments

1 = Server Handle - The number assigned for this server session.

2 = Group Name - Group Name or * for all groups.

Output Arguments

1 = Return code - 0 for No users found; n for Number of users returned.

2 = Users - A multi-valued list of user names.

Operation

If the client passes a Group Name the server will read the Group from VSGROUPS file. It will then return all validated (verified the user is on the VSUSERS file) users from the Group record.

If the client passes an asterisk (*) the server will select the entire VSUSERS file and return a sorted list of users.

Group Collection

Element

Description

Number

52

Constant

vxGroupCollectionCmd

Input Arguments

1 = Server Handle - The number assigned for this server session.

2 = User Name - User Name or * for all users.

Output Arguments

1 = Return code - 0 for No groups found; n for Number of groups returned.

2 = Group Name - A multi-valued list of group names.

Operation

If the client passes a User Name the server will read the User from the VSUSERS file. It will then return all the validated (verified the group is on the VSGROUPS file) groups from the User record.

If the client passes an asterisk (*) the server will select the entire VSGROUP file and return a sorted list of groups.

Get Permissions

Element

Description

Number

55

Constant

vxGetPermissionsCmd

Input Arguments

1 = Server Handle - The number assigned for this server session.

2 = Object Type - 1 for database; 2 for table; 3 for field; 4 for procedure.

3 = Object Name - Name of database or table or field including any info needed to read the data in the VSDATABASE file (format of the key is database{\Table}{\Field}).

4 = Request Type - 0 for User; 1 for Group.

5 = Request Name - Name of User/Group or * for all Users/Groups.

Output Arguments

1 = Return code - 0 for none defined; n for Number of permissions values returned.

2 = Names - A multi-valued list of User or Group Names.

3 = Permissions - An associated multivalued list (to Names) of the permission codes.

Operation

The server will read the VSDATABASE file with the Object Name supplied by the client.

If the Request Name sent was not an asterisk, the server will find either the User Name or Group Name in the VSDATBASE record, sending the associated Permissions to the client.

If the Request Name sent was an asterisk (*), the server will return all group names or user names (in the record) and their associated Permission values.

User Update

Element

Description

Number

53

Constant

VxUserUpdateCmd

Input Arguments

1 = Server Handle - The number assigned for this server session.

2 = UserName – Name of user to update.