Date: Thu, 28 Mar 2024 19:28:13 +0100 (CET) Message-ID: <1044184285.111216.1711650493947@srvdoc.doc.ipesoft.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_111215_833371180.1711650493947" ------=_Part_111215_833371180.1711650493947 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
SQL_CONNECT
SQL_CONNECT
dbObjIdent | in | Reference to an object of Database or Database table types. |
connectString | in | Identifier of Text type or a text constant containing= a connect string to the database. |
dbManIdent_Int | in | Reference to an object of Process type (DbMana= ger), that will be executed the required commands. |
handleIdent_Int | out | Identifier - the unique number (handle) of a connect= ion. |
retCodeIdent_Int | out | Return code identifier. |
transHandle_Int | in | Identifier for an unique number (handle) of the conn= ection to a database. |
An unique number (identifier, handle) is assigned to each opening of a d= atabase by a script. It is necessary to close this number using the action = SQL_DISCONNECT, when hav= ing finished the work with database. If all databases (opened by this scrip= t during its activity) are not to be closed by calling the action SQL_DISCO= NNECT after the script termination, they will be closed automatically. Hand= le is valid only within the frame of a script, that opened the database.
The action SQL_CONNECT always opens a database (not a table, unlike the = actions DB_CONNECT and PG_CONNECT), because it allows to work= with a whole database (all tables contained in it) via a connection create= d by this way. If an object of Database table is used to open a database, t= he database will be internally opened by means of its parent, so an object = of Database.
Opened database may be determined by an object of Database or Database table type (the fir=
st declaration type) or by so-called connect string (the second declaration=
type).
In the first type, it is not necessary to enter the name of a process of <=
a href=3D"/display/D2DOCV12EN/D2000+DBManager">DbManager type that will=
be interpret follow commands, because this is given by the parent relation=
between an object of Database type and the process. The command SQL_CONNEC=
T will use the configuration parameters User, Password and <=
b>DSN from the object configuration of particular object of Database ty=
pe.
The second declaration type allows to create the connection to an database=
on the basis of knowing the Name, Password and DSN u=
sing so-called connect string. It contains:
"UID=3Duser name;PWD=3Duser password;DSN=3DDSN name".
The key words UID, PWD and DSN represent values of individual parameters. =
If some of them is not entered, it will be substituted by a null string. Th=
is declaration type requires to specify, using a reference, a process of Db=
Manager type, that will be provide the execution of individual commands. Ne=
xt optional parameters of connection string are related to optimization and=
are described together with the process DbManager.
If a database is opened using an object of Database or Database Table ty= pe, it is able to enter transHandle_Int. Thereby all SQL_* commands = are to be executed within the frame of the specified Connection. The connection must= be created before using the action DB_TRANS_OPEN. If the clause TRANS is not stated, there w= ill be used the Automatic connection.
If a database is opened by a connect string, the process DbManager alway= s creates a new connection to the database. If the key word ACD (= Auto Commit Disable) is placed in the connect string, the= n the mode Auto Commit is disabled within the frame of this new connection,= an it is necessary to execute the command Commit manually.
INT _handle ; handle to database INT _retCode ; return code TEXT _name ; product name TEXT _type ; product type ; parameterized SQL command TEXT _sql =3D "SELECT Name, Type FROM Products WHERE ID>=3D #PAR# AND = ID<=3D #PAR#"=20 =20 SQL_CONNECT MyDatabase, _handle, _retCode SQL_PREPARE _handle, _retCode, _sql BINDOUT _name, _type SQL_BINDIN _handle, _retCode, 1, 100 ; read all products between 1 and 10= 0 =20 DO_LOOP SQL_FETCH _handle, _retCode EXIT_LOOP _retCode # _ERR_NO_ERROR ; data processing goes here END_LOOP =20 SQL_FREE _handle SQL_DISCONNECT _handle
Related pages: