2The ODBC layer
NEC websites around the world. Select a website. Drivers Installer for INFOCITY,Inc. ARIB/BEST Codec. If you don’t want to waste time on hunting after the needed driver for your PC, feel free to use a dedicated self-acting installer. It will select only qualified and updated drivers for all hardware parts all alone. To download SCI Drivers Installer, follow this link.
C-metric Solutions is a leading software outsourcing company in USA delivering innovative business solutions to clients globally. The major drivers, inhibitors, and threats to an EV ecosystem. The expected value levers and incentives facilitation ecosystem orchestration. The technology, people, and process investments that are needed to make an electric vehicle ecosystem successful. Results and Deliverable Our team shared daily updates including respondent descriptive.
2.1Global configuration
- odbc_set_option(+Property)
- Set global properties for the environment. This must be called before calling any other ODBC predicates. Permitted properties currently include
- connection_pooling(+bool)
- If true, then enable connection pooling for the entire process. Note that due to limitations of ODBC itself, it is not possible to turn pooling off once enabled.
2.2Connection management
The ODBC interface deals with a single ODBC environment with multiple simultaneous connections. The predicates in this section deal with connection management.
- odbc_connect(+DSN, -Connection, +Options)
- Create a new ODBC connection to (Connections with matching connection string keywords can be used. Keywords must match, but not all connection attributes must match.)
- odbc_version(+Atom)
- Select the version of the ODBC connection. Default is
'3.0'
. The other supported value is'2.0'
.
The following example connects to the WordNet1An SQL version of WordNet is available from http://wordnet2sql.infocity.cjb.net/[1] database, using the connection alias wordnet
and opening the connection only once:
user
andpassword
.Whenever possible, applications should use odbc_connect/3. If you need this predicate, please check the documentation for SQLDriverConnect() and the documentation of your driver.bugFacilities to deal with prompted completion of the driver options are not yet implemented.
read
, tell the driver we only access the database in read mode. If update
(default), tell the driver we may execute update commands.true
(default), each update statement is committed immediately. If false
, an update statement starts a transaction that can be committed or rolled-back. See section 2.4 for details on transaction management.dynamic
makes it possible to have multiple active statements on the same connection with Microsoft SQL server. Other values are static
, forwards_only
and keyset_driven
.unicode
while on other platforms it is utf8
. Below, the *A() functions refer to the‘ansi' ODBC functions that exchange bytes and the *W() functions refer to the‘unicode' ODBC functions that exchange UCS-2 characters.- iso_latin_1
- Communicate using the *A() functions and pass bytes untranslated.
- locale
- Communicate using the *A() functions and translated between Prolog Unicode characters and their (possibly) multibyte representation in the current locale.
- utf8
- Communicate using the *A() functions and translated between Prolog Unicode characters and their UTF-8 encoding.
- unicode
- Communicate using the *W() functions.
true
(default false
), statements returningSQL_SUCCESS_WITH_INFO
succeed without printing the info. See also section 2.8.1.$null$
. NullSpecifier is an arbitrary Prolog term, though the implementation is optimised for using an unbound variable, atom and functor with one unbound variable. The representation null(_)
is a commonly used alternative.The specified default holds for all statements executed on this connection. Changing the connection default does not affect already prepared or running statements. The null-value can also be specified at the statement level. See the option list of odbc_query/4.
Name(Value)
. If Property is unbound all defined properties are enumerated on backtracking. Currently the following properties are defined.- database_name(Atom)
- Name of the database associated to the connection.
- dbms_name(Name)
- Name of the database engine. This constant can be used to identify the engine.
- dbms_version(Atom)
- Version identifier from the database engine.
- driver_name(Name)
- ODBC Dynamic Link Library providing the interface between ODBC and the database.
- driver_odbc_version(Atom)
- ODBC version supported by the driver.
- driver_version(Atom)
- The drivers version identifier.
- active_statements(Integer)
- Maximum number of statements that can be active at the same time on this connection. Returns 0 (zero) if this is unlimited.2Microsoft SQL server can have multiple active statements after setting the option
cursor_type
todynamic
. See odbc_set_connection/2.
2.3Running SQL queries
ODBC distinguishes between direct execution of literal SQL strings and parameterized execution of SQL strings. The first is a simple practical solution for infrequent calls (such as creating a table), while parameterized execution allows the driver and database to precompile the query and store the optimized code, making it suitable for time-critical operations. In addition, it allows for passing parameters without going through SQL-syntax and thus avoiding the need for quoting.
2.3.1One-time invocation
[]
for Options.If the statement is a SELECT
statement the result-set is returned in RowOrAffected. By default rows are returned one-by-one on backtracking as terms of the functor row/Arity
, where Arity denotes the number of columns in the result-set. The library pre-fetches the next value to be able to close the statement and return deterministic success when returning the last row of the result-set. Using the option findall/2
(see below) the result-set is returned as a list of user-specified terms. For other statements this argument returns affected(Rows)
, where Rows represents the number of rows affected by the statement. If you are not interested in the number of affected rows odbc_query/2 provides a simple interface for sending SQL-statements.
Below is a small example using the connection created fromodbc_connect/3. Please note that the SQL-statement does not end in the‘;
’character.
The following example adds a name to a table with parent-relations, returning the number of rows affected by the statement. Note that the SQL quote character is the ASCII single quote and, as this SQL quote is embedded in a single quoted Prolog atom, it must be written as '
or '
(two single quotes). We use the first alternative for better visibility.
Options defines the following options.
default
to use default conversion for that column. The length of the type-list must match the number of columns in the result-set.For example, in the table word
the first column is defined with the SQL type DECIMAL(6)
. Using this SQL-type, “001' is distinct from “1', but using Prolog integers is a valid representation for Wordnet wordno
identifiers. The following query extracts rows using Prolog integers:
See also section 2.7 for notes on type-conversion.
true
(default false
), include the source-column with each result-value. With this option, each result in therow/N
-term is of the format below. TableName orColumnName may be the empty atom if the information is not available.3This is one possible interface to this information. In many cases it is more efficient and convenient to provide this information separately as it is the same for each result-row.column(TableName, ColumnName, Value)
Using the findall/2
option the above can be implemented as below. The number of argument of the row
term must match the number of columns in the result-set.
The current implementation is incomplete. It does not allow arguments ofrow(...)
to be instantiated. Plain instantiation can always be avoided using a proper SELECT statement. Potentially useful however would be the translation of compound terms, especially to translate date/time/timestamp structures to a format for use by the application.
SELECT
). The predicate prints a diagnostic message if the query returns a result.2.3.2Parameterised queries
ODBC provides for‘parameterized queries'. These are SQL queries with a ?
-sign at places where parameters appear. The ODBC interface and database driver may use this to precompile the SQL-statement, giving better performance on repeated queries. This is exactly what we want if we associate Prolog predicates to database tables. This interface is defined by the following predicates:
[]
for Options.?
) and unify Statement with a handle to the created statement. Parameters is a list of descriptions, one for each parameter. Each parameter description is one of the following:silent(true)
option of odbc_set_connection/2. An alternative mapping can be selected using the > option of this predicate described below.char
, varchar
, etc. to specify the field-width. When calling odbc_execute/[2-3], the user must supply the parameter values in the default Prolog type for this SQL type. See section 2.7 for details.The use must supply an atom of the format YYYY-MM-DD
rather than a term date(Year,Month,Day)
. This construct enhances flexibility and allows for passing values that have no proper representation in Prolog.
Options defines a list of options for executing the statement. Seeodbc_query/4 for details. In addition, the following option is provided:
- fetch(FetchType)
- Determine the FetchType, which is one of
auto
(default) to extract the result-set on backtracking orfetch
to prepare the result-set to be fetched using odbc_fetch/3.
ODBC doesn't appear to allow for multiple cursors on the same result-set.4Is this right? This would imply there can only be one active odbc_execute/3 (i.e. with a choice-point) on a prepared statement. Suppose we have a table age (name char(25), age integer)
bound to the predicate age/2 we cannot write the code below without special precautions. The ODBC interface therefore creates a clone of a statement if it discovers the statement is being executed, which is discarded after the statement is finished.5The code is prepared to maintain a cache of statements. Practice should tell us whether it is worthwhile activating this.
2.3.3Fetching rows explicitely
Normally SQL queries return a result-set that is enumerated on backtracking. Using this approach a result-set is similar to a predicate holding facts. There are some cases where fetching the rows one-by-one, much like read/1 reads terms from a file is more appropriate and there are cases where only part of the result-set is to be fetched. These cases can be dealt with using odbc_fetch/3, which provides an interface to SQLFetchScroll().
As a general rule of thumb, stay away from these functions if you do not really need them. Experiment before deciding on the strategy and often you'll discover the simply backtracking approach is much easier to deal with and about as fast.
fetch(fetch)
and be executed using odbc_execute/2. Row is unified to the fetched row or the atom end_of_file
6This atom was selected to emphasise the similarity to read. after the end of the data is reached. Calling odbc_fetch/2 after all data is retrieved causes a permission-error exception. Option is one of:- next
- Fetch the next row.
- prior
- Fetch the result-set going backwards.
- first
- Fetch the first row.
- last
- Fetch the last row.
- absolute(Offset)
- Fetch absolute numbered row. Rows count from one.
- relative(Offset)
- Fetch relative to the current row.
relative(1)
is the same asnext
, except that the first row extracted is row 2. - bookmark(Offset)
- Reserved. Bookmarks are not yet supported in this interface.
In many cases, depending on the driver and RDBMS, the cursor-type must be changed using odbc_set_connection/2 for anything different from next
to work.
Here is example code each time skipping a row from a table‘test' holding a single column of integers that represent the row-number. This test was executed using unixODBC and MySQL on SuSE Linux.
2.3.4Fetching data from multiple result sets
Most SQL queries return only a single result set - a list of rows. However, some queries can return more than one result set. For example,’SELECT 1; SELECT 2' is a batch query that returns a single row (1) and then a single row(2). Queries involving stored procedures can easily generate such results.
To retrieve data from a subsequent result set, odbc_next_result_set/1 can be used, but only for prepared queries which were prepared with fetch(fetch) as the fetch style in the option list.
- odbc_next_result_set(+Statement)
- Succeeds if there is another result set, and positions the cursor at the first row of the new result set. If there are no more result sets, the predicate fails.
2.4Transaction management
ODBC can run in two modi. By default, all update actions are immediately committed on the server. Using odbc_set_connection/2 this behaviour can be switched off, after which each SQL statement that can be inside a transaction implicitly starts a new transaction. This transaction can be ended using odbc_end_transaction/2.
- odbc_end_transaction(+Connection, +Action)
- End the currently open transaction if there is one. Using Action
commit
pending updates are made permanent, usingrollback
they are discarded.
The ODBC documentation has many comments on transaction management and its interaction with database cursors.
2.5Accessing the database dictionary
With this interface we do not envision the use of Prolog as a database manager. Nevertheless, elementary access to the structure of a database is required, for example to validate a database satisfies the assumptions made by the application.
- qualifier(Qualifier)
- owner(Owner)
- comment(Comment)
- These facets are defined by SQLTables()
- arity(Arity)
- This facet returns the number of columns in a table.
- table_qualifier(Qualifier)
- table_owner(Owner)
- table_name(Table)
- See odbc_current_table/3.
- data_type(DataType)
- type_name(TypeName)
- precision(Precision)
- length(Length)
- scale(Scale)
- radix(Radix)
- nullable(Nullable)
- remarks(Remarks)
- These facets are defined by SQLColumns()
- type(Type)
- More prolog-friendly representation of the type properties. Seesection 2.7.
all_types
to enumerate all known types. This predicate calls SQLGetTypeInfo() and its facet names are derived from the specification of this ODBC function:If an ODBC operation returns‘with info', the info is extracted from the interface and handled to the Prolog message dispatcher print_message/2. The level of the message is informational
and the term is of the form:
- odbc(State, Native, Message)
- Here, State is the SQL-state as defined in the ODBC API,Native is the (integer) error code of the underlying data source and Message is a human readable explanation of the message.
2.8.2ODBC errors
If an ODBC operation signals an error, it throws the exceptionerror(
. The arguments of the odbc(State, Native, Message)
, _)odbc/3
term are explained in section 2.8.1.
In addition, the Prolog layer performs the normal tests for proper arguments and state, signaling the conventional instantiation, type, domain and resource exceptions.
2.9ODBC implementations
There is a wealth on ODBC implementations that are completely or almost compatible to this interface. In addition, a number of databases are delivered with an ODBC compatible interface. This implies you get the portability benefits of ODBC without paying the configuration and performance price. Currently this interface is, according to thePHP documentation on this subject, provided by Adabas D, IBM DB2, Solid, and Sybase SQL Anywhere.
2.9.1Using unixODBC
The SWI-Prolog ODBC interface was developed usingunixODBC and MySQL onSuSE Linux.
2.9.2Using Microsoft ODBC
Download Infocity Driver Jobs
On MS-Windows, the ODBC interface is a standard package, linked againstodbc32.lib
.
2.10Remaining issues
The following issues are identified and waiting for concrete problems and suggestions.
- Transaction management
- This certainly requires a high-level interface. Possibly in combination with call_cleanup/3, providing automatic rollback on failure or exception and commit on success.
- High-level interface
- Attaching tables to predicates, partial DataLog implementation, etc.
VECTOR India is a premium Embedded & VLSI training Institute that offers a number of job oriented and industry-specific educational programs. Two differentiators readily make us distinct – the conduct of an All India Entrance Examination on a quarterly basis for admission into our various Embedded & VLSI courses, and equipping our students with the right skills set to make them ready for jobs with the electronics industry.
The notable achievements of VECTOR’ students was made possible not only by their dedication to academic schedule and hard work, but also owes itself to the stupendous efforts made by our faculty, front-end and back-end staff in training the students, and in providing them with the technical acumen.
VECTOR India is an equal opportunity company, that provides good working environment and excellent opportunities for growth and development. To meet our current expansion plans we aim to recruit the following personnel on a priority basis. Candidates with matching qualifications and skills set need only apply.
Interested candidates can send your resumes to our mail id as soon as possible.
E-mail ID: careers@vectorindia.org
E-mail ID: careers@vectorindia.org
Download Infocity Driver Download
Download Infocity Driver Windows 10
Lab Coordinator
Counselor
Interested candidates can send your resumes to our mail id as soon as possible.
E-mail ID: careers@vectorindia.org
Comments are closed.