- Modificata la pre_writerel in funzione booleana per abilitare/disab la write su relazione

- Introdotta la gestione dei Join nei tracciati!


git-svn-id: svn://10.65.10.50/trunk@5530 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
augusto 1997-11-04 11:25:00 +00:00
parent b2d7915d77
commit b9025cfa3c
2 changed files with 59 additions and 9 deletions

View File

@ -224,8 +224,55 @@ void TFile_text::set_rec_parm(TConfig& config, const char* section)
}
if (lavoro == "JOI") // setta i join
{
NFCHECK("Join non ancora supportati");
continue;
CHECKS(tmprel, "Can't join to NULL relation ", (const char*)j);
TToken_string join_expr((const char *)obj,' '); // Join expression
int token=0;
TString16 j(join_expr.get(token++)); // file or table
int to=0; // 'to' default: _relation->lfile()->num();
if (strcmp(join_expr.get(token++),"TO")==0) // TO keyword
{
const char* t = join_expr.get(token++);
to = name2log(t);
} else
token --;
int key = 1;
if (strcmp(join_expr.get(token++),"KEY")==0)
key = join_expr.get_int(token++);
else
token--;
int alias = 0;
if (strcmp(join_expr.get(token++),"ALIAS")==0)
alias = join_expr.get_int(token++);
else
token--;
TToken_string exp(80);
if (strcmp(join_expr.get(token++),"INTO")==0)
{
const char* r = join_expr.get(token++);
while (r && strchr(r, '=') != NULL)
{
exp.add(r);
r = join_expr.get(token++);
}
}
#ifdef DBG
if (exp.empty()) yesnofatal_box("JOIN senza espressioni INTO");
#endif
if (isdigit(j[0]))
tmprel->add(atoi(j), exp, key, to, alias); // join file
else
{
#ifdef DBG
if (j.len() > 4)
yesnofatal_box("'%s' non e' una tabella valida: %d", (const char*)j);
else
#endif
tmprel->add(j, exp, key, to, alias); // join table
}
continue;
}
TTracciato_campo& tc = tr->get(n);//prendo il tracciato campo con indice <n>
if (lavoro == "NAM")
@ -607,11 +654,14 @@ int TFile_text::_autosave(TRelation& rel, const TRecord_text& rec, TTracciato_re
field.write(valore, rel);//faccio una write sulla relazione del fieldref
}
}
pre_writerel(rel,rec);
int err = rel.write();
if (err == _isdupkey || err ==_isreinsert)
err = rel.rewrite();
return err;
if (pre_writerel(rel,rec))
{
int err= rel.write();
if (err == _isdupkey || err ==_isreinsert)
err = rel.rewrite();
return err;
} else
return NOERR;
}
//Scarica dal record_text il campo alla posizione <ncampo>

View File

@ -175,8 +175,8 @@ protected:
//effettua modifiche particolari al valore da assegnare ad un campo dell'isamfile
//virtual void preformat_field(TRelation& rel,const TFieldref&field,const TRecord_text& rec,TString &str) {}
virtual void preformat_field(const TFieldref&field,TString &str,TRelation& rel,const TString &tipo_tr) {}
//effettua modifiche sui record della relazione prima di effettuarne la write
virtual void pre_writerel(TRelation& rel,const TRecord_text& rec) {}
//effettua modifiche sui record della relazione prima di effettuarne la write; ritorna TRUE se deve effettuare la write
virtual bool pre_writerel(TRelation& rel,const TRecord_text& rec) {return TRUE;}
public:
TFile_text(const char* file_name, const char* config_name);
virtual ~TFile_text();