Patch level : 12.0 no-patch
Files correlati : tsdb Commento : Prima implementazione TD_recordset per SQLAPI
This commit is contained in:
parent
0c16519027
commit
abe7dd1461
@ -76,7 +76,7 @@ void TDB_recordset::set(const char* sql)
|
||||
_sql.cut(0) << real_query;
|
||||
if (_sql.find("SELECT") >= 0 || _sql.find("select") >= 0)
|
||||
find_and_reset_vars();
|
||||
_rec.sq_set(_sql);
|
||||
_rec->sq_set(_sql);
|
||||
}
|
||||
|
||||
void TDB_recordset::set_connection(const char* conn_str)
|
||||
@ -118,7 +118,7 @@ void TDB_recordset::set_connection(const char* conn_str)
|
||||
|
||||
int TDB_recordset::connect(const char * db, const char * user, const char * pass, const TT_driver tipo_db)
|
||||
{
|
||||
return _rec.sq_connect(db, user, pass, tipo_db);
|
||||
return _rec->sq_connect(db, user, pass, tipo_db);
|
||||
}
|
||||
|
||||
TT_driver TDB_recordset::str_to_driver(const char* tipo_db)
|
||||
@ -164,30 +164,28 @@ TT_driver TDB_recordset::str_to_driver(const char* tipo_db)
|
||||
return TSDB_undefined;
|
||||
}
|
||||
|
||||
int TDB_recordset::connect(const char* db, const char* user, const char* pass, const char* tipo_db)
|
||||
int TDB_recordset::connect(const char* db, const char* user, const char* pass, const char* tipo_db) const
|
||||
{
|
||||
return _rec.sq_connect(db, user, pass, str_to_driver(tipo_db));
|
||||
return _rec->sq_connect(db, user, pass, str_to_driver(tipo_db));
|
||||
}
|
||||
|
||||
TRecnotype TDB_recordset::items() const
|
||||
{
|
||||
/*
|
||||
if(!_rec.sq_is_loaded() && _items == 0)
|
||||
{
|
||||
_rec.exec()
|
||||
}
|
||||
return static_cast<TRecnotype>(_rec.sq_items());
|
||||
return _items;
|
||||
*/
|
||||
if(!_rec->sq_is_loaded() && _items == 0)
|
||||
_rec->sq_exec();
|
||||
return _rec->sq_items();
|
||||
|
||||
}
|
||||
|
||||
bool TDB_recordset::move_to(TRecnotype pos)
|
||||
{
|
||||
return _rec.sq_go(pos);
|
||||
return _rec->sq_go(pos);
|
||||
}
|
||||
|
||||
TDB_recordset::TDB_recordset(const char* sql, bool freezed) : _freezed(freezed), _loaded(false)
|
||||
TDB_recordset::TDB_recordset(const char* sql, const bool freezed) : _freezed(freezed), _loaded(false)
|
||||
{
|
||||
set(sql);
|
||||
_rec = new SSimple_query();
|
||||
_items = 0;
|
||||
set(sql);
|
||||
}
|
||||
|
@ -72,13 +72,6 @@ protected:
|
||||
//SSimpleQuery(P_CONN_VOID &c, const char * query = "", bool ex = false);
|
||||
|
||||
public:
|
||||
/**< Costruttore, non inizializza nulla, da caricare successivamente */
|
||||
SSimple_query() = default;
|
||||
/**< Costruttore, Accetta in ingresso dei parametri per la connessione, volendo è anche possibile impostare una query ed eseguirla. Attenzione! Non risponde se la query ha avuto un esito positivo o negativo! */
|
||||
SSimple_query(const char* db, const char* user, const char* pass, const TT_driver tipo_db, const char * query = "", const bool ex = false, const bool freezed = false) : _rec(db, user, pass, tipo_db, query, ex, freezed) {}
|
||||
//SSimpleQuery(const TString& db, const TString& user, const TString& pass, TT_driver tipoDb, const char * query = "", const bool ex = false, const bool freezed = false) : _rec(db, user, pass, tipoDb, query, ex, freezed) {}
|
||||
/**< Distruttore */
|
||||
virtual ~SSimple_query() = default;
|
||||
|
||||
// Connection functions
|
||||
/**< Eseguo la connessione */
|
||||
@ -192,16 +185,24 @@ public:
|
||||
void freeze() { _rec.freeze(); }
|
||||
/**< Scongela il cursore */
|
||||
void defrost() { _rec.defrost(); }
|
||||
|
||||
/**< Costruttore, non inizializza nulla, da caricare successivamente */
|
||||
SSimple_query() = default;
|
||||
/**< Costruttore, Accetta in ingresso dei parametri per la connessione, volendo è anche possibile impostare una query ed eseguirla. Attenzione! Non risponde se la query ha avuto un esito positivo o negativo! */
|
||||
SSimple_query(const char* db, const char* user, const char* pass, const TT_driver tipo_db, const char * query = "", const bool ex = false, const bool freezed = false) : _rec(db, user, pass, tipo_db, query, ex, freezed) {}
|
||||
//SSimpleQuery(const TString& db, const TString& user, const TString& pass, TT_driver tipoDb, const char * query = "", const bool ex = false, const bool freezed = false) : _rec(db, user, pass, tipoDb, query, ex, freezed) {}
|
||||
/**< Distruttore */
|
||||
virtual ~SSimple_query() = default;
|
||||
};
|
||||
|
||||
class TDB_recordset : public TRecordset
|
||||
{
|
||||
SSimple_query _rec;
|
||||
SSimple_query * _rec;
|
||||
TString _sql;
|
||||
TString _dsn, _usr, _pwd, _drv;
|
||||
|
||||
bool _freezed, _loaded, _columns_loaded;
|
||||
TRecnotype _first_row, _pagesize, _items, _current_row;
|
||||
bool _freezed, _loaded, _columns_loaded{};
|
||||
TRecnotype _first_row{}, _pagesize{}, _items, _current_row{};
|
||||
TArray _page, _column;
|
||||
|
||||
protected:
|
||||
@ -210,7 +211,7 @@ protected:
|
||||
// Parsa la stringa di connessione contenuta nella query
|
||||
void set_connection(const char * conn_str);
|
||||
int connect(const char * db, const char * user, const char * pass, const TT_driver tipo_db);
|
||||
int connect(const char * db, const char * user, const char * pass, const char * tipo_db);
|
||||
int connect(const char * db, const char * user, const char * pass, const char * tipo_db) const;
|
||||
static TT_driver str_to_driver(const char* tipo_db);
|
||||
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user