protected function createTableInfo($table)
{
list($schemaName, $tableName) = $this->getSchemaTableName($table);
// This query is made much more complex by the addition of the 'attisserial' field.
// The subquery to get that field checks to see if there is an internally dependent
// sequence on the field.
$sql = <<<EOD
\t\tSELECT
\t\t\ta.COLUMN_ID,
\t\t\tLOWER(a.COLUMN_NAME) as attname,
\t\t\ta.DATA_TYPE || DECODE( a.DATA_TYPE, 'NUMBER', '('||a.DATA_PRECISION||','||DATA_SCALE||')' , '') as type,
\t\t\ta.DATA_LENGTH as atttypmod,
\t\t\tDECODE(a.NULLABLE, 'Y', '0', '1') as attnotnull,
\t\t\tDECODE(a.DEFAULT_LENGTH, NULL, '0', '1') as atthasdef,
\t\t\tDATA_DEFAULT as adsrc,
\t\t\t'0' AS attisserial
\t\tFROM
\t\t\tALL_TAB_COLUMNS a
\t\tWHERE
\t\t\tTABLE_NAME = '{$tableName}'
\t\t\tAND OWNER = '{$schemaName}'
\t\tORDER BY a.COLUMN_ID
EOD;
$this->getDbConnection()->setActive(true);
$this->getDbConnection()->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
$command = $this->getDbConnection()->createCommand($sql);
//$command->bindValue(':table', $tableName);
//$command->bindValue(':schema', $schemaName);
$tableInfo = $this->createNewTableInfo($schemaName, $tableName);
$index = 0;
foreach ($command->query() as $col) {
$col['index'] = $index++;
$this->processColumn($tableInfo, $col);
}
if ($index === 0) {
throw new TDbException('dbmetadata_invalid_table_view', $table);
}
return $tableInfo;
}