SQLOPEN Verb - Open SQL Channel

Syntax

SQLOPEN(sqlchan{,MODE=str}{,ERR=lineref})data_source_name_string

Description

For BBj-specific information, see SQLOPEN Verb - BBj.

The SQLOPEN verb associates sqlchan with an SQL database. The channels associated with SQL operations are distinct from the regular I/O channels and do not work in FID(), FIN(), and other functions that are designed to report on standard I/O channels. Also, SQLOPEN does not accept an sqlchan value of 0. When a data source requires more than UID and PWD as data source keywords, the keywords can be passed in the data_source_name string. This mode must follow the DSN keyword. All other keywords are driver specific. Some examples include:

SQLOPEN(1)"datasource"
SQLOPEN(1,mode="UID=me,PWD=you")"datasource"
SQLOPEN(1,mode="SQLDriverConnect")"datasource"
SQLOPEN(1,mode="ExecDirect=1")"DSN=datasource;UID=me,PWD=you;OPTION=value"
SQLOPEN(1)"DSN=datasource"
SQLOPEN(chan, mode="DICTIONARY=/path/to/dict/")"MyDB"

The MODE= option allows certain parameters to be set. These include:

UID=string

This option supplies a user name to use with the current data source.

PWD=string

This option supplies a password to use with the user name set by the UID mode.

DICTIONARY=path

 

In V/PRO/5 5.01 and higher, and BBj 4.02 and higher, for a non-ODBC connection, this option overrides the dictionary path specified in the config.tpm file and in the database properties in BBj. The path must end with a trailing forward slash.

DATA=path

 

In V/PRO/5 5.01 and higher, and BBj 4.02 and higher, for a non-ODBC connection, this option overrides the data path specified in the config.tpm file. The path must end with a trailing forward slash.

 

Not all data sources require a UID or PWD.

DSN=datasource

This option supplies a data source name.

SQLDriverConnect

By default, Visual PRO/5 uses the ODBC SQLConnect function to connect to a data source. This mode specifies that SQLDriverConnect is to be used instead. Not all drivers support SQLDriverConnect, and it should not be used to connect to a driver directly. Always specify the data source name when using SQLDriverConnect.

ExecDirect=1

This mode may be required with certain ODBC drivers. A common symptom is a repeated text string in all fields. If this problem occurs, contact the ODBC driver's manufacturer for an update. This mode replaces the ODBC SQLExecute function with SQLExecDirect and slows performance of Visual PRO/5 in conjunction with this driver.

Examples

1010 LET LIST$=SQLLIST(0),LISTPOS=1,GOODLIST$=""
1020 WHILE LISTPOS<LEN(LIST$)
1030 LET P=POS($0A$=LIST$(LISTPOS),ENTRY$=ENTRY$(
1030:LISTPOS,P-1),LISTPOS=LISTPOS+P+1
1040 SQLOPEN(1,ERR=1050)ENTRY$; SQLCLOSE(1);
1040:GOODLIST$=GOODLIST$+ENTRY$+$0A$
1050 WEND
1000 SQLOPEN(1,MODE="UID=Frank,PWD=8JU7B")"Chile Company
1000:Data"

See Also

Verbs - Alphabetical Listing