Special Command Tags
[ODB] Open DataBase
   
Format OPEN (chan[,fileopt])"[ODB]filename[;fileopt]"

Where:

[ODB] File tag clause to inform ProvideX that it will be opening an external Windows ODBC database (not a ProvideX data file).
chan Channel or logical file number to open.
filename Path and/or name of the ODBC database file to open. String expression.
fileopt File options. Supported options include:
BSZ=num Block size
ERR=stmtref Error transfer
IOL=iolref Default IOList
NBF=num Dedicated number of buffers
OPT=String$ Open parameters (See [ODB] OPT= Parameters below)
REC=string$ Record prefix (REC=VIS(string$) can also be used).


*Note* The [ODB] tag is built into the ProvideX programming language. You do not need the ProvideX ODBC driver to use this tag, but you are limited to using the tag in Windows only. (ODBC is the Microsoft acronym for Open Database Connectivity.)


   
Description The [ODB] tag is used as a prefix in an OPEN statement to denote that ProvideX is to route all file I/O requests to an external (Windows, not ProvideX) ODBC database file. Once you open a channel for [ODB] use, you can use it just like any other channel (i.e., for file I/O). It remains open until you close it.


*Note* To open and read ProvideX (internal) data files using other database applications, (e.g., Excel), install and use the ProvideX ODBC driver instead of the [ODB] tag.


   
[ODB] OPT= Parameters

The OPEN parameters for connecting via ODBC are listed below:

"ACCESS=" Determines type of file access required (READ or WRITE). Default is
ACCESS=WRITE.
"AUTOCOMMIT=" Determines auto commit functionality of the database driver (either ON or OFF). It is applicable only if the driver supports transactions.
"CONCURRENCY=" Determines the type of con-current access control/locking to be used. READONLY sets the cursor is set to read only - no updates allowed. LOCK applies low-level record locking. OPT_VERSION causes optimistic locking with the database version control to be used. OPT_VALUE causes optimistic locking with comparing record/column values to be used.
"COMPLETE=" Determines the response to incomplete information by the following values:
  • 0 (SQL_DRIVER_NOPROMPT). Default. Driver Manager copies the connection string specified by the application.
  • 1 (SQL_DRIVER_COMPLETE) or
  • 3 (SQL_DRIVER_COMPLETE_REQUIRED). If the connection string specified by the application includes the DSN keyword, the Driver Manager copies the connection string specified by the application. Otherwise, it takes the same actions as SQL_DRIVER_PROMPT.
  • 2 (SQL_DRIVER_PROMPT). If connection string does not contain either DRIVER, DSN, or FILEDSN keyword, the Driver Manager displays the Data Sources dialog box. It constructs a connection string from the data source name returned by the dialog box and any other keywords passed to it by the application. If the data source name returned by the dialog box is empty, the Driver Manager specifies the keyword-value pair DSN=Default. (This dialog box will not display a data source with the name "Default".) All options except NOPROMPTrequire the handle of the parent window, which will be the handle of the currently active ProvideX window. This parameter is not used if a connection string is not supplied.
"CONNECT=" Specifies a connection string surrounded by a delimiter character, enabling use of a "dsn-less" connection. Connection strings are driver specific. Consult the driver's reference for supported connection string values.

If a connection string is supplied the value of the database name is ignored. If the database name is not null then the value is used only for determining if a connection should be shared. For example,

