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;
|
||||
}
|
||||
|
||||
TString& TISAM_recordset::add_between_filter(const TString& field, const TString& from_val, const TString& to_val,
|
||||
TString from_fld, TString to_fld)
|
||||
TString& TISAM_recordset::add_between_filter(TString & clause, const TString& field, const char* from_val, const char * to_val)
|
||||
{
|
||||
// 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();
|
||||
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 << ")";
|
||||
}
|
||||
TString& ret = get_tmp_string();
|
||||
|
||||
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)
|
||||
|
@ -187,12 +187,9 @@ public:
|
||||
virtual const TString& driver_version() const;
|
||||
virtual const TString& query_text() const { return _use; }
|
||||
|
||||
// Utility
|
||||
/* Ritorna un filtro che può essere:
|
||||
* from_val && to_val: field between
|
||||
* 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 = "");
|
||||
static TString& add_between_filter(TString & clause, const TString& field, const char * from_val, const char * to_val);
|
||||
static TString& add_between_num_filter(TString & clause, const TString& field, const char * from_val, const char * to_val);
|
||||
static TString& add_between_date_filter(TString & clause, const TString& field, const TDate & from_val, const TDate & to_val);
|
||||
|
||||
TISAM_recordset(const char* use);
|
||||
TISAM_recordset(TCursor & c);
|
||||
|
Loading…
x
Reference in New Issue
Block a user