Patch level : nopatch
Files correlati : Commento : Implementazione FP
This commit is contained in:
parent
60a52ab73d
commit
e7d51d8c07
@ -596,16 +596,40 @@ bool TPaf_record::update()
|
|||||||
TPaf_record::TPaf_record(const char* table) : _table(table), _key(15, ',')
|
TPaf_record::TPaf_record(const char* table) : _table(table), _key(15, ',')
|
||||||
{
|
{
|
||||||
TString q;
|
TString q;
|
||||||
q << "SELECT col.[name] FROM sys.columns AS col \
|
TString constraint(table);
|
||||||
|
|
||||||
|
constraint.rtrim(1);
|
||||||
|
constraint << 'Q';
|
||||||
|
// q << "SELECT col.[name] FROM sys.columns AS col \
|
||||||
|
// inner JOIN sys.index_columns AS idx on col.[object_id] = idx.[object_id] AND col.[column_id] = idx.[column_id] \
|
||||||
|
// inner join sys.indexes as K on idx.[index_id] = K.[index_id] \
|
||||||
|
// where K.[name] = '" << table << "_KEY' \
|
||||||
|
// AND idx.[object_id] = object_id('" << table << "') \
|
||||||
|
// ORDER BY index_column_id ASC";
|
||||||
|
q << "SELECT col.[name] FROM sys.columns AS col \
|
||||||
inner JOIN sys.index_columns AS idx on col.[object_id] = idx.[object_id] AND col.[column_id] = idx.[column_id] \
|
inner JOIN sys.index_columns AS idx on col.[object_id] = idx.[object_id] AND col.[column_id] = idx.[column_id] \
|
||||||
inner join sys.indexes as K on idx.[index_id] = K.[index_id] \
|
inner join sys.indexes as K on idx.[index_id] = K.[index_id] \
|
||||||
where K.[name] = '" << table << "_KEY' \
|
where K.[name] = '" << constraint << "' \
|
||||||
AND idx.[object_id] = object_id('" << table << "') \
|
AND idx.[object_id] = object_id('" << table << "') \
|
||||||
ORDER BY index_column_id ASC";
|
ORDER BY index_column_id ASC";
|
||||||
|
|
||||||
for (bool ok = fp_db().sq_set_exec(q); ok; ok = fp_db().sq_next())
|
for (bool ok = fp_db().sq_set_exec(q); ok; ok = fp_db().sq_next())
|
||||||
{
|
{
|
||||||
_key.add(fp_db().sq_get("name"));
|
_key.add(fp_db().sq_get("name"));
|
||||||
}
|
}
|
||||||
|
if (_key.empty_items())
|
||||||
|
{
|
||||||
|
q = "SELECT col.[name] FROM sys.columns AS col ";
|
||||||
|
q << "inner JOIN sys.index_columns AS idx on col.[object_id] = idx.[object_id] AND col.[column_id] = idx.[column_id] \
|
||||||
|
inner join sys.indexes as K on idx.[index_id] = K.[index_id] \
|
||||||
|
where K.[name] = '" << table << "_KEY' \
|
||||||
|
AND idx.[object_id] = object_id('" << table << "') \
|
||||||
|
ORDER BY index_column_id ASC";
|
||||||
|
for (bool ok = fp_db().sq_set_exec(q); ok; ok = fp_db().sq_next())
|
||||||
|
{
|
||||||
|
_key.add(fp_db().sq_get("name"));
|
||||||
|
}
|
||||||
|
}
|
||||||
CHECKS(!_key.empty_items(), "Invalid primary key for table ", table);
|
CHECKS(!_key.empty_items(), "Invalid primary key for table ", table);
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user