[ADO] |
Microsoft SQL Server Interface |
1. |
OPEN (chan[,fileopt1])"[ADO]serveraddress[;table][;fileopt2]" |
2. |
OPEN LOAD (chan[,fileopt1])"[ADO]serveraddress[;table][;fileopt2]" |
Where:
[ADO] |
File tag clause to inform PxPlus that it will be accessing an external ADO database (not a PxPlus data file). | |||||||||||||
chan |
Channel or logical file number to open. | |||||||||||||
serveraddress |
Server address where the database is located. | |||||||||||||
LOAD |
Keyword to locally cache a data read from an ADO database table. | |||||||||||||
fileopt1 |
File options. Supported options include:
| |||||||||||||
fileopt2 |
OPT=string$ |
Open parameters (see [ADO] OPT= Parameters). | ||||||||||||
table |
Name of the table to open. If the table name is not supplied, either SQL statements sent to the database must be created by the application (see Using SQL Directly Within PxPlus) or table and/or column information must be retrieved (see Retrieving DB2/ODB Table and Column Information). |
The [ADO] tag is used as a prefix in an OPEN statement to denote that PxPlus is to route all file I/O requests to a Microsoft SQL Server via an ActiveX Data Objects (ADO) interface. Once a channel is open for [ADO] use, it can be used the same as any other channel (i.e. for file I/O). It remains open until you close it.
When you are creating an SQL database table through [ADO], you will need to consider the level of permission for users requiring access to the table or other related objects. To ensure that users will have access to all necessary tables of the database, you can issue a GRANT command either in or to the SQL environment similar to the following:
GRANT VIEW SERVER STATE TO username
Where:
username is the username of the user in the SQL database.
For a specific object (i.e. a table):
GRANT [privilege_name] ON [object] TO [username]
or
GRANT [privilege_name] ON [object_name] TO {user_name | PUBLIC | role_name} [WITH GRANT OPTION]
The OPEN parameters for connecting via ADO are:
"ACCESS=" |
Determines type of file access required (READ or WRITE). Default is ACCESS=WRITE. (INI Supported) | ||||||||
"AUTOCOMMIT=" |
Determines auto commit functionality of the database driver (either ON or OFF). (INI Supported) It is applicable only if the driver supports transactions. | ||||||||
"CACHEMETADATA=" |
Option to control the local caching of column metadata controlled by setting CACHEMETADATA to a value of 1. Provided there is at least one table open in the session and this option is enabled, the retrieved column metadata will be cached. Default is 0 (zero). (INI Supported) | ||||||||
"CACHEMODE=" |
Local option that specifies the cache mode to use for the table. If 0 (zero), then the key caching is determined by the KEYCACHETIME option. | ||||||||
"CACHESIZE=" |
Specifies the number of megabytes (MB) used for OPEN LOAD caching of records read from a table. This option is per table and defaults to 1. (INI Supported) | ||||||||
"CONCURRENCY=" |
Determines the type of concurrent access control/locking to be used. (INI Supported)
| ||||||||
"CONNECT=" |
Specifies a connection string surrounded by a delimiter character. open (1,iol=*,opt="CONNECT='Provider=SQLOLEDB'")"[ADO]DataSrc;Customer" If the keywords USER= or PSWD= are supplied on the OPEN, then the values of these attributes will be appended to the connection string. The following examples are functionally equivalent: open (1,iol=*,opt="CONNECT='Provider=SQLOLEDB;Uid=foo; Pwd=bar;Initial Catalog=TheDB;Data Source=TheServer'")"[ADO];TheTable;" open (1,iol=*,opt="CONNECT='Provider=SQLOLEDB';User=foo; Pswd=bar;DB=TheDB")"[ADO]TheServer;TheTable;" To control the value of the application name passed to ADO and change it on-the-fly, use the Application Name parameter: CONNECT='Provider=SQLOLEDB;Application Name=TESTAPP' | ||||||||
"CURSOR_TYPE=" |
Defines the type of cursor that is to be used. (INI Supported)
| ||||||||
Date format mask applying to all date fields in table. (INI Supported) This can be a combination of Y M D with any other characters. DATEFMT=YYYYMMDD | |||||||||
"DB=" or "QUALIFIER=" |
Qualifies the specific database that you wish to use when using a driver to service multiple databases. (INI Supported) | ||||||||
"DEBUGIT=" |
String to append to SQL statement, along with program name and line number for debugging purposes. (INI Supported) This must indicate the comment character(s) appropriate to the database. | ||||||||
"EXEC_SPRNO=" |
Name of stored procedure used to emulate the RNO( ) function. You must create a stored procedure for each table and key for which an RNO is needed. Format is spRNOtablename_keynumber. | ||||||||
"EXTROPT=" |
Controls the format of the SELECT statement used to process an EXTRACT. (INI Supported) | ||||||||
Causes all date fields to be translated to/from the SQL date format to the format used by the FACTS application. | |||||||||
"FAST=" |
Specifies that for SQL server, the OPTION (FAST N) will be applied to open ended SELECT statements. This can boost performance when the ORDER BY of a select is not covered by a clustered index. Format is FAST=N, where 0 (default) indicates not to apply the option, and N > 0 indicates the number of FAST rows. | ||||||||
"IDENTDELIM=C [C]" |
Specifies the character(s) used to encapsulate table and column name identifiers when generating an SQL statement. | ||||||||
"IND=" |
Identifies a column that contains a sequential number starting at 0. This is used to emulate an indexed file. | ||||||||
"IGNORE_NODATA=" |
Set to 1 (Y or y) to ignore SQL_NO_DATA error. | ||||||||
"INVALIDDATE=[0,1,2]" |
This option determines how invalid date strings will be handled. | ||||||||
"ISOLATION=" |
Controls the isolation that this connection will have relative to other processes on the same database. In particular, it controls Dirty reads (reading data that may be rolled back), Non-Repeatable reads (reading data after being changed by other transactions), and Phantom reads (reading data newly added to file). (INI Supported) | ||||||||
"KEY=" |
Identifies fields that make up the key(s). For named keys, enter *NAME:keyname. | ||||||||
"KEYCACHETIME=" |
For non-cached tables (those with CACHEMODE=0), this specifies the amount of time in milliseconds that the last read key can be considered valid. If greater than zero, then subsequent requests for the same key within the specified duration will be read from cache rather than the database. | ||||||||
"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. | ||||||||
"KEYSET_SIZE=" |
Size of the Keyset for use with the cursor. (INI Supported) | ||||||||
"LOCKED=" |
This option is similar in format to the KEY= and REC= and specifies which columns are considered non-updateable within the table. These columns will be read in from the database but will be excluded when generating INSERT or UPDATE statements. | ||||||||
Reformats the contents of a date column to and from the Sage MAS 90 date format. | |||||||||
"MAS90SET" |
Sets flags for Sage MAS 90 emulation, such as turning on the MAS90DATE conversion. | ||||||||
"MAXROWS=" |
Maximum number of rows/records returned. (INI Supported) | ||||||||
"NONUMADJ=" |
Set to 1, Y or y to suppress +3 adjustment for defined length of numerics. (INI Supported) | ||||||||
"NONULLS=" |
Inserts zero-length strings rather than nulls into the target database and does not generate WHERE clauses checking for IS NULL or IS NOT NULL. (INI Supported) Set to 1, Y or y to enable or 0, N or n to disable. If the application does not work correctly when moving from Version 5 or lower, then set NONULLS=P to indicate that keys are handled the same as pre-Version 6. | ||||||||
"NOSTRIP" |
Keeps trailing spaces. (Default) | ||||||||
"NULLPADKEY" |
Forces keys to be padded to full length with the null character, $00$. (INI Supported) When used in INI file, set NULLPADKEY=1, Y or y. | ||||||||
"POSUPDATE=" |
Determines use of SqlSetPos functions. (INI Supported) Use one of the following:
| ||||||||
"PREPARE=" |
Set to 1, Y or y to use prepared statements. (INI Supported) Prepared statements are pre-compiled SQL that may improve performance. (Default is Y.) | ||||||||
"PREPARELIMIT=" |
Defaults to 10 and is used to determine when to use prepared statements. The system keeps track of the statements that utilize the = (equal) operator on all parts of the WHERE clause to reduce the overhead of creating prepared statements that are never used. (INI Supported) | ||||||||
"PSWD=" |
Specifies password. (INI Supported, but NOT SECURE. Anyone with access to the INI will be able to read this password.) | ||||||||
"READNEXTLIMIT=" |
Adds a limit to the size of the record set generated by a SELECT to try to reduce the number of rows in a record set. If the value is less than or equal to 0, then an optimized scaling algorithm will be used. (INI Supported) This is a dynamic variation on TOP=. | ||||||||
"REC=" |
Provides the column names, type and size. This is typically done to improve performance. If this information is not provided, then PxPlus must query the database for this information. | ||||||||
"RECDATA=" |
Identifies a column to return as the full record. This can be used for variant records that use complex rules to identify the record type. | ||||||||
"SCHEMA=" |
Sets the Schema name to be prefixed to the table name (separated with a dot). | ||||||||
"SHARED" |
Sets all tables to share a single connection to the ADO database. (Default) | ||||||||
"STDDATE" |
Overrides the above formatting on individual columns. | ||||||||
"STRCOMPARE={ASCII|SQL}" |
Determines the type of string comparison to use. (Default is ASCII.) | ||||||||
"STRIP" |
Removes trailing spaces from fields. | ||||||||
"TEXTMAX=" |
Overrides maximum size for text fields. (Default is 8192 bytes.) (INI Supported) | ||||||||
"TIMEOUT=" |
Defines the time out value for SQL read operations (time before error 0 returned). (INI Supported). WRITE, UPDATE, INSERT and REMOVE directives are controlled by the TIM= option (or default TIM/RTY if not specified). | ||||||||
"TOP=" |
Specifies use of the TOP clause in SELECT statements (limits the number of rows to return in a result set). (INI Supported) If TOP=n is non-zero, then the KEF( ) / KEL( ) functions issue a SELECT TOP1…SQL statement, which improves system performance. If TOP=n > 0, then PxPlus issues SELECT TOP n to reduce the data transferred. TOP=-1 indicates the driver supports SELECT TOP, but normal reading should not use it. TOP=-2 is similar to TOP=-1 except the ADO driver implements the limiting of data and can be used in cases where the database does not support the TOP option. | ||||||||
"TRACE=" |
Provides additional debug/tracing information from the ADO driver. Valid options are 1 to enable or 0 (zero) to disable. (Default is 0.) | ||||||||
"TSQL=" |
Defines a SQL statement that is used to control what data the logical file returns. | ||||||||
"TYP=" |
Sets identifier for different variant records. See ODB/OCI Variant Record Processing. | ||||||||
"UNIQUE" |
Sets new opens to be on a unique connection to the database. (INI Supported) When used in an INI file, set UNIQUE=1, Y or y. UNIQUE=0, N or n indicates a shared connection. Note: | ||||||||
"USER=" |
Specifies login name. (INI Supported) | ||||||||
"USESQLLOCKS=" |
Determines if SQL application locks will be used (when accessing MSSQL). If disabled, then prefix style file locking will be used for LOCK, OPEN LOCK and UNLOCK directives. (INI Supported) | ||||||||
Set to 1, Y or y to validate the data. This option can be included in the respective INI section by database type. Date validation for database connections will only be included if the database OPEN specifies a date format using the DATEFMT=, MAS90DATE or FACTSDT option. For additional data validation information, see IOLIST directive. (The VALIDATE option was added in PxPlus 2017.) |
To read Windows ADO databases from a UNIX server, you would install and use WindX to make the connection or use PxPlus RPC on a Windows Server and open your ADO databases through that server:
open (14)"[WDX][ADO]serveraddress"
Use of Global String Variables as Option Values
In database connection options, you can provide the value following the = (equals sign) in global string variables. When opening the connection to the database, the system will check to see if the value following the = (equals sign) starts with a % and ends with a $ and is the name of a valid global string variable. If so, the value is replaced with the contents of that global variable.
For example, the option USER=%UserName$ would be dynamically changed by the EXE on the OPEN to replace the text %UserName$ with whatever is in that global variable.
(Support to allow the use of global variables for defining database Link/Prefix files was added in PxPlus 2023 Update 1.)
READ Read Data from File
READ RECORD Read Record from File
SELECT Select/Query From ... Where
WRITE Add/Update Data in File
WRITE RECORD Write Record
OPEN Open a File for Processing
IOLIST Specify Variable List
[DB2] DB2 Support
[MYSQL] Open MySql Native Database Link
[OCI] Connect to Oracle Server
[ODB] Open Database
Database Export Utility