//получение полей первичного ключа public IndexData GetPrimaryKey(string schemaName, string tableName) { var _primData = new IndexData(); if (_initialized) { using (ODBCHStatement statement = new ODBCHStatement(_connectionHandle)) { PrimaryKeyStatementDefinition primaryKeyDefinition = new PrimaryKeyStatementDefinition(); List <ODBCData> data = null; try { data = BindBuffer(primaryKeyDefinition); if (ODBCMethods.GetPrimKey(statement, schemaName, tableName)) { if (BindColumns(data, statement)) { while (ODBCMethods.Fetch(statement)) { FillInternalData(ref data); _primData.SetData(0, ""); ColumnData _cd = new ColumnData(data[0].InternalData.strVal, data[1].InternalData.intVal, true); _primData.AddColumnData(_cd); //PrimaryKeyData prim = new PrimaryKeyData(data[0].InternalData.strVal, data[1].InternalData.intVal); // _primData.Add(prim); } } } } finally { foreach (var record in data) { record.Dispose(); } // statement.Close(); } } return(_primData); } else { throw new ODBCErrorNotInitialized("You must connect to database!"); } }
//получение информации об индексах, полях, входящих в них public List <IndexData> GetIndexData(string schemaName, string tableName) { var _indexesData = new List <IndexData>(); const ushort _indexType = 1; //all indexes; if (_initialized) { using (ODBCHStatement statement = new ODBCHStatement(_connectionHandle)) { List <ODBCData> data = null; IndexStatementDefinition indexStatementDefinition = new IndexStatementDefinition(); try { data = BindBuffer(indexStatementDefinition); if (ODBCNative.ODBCMethods.GetIndexInfo(statement, schemaName, tableName, _indexType)) { if (BindColumns(data, statement)) { bool fetched = ODBCNative.ODBCMethods.Fetch(statement); while (fetched) { FillInternalData(ref data); string indexName = data[1].InternalData.strVal; if (indexName.Length > 1) { IndexData _indexData = new IndexData(); _indexData.SetData(data[0].InternalData.intVal, data[1].InternalData.strVal); while ((fetched) & (indexName.Equals(data[1].InternalData.strVal))) { int _unique = ODBCMethods.ReadShort(data[0].ColumnData); if ((_unique == ODBCNative.ODBCConstants.SQL_IS_INDEX_UNIQUE) | (_unique == ODBCNative.ODBCConstants.SQL_IS_INDEX_DUPLICATE)) { bool asc = (data[4].InternalData.strVal == "A"); ColumnData cd = new ColumnData(data[3].InternalData.strVal, data[2].InternalData.intVal, asc); _indexData.AddColumnData(cd); } fetched = ODBCNative.ODBCMethods.Fetch(statement); if (fetched) { FillInternalData(ref data); } } _indexesData.Add(_indexData); } else { fetched = ODBCNative.ODBCMethods.Fetch(statement); } } } } } finally { foreach (var record in data) { record.Dispose(); } } } return(_indexesData); } else { throw new ODBCErrorNotInitialized("You must connect to database!"); } }