Special Command Tags
[MYSQL] Open MYSQL DataBase
 

The native MySql interface is a +PxPlus Exclusive

Format OPEN (chan [, fileopt ] [, OPT=params ] )"[MYSQL]Database [ ; [ table ] [ ;params ] ]"

Where:

[MYSQL] File tag clause to inform ProvideX that it will be opening a direct link to a MySql database server (not a ProvideX data file).
*Note* The square brackets around MYSQL are mandatory,
chan Channel or logical file number to open.
database Name of the Database to open (string expression).
fileopt File options. Supported options include:
ERR=stmtref Error transfer
IOL=iolref Default IOList
REC=string$ Record prefix (REC=VIS(string$) can also be used).
params Open parameters (See OPT= Parameters). All parameters are semi-colon separated and can be contained in the OPEN pathname and/or the OPT= string.
table Optional table name. If provided, PxPlus will internally translate all file IO directives (READ, WRITE, REMOVE, ...) into SQL statements for the specified table on the database.
   
Description The [MYSQL] tag is used as a prefix in an OPEN statement to denote that PxPlus is to route all file I/O requests to an external MySql Database server.

Once you open a channel for [MYSQL] use, you can use it just like any other channel (i.e., for file I/O). It remains open until you close it.

There are two basic modes of operation when using the MySql connection to a database -- Emulation and Direct. Emulation mode is used when a table name is provided in the open command. Direct mode is chosen when no table name is provided.

In emulation mode, the MySql interface will map all standard READ, WRITE, and REMOVE directives along with KEY functions, into SQL commands for the specified table. In this mode, the MySql table will emulate a normal PxPlus keyed or Indexed file. This mode allows most existing application to use MySql tables in lieu of native ProvideX/PxPlus files.

In native mode, the application is responsible for creating and submitting SQL commands directly to the database. The WRITE RECORD directive is used to send SQL commands to the MySql server and the READ or READ RECORD directives can be used to return the results (if any). The results of any SQL command will be returned as a logical PxPlus data record with field separators (SEP) between each field.

OPT= Parameters The OPEN parameters for connecting to a MYSQL server are listed below. Most of the parameters can also be specified in the ProvideX/PxPlus INI file in the "[MySql]" section.
BUSYRETRY= If set to N (or 0), the system will NOT retry SQL commands that return data busy statuses. Normally, you would set this to N if your MySql server automatically waits for busy records. The default is Y -- retry requests that return Data busy statuses.
CURSORCLOSE= Setting this to Y will force the system to close all "open" statements whenever a Commit is issued.
DATEFMT= Date format mask applied to all date fields in table. This can be a combination of Y M D with any other characters; e.g., to convert dates to 4-character year, month and day: DATEFMT=YYYYMMDD. Other characters are inserted as is; e.g., DATEFMT=YY/MM/DD with a date of March 1, 2004 would be returned as 04/03/01.
DATE_CONVERT= If set to Y, the system will convert database columns with DATE format to the standard system Date format as opposed to using the native ASCII date format used by MySql. Default is Y
DATETIME_CONVERT= If set to Y, the system will convert database columns with DATETIME format to the standard system Date format as opposed to using the native ASCII date format used by MySql. Default is Y.
DEBUG= String to append to SQL statement along with program name and line number for debugging purposes. This must indicate the comment character(s) appropriate to the MySql.
EXTROPT= Controls the format of the SELECT statement used to process an EXTRACT. By default, PxPlus will generate the lock clause based on the setting of the 'XI' system parameter.
  • If XI is on, the system generates:

SELECT * FROM table LOCK IN SHARE MODE WHERE...

If XI is off, the system generates:

SELECT * FROM table FOR UPDATE WHERE...

When EXTROPT=text, then text is substituted in place of FOR UPDATE/LOCK IN SHARE MODE. In addition, if the first character of text is $, then the remaining characters of text are placed at the end of the SELECT statement rather than after the filename. This allows for different variations of SQL to be supported.

IND= Identifies a column that contains a sequential number starting at 0. This is used to emulate an indexed file.
IOPROG= Specifies the name of an embedded IO program to use with this connection.
KEY= Identifies fields that make up the key(s). For named keys enter *NAME:keyname; e.g.,

OPEN(chan)"[MYSQL]dsn;table;KEY=field,field,*NAME:keyname"

KEYDATA= Identifies a column that represents the key. This is used to emulate an external key where the data is not duplicated in the data.
MAS90DATE Reformats the contents of a date column to and from the Sage MAS 90 / Sage MAS 200 date format.
NONULLS= If set to Y, the system will not pass NULL fields to the database but instead use strings with no characters. If set to P, then only key fields with be forced not null. If set to N, then empty fields will be passed as NULL to the database. (Default)
NONUMADJ= Set to Y (or 1) tells the system not to reserve additional space in internal buffers for the sign and decimal points of numeric data.
NOSTRIP Keeps trailing spaces (Default)
NULLPADKEY= Set to Y (or 1) to force keys to be padded to full length with the null character, $00$.
PORT=nnnn Identifies the port number on the server that will be used to connect to. If not specified, the MySql default port number will be used.
PREPARE= Set to Y (or "1") to use prepared statements. Prepared statements are pre-compiled SQL that may improve performance.
PSWD= or
PASSWORD=
Specifies the password for the user when connecting to the Database server.
* Warning * It is not advisable to place this in the INI file since anyone with access to it will be able to read this password.
REC= Provides the column names, type, and size. This is typically done to improve performance. If this information is not provided, then ProvideX must query the database for this information. For more information, see Database Variant Record Processing.
RECDATA= Identifies a column to return as the full record. This can be used for variant records, which use complex rules to identify the record type.
SERVER== or
HOST=
Identifies the IP address or name of the database server to connect to.
SHARED Sets all tables to share a single connection to the database server. Default.
STDDATE Overrides the Date formatting on individual columns.
STRIP Removes trailing spaces from fields
TIMESTAMP_CONVERT= If set to Y, the system will convert database columns with TIMESTAMP format to the standard system Date format as opposed to using the native ASCII date format used by MySql. Default is "N"
TYP= Sets identifier for different variant records. For more information, see Database Variant Record Processing.
UNIQUE Sets the open to be on a unique connection to the database server.
USER= Specifies login name.
WAITZERO= If set to Y (or 1), the system will internally issue a WAIT 0 when doing long SELECT directives. This will allow a Graphical display to update periodically. Default is "Y"

 

   
See Also READ Directive,
READ RECORD Directive,
SELECT Directive,
WRITE Directive,
WRITE RECORD Directive
OPEN Directive