Connecting From Application Software [ HP ALLBASE/SQL PC API User's Guide ] MPE/iX 5.0 Documentation
HP ALLBASE/SQL PC API User's Guide
Connecting From Application Software
Application software may have specific requirements for connection to PC
API. Those requirements are discussed here.
Connecting From SQLWindows
When you are connecting to an ALLBASE/SQL DBEnvironment from SQLWindows,
you make an Sqlconnect call, using the SqlUser and SqlDatabase reserved
variables. PC API uses the values associated with these variables to
build the connection string for an ALLBASE/SQL database.
The following example shows how to use an Sqlconnect call from an
SQLWindows application:
Set SqlUser = `user3'
Set SqlDatabase = `server2'
Set bhSqlPrimary = SqlConnect(hSqlPrimary)
If bhSqlPrimary = TRUE
:
For complete information about Sqlconnect, refer to the Gupta manual,
SQLBase SQLTalk Language Reference Manual.
The value in SqlDatabase is used as a search string in the SQL.INI file
and is matched to the database code parameter of the connection string
syntax. The value in SqlUser is matched to the user code parameter. PC
API then builds the actual connection string that is transmitted over the
network by replacing the database code with the node and DBEnvironment
name and replacing the user code with the logon string.
When you customize your system, you add the appropriate connection string
information to the SQL.INI file. Refer to the chapter "Maintaining PC
API" for information on the SQL.INI file.
Connecting from Express Windows and SQLTalk
To enable a list of database names to be produced from the mpedbname
entries in the SQL.INI file, an mpedbname entry in the SQL.INI file needs
the server1 label. This entry must point to a valid DBEnvironment name.
The mpeuser entry in the SQL.INI file needs the sysadm label. This entry
must specify a user that can connect to the DBEnvironment that maps to
server1.
Connecting From PowerBuilder
PowerBuilder uses the transaction object to facilitate database
connection. There are 13 attributes used to connect and return
information about the success or failure of database commands. The
attributes are different for every DBMS. For a complete description of
the transaction object and all of its attributes, refer to the Powersoft
manual, PowerBuilder ALLBASE/SQL Interface.
To define an ALLBASE/SQL database as the global default transaction
object, or sqlca, you need to define attributes as in the following
example:
//Set the default transaction object attributes
sqlca.dbms = "allbase"
sqlca.database = "mydbs"
sqlca.userid = "sysadm"
sqlca.dbpass = "apxft"
// Connect to the database;
connect;
Define one transaction object for each logon.
When a connect statement is issued from the PowerBuilder application, the
value assigned to sqlca.dbms is used to locate the router section in the
SQL.INI file.
The value assigned to sqlca.database is used as a search string in the
SQL.INI file and is matched to the database code parameter of the
connection string syntax. The value in sqlca.userid is matched to the
user code parameter; therefore, one logon is allowed per transaction
object. PC API then builds the actual connection string that is
transmitted over the network by replacing the database code with the
database server node and DBEnvironment name and replacing the user code
with the logon string.
Note that sqlca.dbpass is ignored by PC API.
When you customize your system, you add the appropriate connection string
information to the SQL.INI file. Refer to the chapter "Maintaining PC
API" for information on the SQL.INI file.
PowerBuilder allows you to connect to different DBMSs and different
databases within the same DBMS, as long as you create the transaction
object for each additional connection, and destroy it after you
disconnect.
When accessing ALLBASE/SQL databases from PowerBuilder, you connect to a
DBEnvironment, rather than a database. So you can use the same
transaction object to access more than one ALLBASE/SQL database, as long
as the databases reside in the same DBEnvironment.
If the transaction object has already been defined to access another
DBMS, you can create a new transaction object to be used to connect to an
ALLBASE/SQL DBEnvironment. You must also add corresponding codes and
replacement strings to the SQL.INI file. For example,
sqlalldb = create transaction
creates a new transaction object called sqlalldb.
You then assign attributes to sqlalldb as follows:
sqlalldb.dbms = "allbase"
sqlalldb.database = "humanres"
sqlalldb.userid = "bmoc"
sqlalldb.dbpass = "bmocpw"
You can then connect to the ALLBASE/SQL DBEnvironment that corresponds to
mpedbname humanres in the SQL.INI file:
connect using sqlalldb;
:
disconnect using sqlalldb;
:.
destroy sqlalldb;
After disconnecting, you need to destroy the transaction object. For
more information about connecting to multiple databases with
PowerBuilder, refer to the manual Using PowerBuilder.
MPE/iX 5.0 Documentation