Open(1,iol=*,opt="connect='DSN=nomads'")"[odb]foo;Customer"
Open(2,iol=*,opt="")"[odb]foo;Customer Classes"
Open(3,iol=*,opt="",err=*next)"[odb];Customer"
Open(4,iol=*,opt="connect='DSN=foo')"[odb]foo;Customer"

The table opened on channel 2 will share the connection because of foo. Channel3will error-out because neither a valid database name nor a valid connect string was supplied. Channel4 will open the table Customer using the properties of the "nomads" DSN because foo matches (the connect string was ignored).

If the keywords USER= or PSWD= are supplied on the open then the values of these attributes will be appended to the connection string.

"CURSOR_TYPE=" Defines the type of cursor that is to be used. FORWARD indicates that any result sets can be read in a forward only direction. STATIC indicates that the result set is static. KEYSET forces the cursor to use/maintain record keys in a Keyset. DYNAMIC indicates that the cursor is effective in the current Rowset only.
"CURSOR_USE=" Defines the type of cursor to be used within the ODBC connection. DRIVER (default) assumes the specific driver’ own cursors. ODBC causes the ODBC interface to use the “river Managers” cursor library that may provide additional functionality not available within the database driver. IF_NEEDED tells the system to use the specific database driver's own cursor functionality unless the additional functionality is requested specifically.
"DATEFMT=" Date format mask applying 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.
"DB=" or Qualifies the specific database that you wish to use when using a
"QUALIFIER=" driver to service multiple databases.
"DEBUGIT=" 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 database. For example, "--" is the comment identifier for Microsoft SQL Server; anything after "--" is ignored by SQL Server when compiling the SQL statement.
"EXEC_SPRNO=" Name of stored procedure used to emulate RNO( ) function.
"EXTROPT=" Controls the format of the SELECT statement used to process an EXTRACT. By default, PVX generates:

SELECT * FROM table FOR UPDATE WHERE...

When EXTROPT=text, then text is substituted in place of FOR UPDATE. 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.
"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).

Settings include: UNCOMMITED (D, R, P possible), COMMITED (D possible, R & P not possible), REPEATABLE (P possible, D & R not possible), SERIAL (D, R, & P not possible), VERSIONING (D, R, & P not possible, but uses versioning as opposed to record locks).

"KEY=" Identifies fields that make up the key(s). For named keys enter *NAME:keyname; e.g.,

OPEN(chan)"[ODB]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.
"KEYSET_SIZE=" Size of the Keyset for use with the cursor.
"MAS90DATE" Reformats the contents of a date column to and from the Sage MAS 90 / Sage MAS 200 date format.
"MAS90DT" Format DATE Fields as Sage MAS 90 / Sage MAS 200 style dates.
"MAS90SET" Sets flags for Sage MAS 90 / Sage MAS 200 emulation, such as turning on the MAS90DATE conversion.
"MAXROWS=" Maximum number of rows/records returned.
"NOSTRIP" Keeps trailing spaces (Default)
"NULLPADKEY=" Set to 1, Y or y to force keys to be padded to full length with the null character, $00$.
"ORACLE=" Indicates if the database uses ORACLE SQL sequence (either Y or N). If ORACLE= and TOP= are used, then SELECT commands are generated as SELECT * FROM (SELECT * FROM TABLE) WHERE ROWNUM < 1. Default is ORACLE=N.
"POSUPDATE=" Determines use of SqlSetPos functions. Use one of the following: M (must use positioned update), O (default, optionally use positioned update), N (never use positioned update).
"PREPARE=" Set to 1, Y or y to use prepared statements. Prepared statements are pre-compiled SQL that may improve performance.
"PSWD=" Specifies password - not secure. Anyone with access to the INI 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 ODB/OCI 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.
"ROWSET_SIZE=" Size of the Rowset used by the cursor.
"SHARED" Sets all tables to share a single connection to the Oracle database. Default.
"STDDATE" Overrides the above formatting on individual columns.
"STRIP" Removes trailing spaces from fields
"TEXTMAX=" Overrides maximum size for text fields (default is 4096 bytes).
"TIMEOUT=" Defines the time out value for any SQL operation (time before error 0 returned).
"TOP=" Specifies use of the TOP clause in SELECT statements (limits the number of rows to return in a result set).

If TOP=n is non-zero , then the KEF( ) / KEL( ) functions issue a SELECT TOP 1... SQL statement, which improves system performance. If TOP=n > 0, then PVX issues SELECT TOP n to reduce the data transferred. TOP=-1 indicates the driver supports SELECT TOP, but normal reading should not use it. Default is 0 (TOPnot supported).

"TSQL=" Defines a SQL statement that is used to control what data the logical file returns.
"TYP=" Sets identifier for different variant records. For more information see ODB/OCI Variant Record Processing.
"UNIQUE=" Set to 1, Y or y to have new opens be on a unique connection to the database. Default is N (shared connection).
"USER=" Specifies login name.

 

   
DSN List A special option exists to return the list of known/configured Data Sources on the system.

If you specify an asterisk as the table name the ODBC interface will return records consisting of two fields, the first being the DSN name, the second being its description. Only READ and CLOSE statements may be processed against a connection opened using the Asterisk.

Example:

0010 SELECT DSNAME$,DESC$ FROM "[odb]*"
0020 PRINT DSNAME$,":",DESC$
0030 NEXT RECORD

-:RUN
MS Access Database:Microsoft Access Driver (*.mdb)
Excel Files:Microsoft Excel Driver (*.xls)
dBASE Files:Microsoft dBase Driver (*.dbf)
MQIS:SQL Server
PVXSRC:ProvideX ODBC Driver

This option is a +PxPlus Exclusive

   
Using ODBC on Unix To read Windows ODBC databases from a UNIX server, you would install and use WindX to make the connection or use ProvideX RPC on a PC or NT server and open your ODBC databases through that server:
 
OPEN (14)"[WDX][ODB]c:\your_path\ODBC_filename"
   
See Also READ Directive,
READ RECORD Directive,
SELECT Directive,
WRITE Directive,
WRITE RECORD Directive
OPEN Directive