Patch level : 12.0 nopatch
Files correlati : Commento : sistemata add_between_filter. Aggiunte add_between_num_filter add_between_date_filter
This commit is contained in:
parent
7a4f105218
commit
30e1e22190
@ -1713,34 +1713,70 @@ const TString& TISAM_recordset::driver_version() const
|
|||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
TString& TISAM_recordset::add_between_filter(const TString& field, const TString& from_val, const TString& to_val,
|
TString& TISAM_recordset::add_between_filter(TString & clause, const TString& field, const char* from_val, const char * to_val)
|
||||||
TString from_fld, TString to_fld)
|
|
||||||
{
|
{
|
||||||
// Se from_fld e to_fld sono vuoti vengono valorizzati con il nome del campo preceduti da #DA e #A
|
|
||||||
if (from_fld.empty() || to_fld.empty())
|
|
||||||
{
|
|
||||||
const TString qf = field.find('.') < 0 ? field : field.sub(field.find('.') + 1);
|
|
||||||
if (from_fld.empty())
|
|
||||||
from_fld << "#DA" << qf;
|
|
||||||
if (to_fld.empty())
|
|
||||||
to_fld << "#A" << qf;
|
|
||||||
}
|
|
||||||
|
|
||||||
TString& ret = get_tmp_string();
|
TString& ret = get_tmp_string();
|
||||||
if (from_val.full() && to_val.full())
|
|
||||||
{
|
|
||||||
ret << "&&(BETWEEN(" << field << ", " << from_fld << ", " << to_fld << "))";
|
|
||||||
}
|
|
||||||
else if (from_val.full())
|
|
||||||
{
|
|
||||||
ret << "&&(" << field << ">=" << from_fld << ")";
|
|
||||||
}
|
|
||||||
else if (to_val.full())
|
|
||||||
{
|
|
||||||
ret << "&&(" << field << "<=" << to_fld << ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
if (from_val && *from_val && to_val && *to_val)
|
||||||
|
ret << "(BETWEEN(" << field << ", \"" << from_val << "\", \"" << to_val << "\"))";
|
||||||
|
else
|
||||||
|
if (from_val && *from_val)
|
||||||
|
ret << "(" << field << ">=\"" << from_val << "\")";
|
||||||
|
else
|
||||||
|
if (to_val && *to_val)
|
||||||
|
ret << "(\"" << field << "<=" << to_val << "\")";
|
||||||
|
if (ret.full())
|
||||||
|
{
|
||||||
|
if (clause.full())
|
||||||
|
clause << "&&";
|
||||||
|
clause << ret;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
TString& TISAM_recordset::add_between_num_filter(TString & clause, const TString& field, const char* from_val, const char * to_val)
|
||||||
|
{
|
||||||
|
|
||||||
|
TString& ret = get_tmp_string();
|
||||||
|
|
||||||
|
if (from_val && *from_val && to_val && *to_val)
|
||||||
|
ret << "(BETWEEN(" << field << ", " << from_val << ", " << to_val << "))";
|
||||||
|
else
|
||||||
|
if (from_val && *from_val)
|
||||||
|
ret << "(" << field << ">=" << from_val << ")";
|
||||||
|
else
|
||||||
|
if (to_val && *to_val)
|
||||||
|
ret << "(" << field << "<=" << to_val << ")";
|
||||||
|
if (ret.full())
|
||||||
|
{
|
||||||
|
if (clause.full())
|
||||||
|
clause << "&&";
|
||||||
|
clause << ret;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
TString& TISAM_recordset::add_between_date_filter(TString & clause, const TString& field, const TDate & from_val, const TDate & to_val)
|
||||||
|
{
|
||||||
|
|
||||||
|
TString& ret = get_tmp_string();
|
||||||
|
|
||||||
|
if (from_val && *from_val && to_val && *to_val)
|
||||||
|
ret << "(BETWEEN(" << field << ", " << from_val.date2ansi() << ", " << to_val.date2ansi() << "))";
|
||||||
|
else
|
||||||
|
if (from_val && *from_val)
|
||||||
|
ret << "(ANSI(" << field << ")>=" << from_val.date2ansi() << ")";
|
||||||
|
else
|
||||||
|
if (to_val && *to_val)
|
||||||
|
ret << "(ANSI(" << field << ")<=" << to_val.date2ansi() << ")";
|
||||||
|
if (ret.full())
|
||||||
|
{
|
||||||
|
if (clause.full())
|
||||||
|
clause << "&&";
|
||||||
|
clause << ret;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
TISAM_recordset::TISAM_recordset(const char* use)
|
TISAM_recordset::TISAM_recordset(const char* use)
|
||||||
|
@ -187,12 +187,9 @@ public:
|
|||||||
virtual const TString& driver_version() const;
|
virtual const TString& driver_version() const;
|
||||||
virtual const TString& query_text() const { return _use; }
|
virtual const TString& query_text() const { return _use; }
|
||||||
|
|
||||||
// Utility
|
static TString& add_between_filter(TString & clause, const TString& field, const char * from_val, const char * to_val);
|
||||||
/* Ritorna un filtro che può essere:
|
static TString& add_between_num_filter(TString & clause, const TString& field, const char * from_val, const char * to_val);
|
||||||
* from_val && to_val: field between
|
static TString& add_between_date_filter(TString & clause, const TString& field, const TDate & from_val, const TDate & to_val);
|
||||||
* solo from_from: field >= from_val
|
|
||||||
* solo to_from: field <= to_val */
|
|
||||||
static TString& add_between_filter(const TString& field, const TString& from_val, const TString& to_val, TString from_fld = "", TString to_fld = "");
|
|
||||||
|
|
||||||
TISAM_recordset(const char* use);
|
TISAM_recordset(const char* use);
|
||||||
TISAM_recordset(TCursor & c);
|
TISAM_recordset(TCursor & c);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user