Patch level : 12.0 978

Files correlati     : ba8.exe ba8200b.msk
Commento            :

- Corretta generazione quesry per il file del 770
This commit is contained in:
Alessandro Bonazzi 2020-07-17 13:09:46 +02:00
parent de496673aa
commit 7138353652
2 changed files with 42 additions and 17 deletions

View File

@ -138,12 +138,22 @@ public:
int TTable_mask::father_logicnum() const
{
return table2logic(get(F_FATHER));
TFilename n = get(F_FATHER);
int logic = table2logic(n);
if (logic <= 0)
logic = table2logic(n.name_only());
return logic;
}
int TTable_mask::son_logicnum() const
{
return table2logic(get(F_SON));
TFilename n = get(F_SON);
int logic = table2logic(n);
if (logic <= 0)
logic = table2logic(n.name_only());
return logic;
}
// Dato il numero logico di una tabella ed un campo (di un'altra tabella)
@ -263,13 +273,14 @@ TTable_mask::TTable_mask() : TAutomask("ba8200b")
for (int logic = LF_USER; logic < nfiles; logic++)
{
const FileDes& fd = prefix().get_filedes(logic);
tt = fd.SysName;
tt = fd.SysName;
if (tt.full())
{
tt.strip("$%"); tt.upper();
tt.add(logic);
tt.add(fd.Des);
sht.rows_array().add(tt);
tt.add(fd.Des);
sht.rows_array().add(tt);
}
}
sht.rows_array().sort();
@ -617,10 +628,11 @@ static bool sql_tree_handler(TTree& tree, void* jolly, word flags)
TString& where = *(TString*)arr.objptr(1);
TString_array& join = rn->join();
TString str;
TFilename n = rn->name(); n = n.name_only();
if (from.get_pos(rn->id()) < 0)
{
from.add(rn->name());
from.add(n);
if (rn->alias().not_empty())
from << " AS " << rn->alias();
@ -630,10 +642,17 @@ static bool sql_tree_handler(TTree& tree, void* jolly, word flags)
{
if (where.not_empty())
where << "AND";
where << '(' << rn->id() << '.' << row->get(0) << '=';
TFilename id = rn->id(); id = id.name_only();
where << '(' << id << '.' << row->get(0) << '=';
str = row->get();
if (isalpha(str[0]))
where << rn->father()->id() << '.';
if (isalpha(str[0]))
{
TFilename father_id = rn->father()->id(); father_id = father_id.name_only();
where << father_id << '.';
}
where << str << ')';
}
}
@ -718,8 +737,10 @@ void TQuery_mask::sheet2sql()
{
if (multiple)
{
const TString& tab = row->get(0);
if (!tab.blank())
TFilename tab = row->get(0);
tab = tab.name_only();
if (tab.full())
{
field.insert(".");
field.insert(tab); // Table name
@ -788,9 +809,13 @@ void TQuery_mask::sheet2isam()
TString_array rel;
tree2isam(rel);
TString use;
FOR_EACH_ARRAY_ROW(rel, i, row)
use << *row << '\n';
TString use("USE ");
FOR_EACH_ARRAY_ROW(rel, i, row)
{
TFilename t = *row; t = t.name_only();
use << t << '\n';
}
set(F_SQL, use, true);
_sql_dirty = false;

View File

@ -7,11 +7,11 @@ BEGIN
PROMPT 1 0 "@bTabella collegata"
END
STRING F_SON 10
STRING F_SON 30 10
BEGIN
PROMPT 2 1 "Tabella "
FLAGS "U"
SHEET "Tabella@10|Num@3R|Descrizione archivio@70"
SHEET "Tabella@30|Num@3R|Descrizione archivio@70"
INPUT F_SON
OUTPUT F_SON
CHECKTYPE REQUIRED
@ -28,7 +28,7 @@ BEGIN
PROMPT 25 0 "@bTabella principale"
END
STRING F_FATHER 10
STRING F_FATHER 30 10
BEGIN
PROMPT 26 1 "Tabella "
FLAGS "D"