1 はじめに
以下の説明では、 用語は、言語キーワード、ユーザー指定の値、リテラルなどの任意の単語または単語のグループを指します。用語の正確な意味は、それが使用される文脈によって異なります。
• イタリック体のフォント は新しい用語を導入しています。通常、初めて定義した文で。
• Fixed-width (mono-spaced) font は、 SQL コマンド、例で使用されている特定のテーブル名および列名、プログラミング言語のキーワード など、文字通りに指定する必要がある用語に使用され ます 。例えば、 SELECT * FROM emp;
•
•
•
•
2 要件の概要
•
•
3.1 EDB-ODBCのインストールの EDB-ODBCコネクタは、EDB Postgres Advanced ServerのグラフィカルインストーラまたはRPMインストーラと一緒に配布され、インストールされます。3.1.1 RPMパッケージを使用したコネクタのインストールリポジトリ設定ファイルをダウンロードした後、スーパーユーザー特権を引き受け 、次のコマンドを使用してリポジトリ設定ファイルを作成します。インストーラによって、 edb という名前のリポジトリ設定ファイルが作成されます 。 repo ;ファイルは/etc/yum.repos.dます。このファイルには、各EnterpriseDBリポジトリのエントリが含まれています。コネクタをインストールするには、 enterprisedb - toolsリポジトリのエントリを有効にする必要があります。
2。
3.1.2 SLES 12ホストへのコネクタのインストール入力を求められたら User NameとPassword 、EnterpriseDBのリポジトリ用の接続の資格情報を提供しています。認証情報が必要な場合は、EnterpriseDBに連絡してください。
DebianまたはUbuntuホストにDEBパッケージをインストールするには、EnterpriseDBリポジトリへのアクセスを許可する認証情報が必要です。リポジトリの認証情報を要求するには、以下のEnterpriseDB Advanced Downloadsページにアクセスしてください。次の手順では、EnterpriseDB aptリポジトリを使用してDEBパッケージをインストールする方法について説明します。コマンドを使用するときは、 usernameとpasswordをEnterpriseDBが提供する資格情報に置き換えてください。
Nextをクリックして続けます。StackBuilder Plusを使用して、既存のAdvanced Serverインストールでコネクタを追加または更新することもできます。 StackBuilder Plusを開くには、Windows AppsメニューまたはLinuxのStartメニューからStackBuilder Plusを選択します(図2.5を参照)。StackBuilder Plusが開いたら、画面上の指示に従います。ツリーコントロールの[ Database Driversノードから[ EnterpriseDB ODBC Connector ]オプションを選択します(図2.6を参照)。
3.2 データソースの作成データソースの最初の行はデータソース名です。名前は、大括弧で囲まれた固有のIDです。データソース名の後には 、データソースを構成する個々の接続プロパティを識別する一連の 'keyword=value 」ペアが続きます。ODBC管理ユーティリティは、ODBC接続用の名前付きデータソースを作成します。ほとんどの場合、ODBC管理ユーティリティはオペレーティングシステムと一緒に配布されています(WindowsまたはunixODBCを使用している場合、このツールは ODBC Data Source Administrator と呼ばれ ODBC Data Source Administrator )。オペレーティングシステムにODBC管理者が含まれていない場合は、サードパーティのオプションをオンラインで利用できます。セクション2.3.1と2.3.2では、各オペレーティングシステムで利用可能なグラフィカルツールを使用して、WindowsとLinuxにデータソースを追加する方法を説明します。データソースを定義する過程で、一連の接続プロパティを指定するように求められます。セクション2.3には、 オプションのデータソース接続プロパティに関する情報が含まれています。グラフィカルツールを使用して接続プロパティを指定するか、テキストエディタを使用してodbc.iniファイルを編集できます。
3.3 EDB-ODBC接続プロパティ次の表は、グラフィカル接続マネージャツールのダイアログ、または名前付きデータソースを定義するodbc.iniファイルで指定できる接続プロパティについて説明しています 。列は、接続プロパティ(ODBC Administratorダイアログに表示されるodbc.ini )、対応するキーワード( odbc.iniファイルに表示されるodbc.ini )、プロパティのデフォルト値、および接続プロパティの説明を識別します。
0 - Don't rollback1 - Rollback the transaction2 - Rollback the statement If enabled, the SQLStatistics() function reports that a unique index exists on each OID column. function reports that a unique index exists on each column. If enabled, the SQLStatistics() function will report unique indexes. If not enabled, the SQLStatistics() function reports that indexes allow duplicate values. If enabled, the driver will use server-side cursors. To enable UseDeclareFetch If enabled, the driver will use server-side cursors. To enable , specify a value of 1 , specify a value of ; to disable UseDeclareFetch ; to disable , specify a value of 0 , specify a value of . If enabled, the driver parses simple statements when you call the SQLNumResultCols() , SQLDescribeCol() or SQLColAttributes() functions. statements when you call the If enabled, the driver parses simple SELECT statements when you call the If enabled, the driver parses simple functions. If enabled, the SQLCancel() function will call on your behalf. SQLFreeStmt(SQL_Close) on your behalf. SQLFreeStmt(SQL_Close) on your behalf. If enabled, the driver records its work in a log file. On Windows, the file name is C:\mylog_<process-id> ; on Linux the file name is /tmp/mylog_<username><process-id>.log . SQLDescribeCol() and SQLColAttributes() functions compute the size of a column. Specify Determines how the functions compute the size of a column. Specify 0 to force the driver to report the maximum size allowed for the type; specify functions compute the size of a column. Specify to force the driver to report the maximum size allowed for the type; specify to force the driver to report an unknown length or to force the driver to report the maximum size allowed for the type; specify 1 to force the driver to report an unknown length or to force the driver to report the maximum size allowed for the type; specify to force the driver to search the result set to find the longest value. Do not specify 2 to force the driver to search the result set to find the longest value. Do not specify to force the driver to report the maximum size allowed for the type; specify to force the driver to search the result set to find the longest value. Do not specify UseDeclareFetch if you have enabled to force the driver to search the result set to find the longest value. Do not specify 2 to force the driver to search the result set to find the longest value. Do not specify . If enabled, the driver treats TEXT columns as if they are of type SQL_LONGVARCHAR columns as if they are of type If enabled, the driver treats columns as if they are of type . If disabled, the driver treats TEXT columns as SQL_VARCHAR values. columns as SQL_VARCHAR values. If enabled, the driver treats values of unknown type as SQL_LONGVARCHAR values. If unchecked, the driver will treat values of unknown type as If enabled, the driver treats values of unknown type as values. If unchecked, the driver will treat values of unknown type as SQL_VARCHAR values. By default, values of unknown type are treated as Y values. values. If unchecked, the driver will treat values of unknown type as SQL_VARCHAR values. By default, values of unknown type are treated as Y values. If enabled, the driver treats BOOL columns as SQL_CHAR values. If disabled, columns as If enabled, the driver treats values. If disabled, BOOL columns are treated as SQL_BIT values. columns are treated as values. If enabled, the driver treats VARCHAR and BPCHAR values longer than MaxVarCharSize as SQL_LONGVARCHAR values UnknownAsLongVarChar is on, columns of unknown type are If is on, columns of unknown type are MaxLongVarcharSize bytes long; otherwise, they are reported to be MaxVarcharSize bytes in length. bytes long; otherwise, they are reported to be bytes in length. SysTablePrefixes field to specify a semi-colon delimited list of prefixes that indicate that a table is a system table. By default, the list contains d Use the field to specify a semi-colon delimited list of prefixes that indicate that a table is a system table. By default, the list contains d d_; field to specify a semi-colon delimited list of prefixes that indicate that a table is a system table. By default, the list contains d d_; . If enabled, the SQLRowCount() function will return a single, cumulative row count for the entire array of parameter settings for an INSERT statement. If disabled, an individual row count will be returned for each parameter setting. By default, this option is disabled. function will return a single, cumulative row count for the entire array of parameter settings for an statement. If disabled, an individual row count will be returned for each parameter setting. By default, this option is disabled. The LF<->CR/LF conversion option instructs the driver to convert line-feed characters to carriage-return/line-feed pairs when fetching character values from the server and convert carriage-return/line-feed pairs back to line-feed characters when sending character values to the server. By default, this option is enabled. SQLSetPos() or SQLBulkOperations() functions. operations using the Permits positioned UPDATE and DELETE operations using the Permits positioned functions. If enabled, the driver treats BYTEA values as if they are of type SQL _ LONGVARBINARY values as if they are of type If enabled, the driver treats SQL . If disabled, BYTEA values are treated as SQL _ VARBINARY values. values are treated as SQL values. If enabled, the driver treats BYTEA values as if they are large objects. If enabled, the driver treats values as if they are large objects. The Row Versioning option specifies if the driver should include the column when reporting the columns in a table. The The Row Versioning option specifies if the driver should include the xmin column when reporting the columns in a table. The The Row Versioning option specifies if the driver should include the column when reporting the columns in a table. The xmin value is the ID of the transaction that created the row. You must use row versioning if you plan to create cursors where SQL_CONCURRENCY = SQL_CONCUR_ROWVER value is the ID of the transaction that created the row. You must use row versioning if you plan to create cursors where . Determines driver behavior if you try to retrieve information about a query without executing the query. If Yes , the driver declares a cursor for the query and fetches the meta-data from the cursor. If No , the driver declares a cursor for the query and fetches the meta-data from the cursor. If , the driver executes the command as soon as you request any meta-data. TrueIsMinus1 tells the driver to return BOOL values of TRUE as -1 . If this option is not enabled, the driver will return 1 as TRUE BOOL values of . If this option is not enabled, the driver will return values of . The driver always returns 0 as FALSE BOOL values of . The driver always returns . If enabled, the driver uses the PREPARE and EXECUTE commands to implement the Prepare/Execute model. BI The value of determines how the driver treats BIGINT values: determines how the driver treats values: 0x1 - Forces the output of short-length formatted connection strings. Specify this option if you are using the MFC CDatabase class.0x2 - Allows MS Access to recognize PostgreSQL's serial type as AutoNumber type. - Allows MS Access to recognize PostgreSQL's serial type as AutoNumber type.0x4 - Return ANSI character types for the inquiries from applications. Specify this option for applications that have difficulty handling Unicode data.0x8 - If set, NULL dates are reported as empty strings and empty strings are interpreted as dates on input. NULL dates on input. dates are reported as empty strings and empty strings are interpreted as NULL dates on input.0x10 - Determines if SQLGetInfo returns information about all tables, or only accessible tables. If set, only information is returned for accessible tables. - Determines if returns information about all tables, or only accessible tables. If set, only information is returned for accessible tables.0x20 - If set, each SQL command is processed in a separate network round-trip, otherwise, SQL commands are grouped into as few round-trips as possible to reduce network latency. If libpq (and its dependencies) are installed in the same directory as the EDB-ODBC driver, enabling SSL Mode allows you to use SSL and other utilities.
3.3.1 Windowsでのデータソース定義の追加Windows ODBC Data Source Administratorは、名前付きデータソースを作成するグラフィカルインターフェイスです。 Control Panel移動してControl Panel Administrative Tools ]メニューを開き、適切な[ ODBC Data Sources ]アイコン(32- or 64- bit)をダブルクリックすると、 ODBC Data Source Administrator (図2.2を参照)を開くことができます。[ Add ]ボタンをクリックして[ Create New Data Source ]ダイアログを開きCreate New Data Source (図2.3を参照)。ドライバの一覧から[ EnterpriseDB (ANSI)または[ EnterpriseDB (UNICODE) ]を選択し、[ Finish ]をクリックします。
•
•
• User Nameフィールドにユーザーの名前を入力します。
•
• libpqがEDB-ODBCドライバと同じディレクトリにインストールされている場合は、 SSL 横にあるドロップダウンリストボックス Mode ラベルがアクティブになり、SSLやその他のAdvanced Serverユーティリティを使用できるようになります。
•
• [ Global ]ボタンをクリックすると、EDB-ODBCドライバ(データソースではなくドライバ自体)のロギングオプションを指定できるダイアログが開きます。
• 遺伝的クエリDisable Genetic Optimizerを無効にするには、[遺伝Disable Genetic Optimizerを無効にする]の横のチェックボックスを Disable Genetic Optimizerます。デフォルトでは、クエリオプティマイザはonです。
• KSQO (Keyset Query Optimization) 横にあるチェックボックスをオンにして、キーセットクエリに対するサーバー側のサポートを有効にします。デフォルトでは、 Keyset Query Optimizationはonます。
• SQLStatistics()関数が固有索引を報告するようにするには、「 Recognize Unique Indexes 横のボックスをチェックします。このオプションがチェックされていない場合、 SQLStatistics()関数はすべてのインデックスが重複値を許可することを報告します。既定では、[ Recognize Unique Indexesはonます。
• アプリケーションがSELECTコマンドを実行するたびにドライバがサーバー側のカーソルを使用するように指定するには、[ Use Declare/Fetch を Use Declare/Fetch 横のボックスをオンにします 。デフォルトでは、 Use Declare/Fetchはoffです。
• CommLog (C:\psqlodbc_xxxx.log) 横のチェックボックスをオンにして、すべてのクライアント/サーバートラフィックをログファイルに記録します。デフォルトでは、ロギングはoffです。
• SQLNumResultCols() 、 SQLDescribeCol() 、またはSQLColAttributes()関数を呼び出すときに、(サーバーではなく)ドライバーが単純なSELECTステートメントの解析を試みるように指定するには、「 Parse Statements 横のボックスをチェックします 。デフォルトでは、このオプションはoffです。
• SQLCancel()関数がユーザーに代わってSQLFreeStmt(SQLClose)を呼び出すように指定するには、 SQLCancel() Cancel as FreeStmt (Exp) 横のボックスをオンにします。デフォルトでは、このオプションはoffです。
• MyLog (C:\mylog_xxxx.log) 横のボックスをチェックして 、ドライバの活動の詳細な記録をログファイルに記録します。ログファイルの名前はc:\mylog_ process-id .logです。デフォルトでは、ロギングはoffです。Unknown Sizesボックスのラジオボタンは、 SQLDescribeCol()およびSQLColAttributes()関数が未知の型の列のサイズを計算する方法を指定しSQLDescribeCol()既知のデータ型の一覧については、セクション3.7、 サポートされるデータ型を参照)。
• [ Maximum ]の横にあるボタンを選択して、ドライバがVARCHARまたはLONGVARCHAR許可されている最大サイズを報告するように指定します( Unknowns as LongVarChar設定によって異なります)。 Unknowns as LongVarCharが有効な場合、ドライバはLONGVARCHAR最大サイズ( MiscellaneousボックスのMax LongVarCharフィールドで指定)を返します。 [ Unknowns as LongVarCharが有効になっていない場合、ドライバは([ Miscellaneousボックスの)[ Max VarCharフィールドで指定されたサイズを返します。
• 次へ]ボタンを選択して Don't know指定するには、そのドライバレポート「不明」の長さ。
• [ Longest ]の横にあるボタンを選択して、ドライバが結果セットを検索し、見つかった最長の値を報告するように指定します。 (注: UseDeclareFetchが有効になっている場合は、 Longest指定しないでください。)
• Text as LongVarChar 横のチェックボックスをオンにして、 TEXT値がSQL_LONGVARCHAR型であるかのように扱います。このボックスがチェックされていない場合、ドライバはTEXT値をSQL_VARCHAR値としてSQL_VARCHARます。デフォルトでは、 TEXT値はSQL_LONGVARCHAR値として扱われます。
• Unknowns as LongVarChar 横のボックスをオンにして、ドライバーが不明なタイプの値をSQL_LONGVARCHAR値として扱うように指定します。オフにすると、ドライバは未知の型の値をSQL_VARCHAR値としてSQL_VARCHARます。デフォルトでは、未知のタイプの値はSQL_VARCHAR値として扱われます。
• [ Bools as Char 横のボックスをオンにして、ドライバがBOOL値をSQL_CHAR値として扱うように指定します。オフにすると、 BOOL値はSQL_BIT値として扱われます。デフォルトでは、 BOOL値はSQL_CHAR値として扱われます。
•
•
•
• SysTablePrefixesフィールドを使用して、テーブルがシステムテーブルであることを示す、コロンで区切られたプレフィックスのリストを指定します。デフォルトでは、リストにはdd_;が含まれてdd_; 。[ Apply ]ボタンをクリックしてデータソースのプロパティに変更を適用するか、[ Cancel ]ボタンをクリックして変更を適用せずにダイアログを終了します。ダイアログに変更を適用して終了するには、[ OK ]ボタンをクリックします。
• [ Read Only 横にあるチェックボックス Read Onlyにすると、ドライバは次のコマンドを実行できなくなりますINSERT 、 UPDATE 、 DELETE 、 CREATE 、 ALTER 、 DROP 、 GRANT 、 REVOKEまたはLOCK 。 Read Onlyオプションを呼び出すと、ODBCのプロシージャコールエスケープ構文( call=procedure-name? )を使用する呼び出しも禁止されます。デフォルトでは、このオプションはオフです。
• SQLTables()関数の結果セットにShow System Tablesを含めるには、[システムテーブルのShow System Tables 横のチェックボックスをオンにします 。このオプションが有効になっていると、ドライバは名前がpg_始まるテーブル、またはAdvanced OptionsダイアログのPage 1のSysTablePrefixesフィールドにリストされた任意のプレフィックスをSysTablePrefixesます。デフォルトでは、このオプションはオフです。
• ODBCデータソースを介してsysスキーマおよびdboスキーマ内のオブジェクトにアクセスするには、 Show sys/dbo Tables [Access] を Show sys/dbo Tables [Access] 横のチェックボックスをオンにします 。デフォルトでは、このオプションは有効(オン)になっています。
• SQLRowCount()メソッドの呼び出しが実行されたときにINSERTステートメントのパラメーター設定の配列全体に対して単一の累積行数が戻されるようにするには、「 Cumulative Row Count for Insert 横のボックスをチェックします 。このオプションが有効になっていない(ボックスがチェックされていない)場合は、配列内の各パラメーター設定に対して個別の行数が使用可能になるため、 SQLRowCount()呼び出しは最後に挿入された行の数を返します。
• LF<->CR/LF変換の隣のボックスをチェックして 、サーバから文字値を取得するときにラインフィード文字をキャリッジリターン/ラインフィードペアに変換し、キャリッジリターン/ラインフィードペアを変換するようにドライバに指示します。文字値をサーバに送信するときに文字を改行する。デフォルトでは、このオプションは有効になっています。
• Updatable Cursors 横のボックスをチェックして、ドライバーがSQLSetPos()またはSQLBulkOperations()関数を使用した位置付けUPDATEおよびDELETE操作を許可するように指定します。デフォルトでは、このオプションは有効になっています。
•
• テーブル内の列をレポートするときにxmin列を含めるには、[ Row Versioning 横にあるチェックボックスをオンにします。 xmin列は、行を作成したトランザクションのIDです。 SQL_CONCURRENCY = SQL_CONCUR_ROWVERカーソルを作成する予定の場合は、行のバージョン管理を使用する必要があります。デフォルトでは、 Row Versioningはオフです。
• ドライバが実際にクエリを実行せずにクエリに関するメタデータ(結果セット内の列数、または列タイプ)を取得するように指定するには、[ Disallow Premature未使用]の横のチェックボックスをオンにします。このオプションが指定されていない場合は、クエリに関するメタデータを要求したときにドライバがクエリを実行します。デフォルトでは、 Disallow Prematureは無効です。
• 次のチェックボックスをオンに True is -1を返すためにドライバーに指示するBOOL値Trueとして-1 。このオプションが有効になっていない場合、ドライバは1としてTrue BOOL値を返します。ドライバは常に0としてFalse BOOL値を返します。
• Server side prepare 横にあるチェックボックスをオンにして、ドライバにPREPAREコマンドとEXECUTEコマンドを使用してPrepare/Executeモデルを実装するように指示します。デフォルトでは、このチェックボックスはオンになっています。
•
• dbms_nameフィールドにデータベースシステム( EnterpriseDBまたはPostgreSQL )を入力します 。ここに入力された値は、 SQLGetInfo()関数が呼び出されたときにSQL_DBMS_NAME引数に返されます。デフォルトはEnterpriseDBです。Int8 Asボックスのラジオボタンを使用して 、ドライバがBIGINT値をクライアントに返す方法を指定します。 default横にあるラジオボタンを選択して、デフォルトのタイプを指定します。 クライアントがMS Jetの場合は NUMERIC 、クライアントが 他のODBCクライアントの場合は BIGINT 。ドライバーがBIGINT値をbigint ( SQL_BIGINT )、 numeric ( SQL_NUMERIC )、 varchar ( SQL_VARCHAR )、 double ( SQL_DOUBLE )、またはint4 ( SQL_INTEGER )として返すようにオプションで指定できます。
If set, NULL dates are reported as empty strings and empty strings are interpreted as dates on input. NULL dates on input. dates are reported as empty strings and empty strings are interpreted as NULL dates on input. SQLGetInfo returns information about all tables, or only accessible tables. If set, only information is returned for accessible tables. Determines if returns information about all tables, or only accessible tables. If set, only information is returned for accessible tables. [ Protocolボックスには、特定のフロントエンド/バックエンドプロトコルバージョンを使用してサーバーと対話するようにドライバーに指示するラジオボタンが含まれています。デフォルトでは、選択されているProtocolは7.4+です。必要に応じて、バージョン6.4+ 、 6.3または6.2から選択できます。[ Level of Rollback on errors の Level of Rollback on errorsボックスには、ドライバがエラー処理を処理する方法を指定するラジオボタンが含まれています。
[ OID Optionsボックスには、一部のテーブルに含まれるOID列をドライバが公開する方法を制御するオプションが含まれています。
• 「 Show Column 横のボックスをチェックして 、 SQLColumns()関数の結果セットにOID列を含めます。このボックスがチェックされていない場合、 OID列はSQLColumns()から隠されます。
• 使用する Connect Settingsこの接続を開くときに、ドライバが使用するパラメータの割り当てのリストを指定するには、フィールドを。 SETステートメントで変更できる構成パラメーターはすべて、セミコロンで区切ったリストに含めることができます。例えば:名前付きデータソースの接続プロパティを定義したら、[ Apply ]ボタンをクリックしてオプションを適用します。 Cancelを選択すると、オプションを保存せずにオプションで終了することができます。 [ OK ]ボタンを選択してオプションを保存して終了します。[ Global ]ボタン([ EnterpriseDB ODBC Driver ]ダイアログ)を選択して [ Global Settings ]ダイアログを開きます(図2.7)。このダイアログのオプションは、EDB-ODBCドライバのログ記録オプションを制御します。このダイアログを使用して、名前付きデータソースなしでドライバが使用されている場合、または接続文字列が解析される前に発生したドライバ操作のログを記録する場合に、ログを記録します。
• CommLogフィールドの横にあるチェックボックスをオンにして、すべてのクライアント/サーバートラフィックをログファイルに記録します。ログファイルの名前はC:\psqlodbc_ process-idここで、 process-idは使用中のプロセスの名前です。
• ドライバのアクティビティのログファイルを保存するには、 Mylogフィールドの横にあるチェックボックスをオンにします 。ログファイルの名前はc:\mylog_ process-idここで、 process-idは使用中のプロセスの名前です。
• [OK]ボタンをクリックして[ Connection Test ]ダイアログを閉じます。接続が成功したら、[ Save ]ボタンをクリックして名前付きデータソースを保存しSave 。接続の確立に問題がある場合は、パラメータを調整してもう一度テストしてください。
3.3.2 Linuxでのデータソース定義の追加Linux ODBC Administratorは、unixODBCとともに配布されているグラフィカルツールです。 ODBC Administratorを使用して、 ODBC Administratorドライバと名前付きリソースを管理できます。 ODBCアドミニストレータをシステムに追加するには、ターミナルウィンドウを開き、スーパーユーザ特権を引き継ぎ、次のように入力します。Advanced Server Connectorsコンポーネントをインストールすると、EDB-ODBCドライバがODBCアドミニストレータのドライバの一覧に追加されます。 [ Advanced設定]をクリックし、[ Drivers ]タブを選択して、 enterprisedbドライバがリストに表示されていることを確認します(図2.10を参照)。EDB-ODBCドライバがドライバの一覧に表示されていない場合は、 ODBC Administrator を使用して追加でき ODBC Administrator 。ドライバ定義を追加するには、[ Drivers ]タブを選択して[ Add ] Addクリックします。図2.11に示すように、 Driver Properties (new)ウィンドウが開きます。図2.11 - Driver Propertiesウィンドウ完了 Driver PropertiesドライバマネージャとEDB-ODBCドライバを登録するウィンドウを:
•
• Descriptionフィールドにドライバの説明を追加します。
•
• SetupフィールドにEDB-ODBCドライバの設定ファイルの場所へのパスを追加します 。デフォルトでは、ドライバセットアップファイルへの絶対パスは次のとおりです。EDB-ODBCドライバのドライバプロパティを説明したら、[ OK ]をクリックします 。 [ODBCデータソースアドミニストレータ]ウィンドウの使用可能なODBCドライバのリストにEDB-ODBCドライバが追加されました(図2.12)。ドライバマネージャがEDB-ODBCドライバを利用できるようになったら、データソースを追加できます。左側のパネルの[ Data Source Names ]オプションをクリックし、追加するデータソース名の種類に適した[DSN]タブを選択します。
•
• [ System ]タブを選択して、すべてのユーザーが利用できる名前付きデータソースを追加します。すべてのシステムデータソースは単一のファイル(通常は/etc/odbc.ini )に保存されています。
• File ]タブを選択して、すべてのユーザーが利用できる名前付きデータソースを追加しますが、それは選択したファイルに保存されています。Select the appropriate tab and click Add Select the appropriate tab and click . The window opens, as shown in Figure 2.13. a New Data Source… . The Create window opens, as shown in Figure 2.13.Select the EDB-ODBC driver from the list, and click OK Select the EDB-ODBC driver from the list, and click Data Source Properties window. to open the window.window (shown in Figure 2.14), specifying the connection properties for the EDB-ODBC driver. Complete the Data Source Properties (new) window (shown in Figure 2.14), specifying the connection properties for the EDB-ODBC driver.
•
• Enter a description of the named data source in the Description field. Enter a description of the named data source in the field.
• The unixODBC driver includes a trace utility that records the sequence of calls made an ODBC application to a log file. Specify Trace field to turn the trace utility on. Note that using the trace utility can slow down an application. Yes in the The unixODBC driver includes a trace utility that records the sequence of calls made an ODBC application to a log file. Specify field to turn the trace utility on. Note that using the trace utility can slow down an application.
• TraceFile field to specify a file to receive information returned by the Use the field to specify a file to receive information returned by the Trace utility. field to specify a file to receive information returned by the utility.
•
•
•
• Enter the password for the user in the Password field. Enter the password for the user in the field.
• Port field. Enter a port number (or accept the default value of 5444 Enter a port number (or accept the default value of ) in the field.
• Protocol field to specify a front-end/back-end protocol version; the default value is Use the field to specify a front-end/back-end protocol version; the default value is 7.4 . You can optionally select from protocol versions 7.4 , 6.4 , 6.3 or 6.2 .
• Use the ReadOnly field to specify Yes to 、次のコマンドを実行するからドライバを防ぐINSERT 、 UPDATE 、 DELETE 、 CREATE 、 ALTER 、 DROP 、 GRANT 、 REVOKEまたはLOCK 。 [ Read Only ]オプションを有効にすると、ODBCプロシージャコールエスケープ構文( call=procedure-name? )を使用する呼び出しも禁止されます。デフォルトでは、 ReadOnlyはNo設定されてNoます。
• テーブルの列をレポートするときにif the driver should xmin列if the driver should含めるif the driver shouldがあるif the driver should Use the RowVersioning field to specify Use the Yes field to specifyします。 xmin列は、行を作成したトランザクションのIDです。 SQL_CONCURRENCY = SQL_CONCUR_ROWVERカーソルを作成する予定の場合は、行のバージョン管理を使用する必要があります。デフォルトでは、 Row VersioningはNo設定されてNoます。
•
•
•
• ConnSettingsフィールドを使用して、この接続を開くときにドライバが使用するパラメータ割り当てのリストを指定します。
• SQLGetInfo()は、EDB-ODBCドライバとAdvanced Serverに関する情報を返します。
• SQLGetEnvAttr()は、ODBC環境属性に関する情報を返します。
• SQLGetConnectAttr()は、個々の接続に固有の属性に関する情報を返します。
• SQLGetStmtAttr()は、個々のステートメントに固有の属性に関する情報を返します。
• SQLSetEnvAttr()関数を使用して環境属性を設定します。
4.1 SQLGetInfo()ODBC SQLGetInfo()関数は、EDB-ODBCドライバとAdvanced Serverに関する情報を返します。 SQL_ODBC_VERとしてSQL_ODBC_VERを指定しない限り、 SQLGetInfo()を呼び出すにはオープン接続が必要info_type 。 SQLGetInfo()のシグネチャは次のとおりです。SQLHDBC conn_handle , // InputSQLUSMALLINT info_type , // InputSQLPOINTER info_pointer , // OutputSQLSMALLINT buffer_len , // InputSQLSMALLINT * string_length_pointer // OutputIf the info_type argument is SQL_DRIVER_HDESC or SQL_DRIVER_HSTMT , the info_pointer argument is both Input and Output .buffer_len is the length of the allocated memory buffer pointed to by buffer_len is the length of the allocated memory buffer pointed to by info_pointer . If info_pointer is NULL . If , buffer_len is ignored. If the returned value is a fixed size, buffer_len is ignored. buffer_len is only used if the requested value is returned in the form of a character string.string_length_pointer is a pointer to an SQLSMALLINT value. is a pointer to an value. SQLGetInfo() writes the size of the requested value in this integer.A typical usage is to call with a NULL with a SQLGetInfo() A typical usage is to call info_pointer to obtain the length of the requested value, allocate the required number of bytes, and then call SQLGetInfo() again (providing the address of the newly allocated buffer) to obtain the actual value. The first call retrieves the number of bytes required to hold the value; the second call retrieves the value. to obtain the length of the requested value, allocate the required number of bytes, and then call SQLGetInfo() again (providing the address of the newly allocated buffer) to obtain the actual value. The first call retrieves the number of bytes required to hold the value; the second call retrieves the value.If the size of the returned value exceeds buffer_len If the size of the returned value exceeds , the information is truncated and NULL terminated. If the returned value is a fixed size, string_length is ignored (and the size of the requested value is not provided by SQLGetInfo() is ignored (and the size of the requested value is not provided by ).SQLGetInfo() s information in one of the following formats:書き込みs information in one of the following formats:
• SQLUINTEGERビットマスク
• SQLUINTEGERフラグ
• SQLUINTEGERバイナリ値
• SQLUSMALLINT値
• NULL終端文字列
SQL info_type Argument SQLProcedures() Indicates if procedures returned by can be executed by the application. Indicates if procedures returned by can be executed by the application. N ReturnsSQLProcedures() function may be executed by the application. Some procedures executed by the function may be executed by the application. Indicates if the user has SQLTables(). privileges on all table names returned by SELECT privileges on all table names returned by Indicates if the user has SQLTables(). N Returns prev. SQL_MAX_DRIVER_CONNECTIONS 0 Returns 0 Returns 0 Returns SQL_AF_ALL Returns clauses supported by the server. Identifies the ALTER DOMAIN clauses supported by the server. Identifies the clauses supported by the server. 0 ReturnsALTER DOMAIN clauses are not supported. clauses supported by the server. Identifies the ALTER TABLE clauses supported by the server. Identifies the clauses supported by the server. Row Counts are available when executed by calling S QLExecute or SQLExecDirect Row Counts are available when executed by calling S . Now SQL_QUALIFIER_LOCATION Now SQL_QUALIFIER_NAME Y Returns Now SQL_QUALIFIER_NAME_SEPARATOR Now SQL_QUALIFIER_TERM catalog Returns Now SQL_QUALIFIER USAGE Catalog names can be used in SELECT , INSERT , UPDATE , DELETE , SELECT Catalog names can be used in FOR UPDATE and positioned UPDATE and DELETE statements. Y Returns SQL_CB_NON_NULL Returns CONVERT function. type using the Indicates conversion support from the BIGINT type using the Indicates conversion support from the function. 0 Returns CONVERT function. type using the Indicates conversion support from the BINARY type using the Indicates conversion support from the function. 0 Returns CONVERT function. type using the Indicates conversion support from the BIT type using the Indicates conversion support from the function. CONVERT function. type using the Indicates conversion support from the CHAR type using the Indicates conversion support from the function. 0 Returns 0 Returns CONVERT function. type using the Indicates conversion support from the DECIMAL type using the Indicates conversion support from the function. 0 Returns CONVERT function. type using the Indicates conversion support from the DOUBLE type using the Indicates conversion support from the function. 0 Returns CONVERT function. type using the FLOAT type using the Indicates conversion support from, the function. 0 Returns CONVERT function. Lists the scalar conversion functions supported by the server and driver using the function. CONVERT function. type using the Lists the conversion support from the INTEGER type using the Lists the conversion support from the function. CONVERT function. type using the Indicates conversion support from the INTERVAL_DAY_TIME type using the Indicates conversion support from the function. CONVERT function. type using the Indicates conversion support from the INTERVAL_YEAR_MONTH type using the Indicates conversion support from the function. CONVERT function. type using the Indicates conversion support for the LONG_VARBINARY type using the Indicates conversion support for the function. 0 Returns CONVERT function. type using the Indicates conversion support for the LONGVARCHAR type using the Indicates conversion support for the function. 0 Returns CONVERT function. type using the Indicates conversion support for the NUMERIC type using the Indicates conversion support for the function. 0 Returns CONVERT function. type using the Indicates conversion support for the REAL type using the Indicates conversion support for the function. 0 Returns CONVERT function. type using the Indicates conversion support for the SMALLINT type using the Indicates conversion support for the function. 0 Returns CONVERT function. type using the TIMESTAMP type using the Indicates conversion support for function. 0 Returns CONVERT function. type using the Indicates conversion support for the TINYINT type using the Indicates conversion support for the function. CONVERT function. type using the Indicates conversion support for the VARBINARY type using the Indicates conversion support for the function. 0 Returns CONVERT function. type using the Indicates conversion support for the WCHAR type using the Indicates conversion support for the function. CONVERT function. type using the Indicates conversion support for the WLONGVARCHAR type using the Indicates conversion support for the function. CONVERT function. type using the Indicates conversion support for the WVARCHAR type using the Indicates conversion support for the function. Returns SQL_CN_ANY 0 Returns 0 Returns 0 Returns 0 Returns 0 Returns file on Linux or the odbc.ini file on Linux or the dbms_name parameter from the file on Linux or the dialog box when defining a data source in Windows. The default is Advanced Options dialog box when defining a data source in Windows. The default is field of page 2 of the dialog box when defining a data source in Windows. The default is dbms_name field of page 2 of the Returns the value given by the dialog box when defining a data source in Windows. The default is EnterpriseDB . TXN_READ_COMMITTED Returns N Returns value that contains the driver's connection handle. SQLULEN value that contains the driver's connection handle. Returns an value that contains the driver's connection handle. value that contains driver's descriptor handle. SQLULEN value that contains driver's descriptor handle. Returns an value that contains driver's descriptor handle. value that contains the driver's environment handle. SQLULEN value that contains the driver's environment handle. Returns an value that contains the driver's environment handle. value that contains the library handle (returned to the ODBC driver manager when the manager loaded the driver). SQLULEN value that contains the library handle (returned to the ODBC driver manager when the manager loaded the driver). Returns an value that contains the library handle (returned to the ODBC driver manager when the manager loaded the driver). value that contains the driver's statement handle. SQLULEN value that contains the driver's statement handle. Returns an value that contains the driver's statement handle. EDB-ODBC.DLL Returns 03.50 Returns 9.0.0.6 Returns 0 Returns 0 Returns 0 Returns 0 Returns 0 Returns 0 Returns Y Returns SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1 Describes extended attributes for the forward-only cursor designated by . GROUP BY clause and columns in the SELECT list. clause and columns in the Indicates the relationship between a list. " Returns 0 Returns Prev. SQL_ODBC_SQL_OPT_IEF N Returns "" Returns N ReturnsAdvanced Server does not support escape characters in LIKE predicates. Advanced Server does not support escape characters in predicates. 0 Returns 0 Returns 0 Returns 0 Returns 64 Returns 0 Returns 0 Returns 0 Returns 0 Returns 0 Returns prev. SQL_MAX_ACTIVE_STATEMENTS 0 Returns 32 ReturnsA cursor name cannot exceed 32 characters in length. A cursor name cannot exceed characters in length. prev. SQL_ACTIVE_CONNECTIONS 0 Returns 64 Returns 0 Returns Now SQL_MAX_SCHEMA_NAME_LEN 64 Returns 0 Returns Now SQL_MAX_CATALOG_NAME_LEN 0 Returns 0 Returns SQL_MAX_ROW_SIZE columns in the row. LONGVARCHAR columns in the row. or LONGVARBINARY columns in the row. includes the length of any Indicates whether the columns in the row. Y Returns 64 Returns 0 Returns 64 Returns 0 Returns 0 Returns data value before receiving the value. Indicates if the server needs the length of a LONG data value before receiving the value. Indicates if the server needs the length of a data value before receiving the value. Indicates if the server supports values in columns. NOT NULL values in columns. Indicates if the server supports values in columns. SQL_NNC_NON_NULL ReturnsAdvanced Server does support values in columns. NOT NULL values in columns. Advanced Server does support values in columns. values are located in a result set. NULL values are located in a result set. Indicates where values are located in a result set. SQL_NC_HIGH Returnsvalues in a data set is determined by the The location of NULL values in a data set is determined by the The location of values in a data set is determined by the ASC keywords; and DESC keywords; values in a data set is determined by the keywords; NULL values are sorted to the high end of the data set. SQL_OAC_LEVEL1 Returns SQL_OIC_CORE Returns Now SQL_INTEGRITY N Returns 03.52.0000 Returns SQL_OJ_LEFT Returns Y Returns prev. SQL_SCHEMA_TERM schema Returns ORDER BY clause must be included in the Indicates if the columns in an SELECT list. clause must be included in the Indicates if the columns in an list. N ReturnsORDER BY clause do not have to be in the Columns in an clause do not have to be in the SELECT list. clause do not have to be in the list. prev. SQL_SCHEMA_USAGE SQL_PARC_BATCH Returnsif a single, cumulative row count is available for the entire array. SQL_PARC_NO_BATCH Returns if a single, cumulative row count is available for the entire array. Returns procedure Y Returns prev. SQL_CATALOG_LOCATION prev. SQL_CATALOG_NAME Y Returns prev. SQL_CATALOG_NAME_SEPARATOR prev. SQL_CATALOG_TERM catalog Returns prev. SQL_CATALOG_USAGE Catalog names can be used in SELECT , INSERT , UPDATE , DELETE , SELECT Catalog names can be used in FOR UPDATE and positioned UPDATE and DELETE statements. Qualifiers can be used in all DML statements ( SELECT , INSERT , UPDATE , DELETE , SELECT Qualifiers can be used in all DML statements ( FOR UPDATE ). SQL_IC_SENSITIVE Returns Returns . catalog Returns SQL_CL_START Returns Y Returns schema Returns in search patterns. The escape character that allows use of the wildcard characters % and _ The escape character that allows use of the wildcard characters in search patterns. Returns \' characters in search patterns. ' character is used as an escape character for the ' The ' \ ' character is used as an escape character for the ' % ' and ' _ ' characters in search patterns. ' character is used as an escape character for the ' ' characters in search patterns. _ Returns statement supported by the server. Identifies the predicates of a SELECT statement supported by the server. Identifies the predicates of a statement supported by the server. statement that are supported by the server. REVOKE statement that are supported by the server. Identifies the clauses in a statement that are supported by the server. statement that are supported by the server. SELECT statement that are supported by the server. Indicates the row value constructor expressions in a statement that are supported by the server. standard the driver conforms to. Indicates the CLI standard the driver conforms to. Indicates the standard the driver conforms to. SQLSetPos() or UPDATE or DELETE statements are detected by the application. Indicates whether changes made to a static cursor by statements are detected by the application. Indicates whether changes made to a static cursor by statements are detected by the application. 0 Returns Returns table TIMESTAMPADD scalar function. Indicates the timestamp intervals supported by the server for the scalar function. 0 Returns TIMESTAMPDIFF scalar function. Indicates the timestamp intervals supported by the server for the scalar function. 0 Returns specification that the driver manager complies with. X/Open specification that the driver manager complies with. The publication year of the specification that the driver manager complies with.
4.2 接続属性4.2.1 SQLGetConnectAttr()SQLGetConnectAttr()関数は、接続属性の現在の値を返します。署名は次のとおりです。SQLHDBC conn_handle, //InputSQLINTEGER attribute, //InputSQLPOINTER value_pointer, //OutputSQLINTEGER buffer_length, //InputSQLINTEGER * string_length_pointer //Outputattributeは、値を取得したい属性を識別します。attribute値を受け取るメモリー内の場所へのポインター 。場合 attribute ODBCによって定義されるvalue_pointer文字列またはバイナリバッファを指し、 buffer_lengthの長さであるvalue_pointer 。 value_pointerが固定サイズの値(整数など)をbuffer_lengthている場合、 buffer_lengthは無視されます。
SQL_LEN_BINARY_ATTR(length) The result of value_pointerに戻すために使用可能なバイト数を受け取るSQLINTEGER へのポインター 。場合value_pointerあるNULL 、 string_length_pointer返されません。
4.2.2 SQLSetConnectAttr()SQLHDBC conn_handle , // InputSQLINTEGER attribute , // InputSQLPOINTER value_pointer , // InputSQLINTEGER string_length , // Inputattributeは、値を設定したい属性を識別します。attributeが想定する値へのポインタ 。attributeがODBCおよびvalue_pointerによって定義されている場合 、バイナリバッファまたは文字列を指しstring_lengthの長さであるvalue_pointer 。 value_pointerが固定長の値(整数など)をstring_lengthている場合、 string_lengthは無視されます。
SQL_LEN_BINARY_ATTR(length) The result of SQLSetConnectAttr()戻りSQL_SUCCESS 、 SQL_SUCCESS_WITH_INFO 、 SQL_ERROR 、 SQL_STILL_EXECUTINGまたはSQL_INVALID_HANDLE.SQLSetConnectAttr()は、接続ハンドルが割り振られてから、 SQLFreeHandle().呼び出しで接続がクローズされるまでの間、いつでも呼び出すことができます SQLFreeHandle().呼び出しによって設定されたすべての属性は、 SQLFreeHandle()呼び出しまで持続します。
4.3 環境属性4.3.1 SQLGetEnvAttr()SQLGetEnvAttr()関数を使用して、システムの環境属性の現在の値を見つけます。関数のシグネチャは次のとおりです。SQLHDBC env_handle , // InputSQLINTEGER attribute , // InputSQLPOINTER value_ptr , // OutputSQLINTEGER buffer_length , // InputSQLINTEGER * string_length_pointer // Outputattributeは、値を取得したい属性を識別します。attribute値を受け取るメモリー内の場所へのポインター 。value_pointerに戻すために使用可能なバイト数を受け取るSQLINTEGER へのポインター 。場合value_pointerあるNULL 、 string_length_pointer返されません。
4.3.2 SQLSetEnvAttr()SQLHENV env_handle , //InputSQLINTEGER attribute , //InputSQLPOINTER value_pointer , //InputSQLINTEGER string_length //Inputattributeは、値を設定したい属性を識別します。場合 value_pointerバイナリバッファまたは文字列へのポインタであり、 string_lengthの長さであるvalue_pointer 。属性に割り当てられている値が文字の場合、 string_lengthはその文字ストリングの長さです。場合value_pointerあるNULL 、 string_length返されません。 value_pointerが整数の場合、 string_lengthは無視されます。アプリケーションは接続ハンドルを割り振る前にSQLSetEnvAttr() 呼び出す必要があります 。環境属性に適用されたすべての値は、接続に対してSQLFreeHandle()が呼び出されるまで存続します。 ODBCバージョン3.xでは、複数の環境ハンドルを同時に割り当てることができます。
Defaults to SQL_TRUE. Calls that set this attribute to SQL_FALSE Calls that set this attribute to SQL_FALSE SQL_ERROR/SQLSTATEHYC00 (feature not implemented). SQL_ERROR/SQLSTATEHYC00 (feature not implemented). return Calls that set this attribute to (feature not implemented).
4.4 ステートメント属性4.4.1 SQLGetStmtAttr()SQLHDBC stmt_handle, //InputSQLINTEGER attribute, //InputSQLPOINTER value_ptr, //OutputSQLINTEGER buffer_length, //InputSQLINTEGER * string_length_pointer //Outputattributeは属性値ですattribute値を受け取るメモリー内の場所へのポインター 。属性はODBCによって定義されている場合、 buffer_lengthの長さであるvalue_pointer (場合value_pointer文字列またはバイナリバッファにポイント)。場合value_pointer整数を指し、 buffer_length無視されます。
SQL_LEN_BINARY_ATTR(length) The result of
4.4.2 SQLSetStmtAttr()SQLHENV stmt_handle , //InputSQLINTEGER attribute , //InputSQLPOINTER value_pointer , //InputSQLINTEGER string_length //Inputstmt_handleは環境ハンドルです。attributeは、値を設定したいステートメント属性を識別します。value_pointerは、属性に割り当てられる値を保持するメモリ内の場所へのポインタです。 value_pointerは、次のものへのポインタです。
•
•
• SQLUINTEGER値
• SQLULEN値attributeがODBCおよびvalue_pointerによって定義されている場合 、バイナリバッファまたは文字列を指しstring_lengthの長さであるvalue_pointer 。場合value_pointer整数を指し、 string_length無視されます。
SQL_LEN_BINARY_ATTR(length) The result of
4.5 エラー処理4.5.1 SQLGetDiagRec()SQLGetDiagRec()関数は、属性値を取得または設定するODBC関数によって書かれた診断レコードのステータスとエラー情報を返します。署名は次のとおりです。SQLSMALLINT handle_type , // InputSQLHANDLE handle , // InputSQLSMALLINT record_number , // InputSQLCHAR * SQLState_pointer , // OutputSQLINTEGER * native_error_pointer , // OutputSQLCHAR * error_text_pointer , // OutputSQLSMALLINT buffer_length , // Input
• SQL_HANDLE_ENVは環境ハンドルを指定します。
• SQL_HANDLE_STMTはステートメント・ハンドルを指定します。
• SQL_HANDLE_DBCは接続ハンドルを指定します。
• SQL_HANDLE_DESCは記述子ハンドルを指定します。Th e status record that the application is seeking information from (must be greater than or equal to 1).error code from the record. SQLState error code from the record. Pointer to a memory buffer that receives the error code from the record.Pointer to a buffer that receives the native error message for the data source (contained in the SQL_DIAG_NATIVE field). Pointer to a buffer that receives the native error message for the data source (contained in the field).Pointer to a memory buffer that receives the error text (contained in the SQL_DIAG_MESSAGE_TEXT field) Pointer to a memory buffer that receives the error text (contained in the field)error_text_pointer field. If the number of characters in the Pointer to the buffer that receives the size (in characters) of the field. If the number of characters in the error_text_pointer parameter exceeds the number available (in buffer_length ), error_text_pointer will be truncated.
次の表はODBC API関数の一覧です。 APIがEDB-ODBCドライバーによってサポートされている場合、右側の列は Yes 指定します 。 ODBC SQLGetFunctions()関数( SQL_API_ODBC3_ALL_FUNCTIONS関数IDを指定SQLGetFunctions()使用して、このリストの現在のバージョンを返します。
4.7 サポートされているデータ型
4.8 スレッドセーフ