Patch level : 12.0 no-patch
Files correlati : include Commento : Aggiunta funzione TISAM_recordset::add_between_filter() che passato nome campo, from_val e to_val restituisce between, >= o <= in CampoSQL
This commit is contained in:
parent
18f4c6985c
commit
3260e84ab5
@ -1652,6 +1652,36 @@ 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)
|
||||
{
|
||||
// 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 << ")";
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
TISAM_recordset::TISAM_recordset(const char* use)
|
||||
: _relation(NULL), _cursor(NULL)
|
||||
{
|
||||
|
@ -167,6 +167,13 @@ 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 = "");
|
||||
|
||||
TISAM_recordset(const char* use);
|
||||
virtual ~TISAM_recordset();
|
||||
};
|
||||
@ -181,5 +188,4 @@ const TString& logic2table(int logic_num);
|
||||
int table2logic(const TString& name);
|
||||
TRecordset* create_recordset(const TString& sql);
|
||||
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user