Previous: , Up: ODBC Examples   [Contents][Index]


10.31.2.4 Example 4

This example is similar to the second, but this time we ask the database what the datatypes of the columns of the table are with odbc_list_data_types/3.

:- use_module(library(odbc)).

example3 :-
   odbc_env_open(EnvHandle),
   odbc_db_open('MyDatabase', EnvHandle, ConnectionHandle),
   odbc_query_open(ConnectionHandle, StatementHandle),
   odbc_list_data_types(StatementHandle,
                        scratch(vehicle, wheels),
                        DataTypes),
   odbc_query_execute_sql(StatementHandle,
                       'INSERT INTO scratch (vehicle, wheels) VALUES (?, ?)',
                       ["railwaycar", 8],
                       DataTypes,
                       ResultSet),
   odbc_query_close(ResultSet),
   odbc_db_close(ConnectionHandle),
   odbc_env_close(EnvHandle).


Send feedback on this subject.