EnglishРусский  
The project is closed! You can look at a new scripting language. It is available on GitHub.
Also, try our open source cross-platform automation software.

Ads

Installer and installation software
Commercial and Freeware installers.

ODBC description

A brief description of ODBC library. The object of the odbc type provides connection to a database. The objects of the odbcquery type are used to run SQL queries and move the cursor through a result set. This object has got the arr fields[] of odbcfield array that contains result set fields odbcfield; furthermore, the number of elements of the array equals the number of the fields.

The objects of the odbcfield type make it possible to get the required information of the field as well as the field's value (depending on the current position of the cursor in the result set).

The sequence of operations for working with the database:

  • create an ODBC connection to the database using the odbc.connect method;
  • create a new ODBC query using the odbc.newquery method. Note that severalqueries are likely to be created for one connection;
  • run a SQL query using the odbcquery.run method; the query may retrieve the result set (the SELECT command) or no data (the INSERT command, the UPDATE command etc.);
  • move the cursor through the result set using the following methods: odbcquery.first, odbcquery.next etc. if necessary. The access is gained to the fields through the fields array odbcquery.fields[i], where i - a field number begining from 0, or with the odbcquery.fieldbyname method;
  • use the odbcfield.getstr method, the odbcfield.getint method etc.in order to get field values;
  • run the next SQL query after processing if necessary;
  • disconnect from the database using the ODBC method odbc.disconnect.

There are some peculiarities to keep in mind when working with ODBC drivers:
while running a SQL query with the help of multiple sequential statements of the "INSERT ..." type, only some of the query statements are being executed (there can be from 300 to 1000 statements used for the "SQL server" driver) and no error message is displayed. In this case, you had better divide such queries into several parts;
some types of drivers do not make it possible to calculate the total number of messages received by the SQL query.

Related links

Source