Patch level : 12.0 1220
Files correlati : fp0.exe Correzione errore su fatturazione elettronica. la funzione search() si era rotta. nella specifico la funzione di libreria sq_set_exec() ritornava true anche quando la query non resitituiva nessun recordset. questo comprometteva la funzionalita della funzione search()
This commit is contained in:
parent
f0bba3fd67
commit
6158d6a05a
@ -595,13 +595,7 @@ bool TPaf_record::search()
|
|||||||
query << ";";
|
query << ";";
|
||||||
// return xvt_sql_execute(_db, query, paf_search_record, this) == 1;
|
// return xvt_sql_execute(_db, query, paf_search_record, this) == 1;
|
||||||
// TODO: Valutare
|
// TODO: Valutare
|
||||||
bool exec_query = fp_db().sq_set_exec(query);
|
return fp_db().sq_set_exec(query);
|
||||||
int items = fp_db().sq_items();
|
|
||||||
|
|
||||||
if (items > 0)
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Carica un record in base ad un massimo di 3 campi chiave
|
// Carica un record in base ad un massimo di 3 campi chiave
|
||||||
|
@ -7,58 +7,32 @@
|
|||||||
* Classe per esecuzioni di query temporanee (wrapper semplice per SACommand) *
|
* Classe per esecuzioni di query temporanee (wrapper semplice per SACommand) *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
const bool SSimple_query::sq_set_exec(const char* query, const bool auto_f)
|
|
||||||
{
|
|
||||||
bool ok = false;
|
|
||||||
|
|
||||||
if (sq_is_connect())
|
|
||||||
{
|
|
||||||
ok = _rec.set(query);
|
|
||||||
if (ok)
|
|
||||||
_rec.exec(auto_f);
|
|
||||||
}
|
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
const TDate SSimple_query::sq_get_date(const char * field)
|
const TDate SSimple_query::sq_get_date(const char * field)
|
||||||
{
|
{
|
||||||
TDate date;
|
TDate date(_rec.get_date(field));
|
||||||
|
if (!date.ok() || date == 19000100)
|
||||||
if (sq_is_connect())
|
|
||||||
{
|
{
|
||||||
date = _rec.get_date(field);
|
TString dt_str = _rec.get(field);
|
||||||
|
if (dt_str.len() > 10)
|
||||||
if (!date.ok() || date == 19000100)
|
dt_str = dt_str.left(10);
|
||||||
{
|
date = dt_str;
|
||||||
TString dt_str = _rec.get(field);
|
|
||||||
|
|
||||||
if (dt_str.len() > 10)
|
|
||||||
dt_str = dt_str.left(10);
|
|
||||||
date = dt_str;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
|
|
||||||
const real SSimple_query::sq_get_real(const char * field)
|
const real SSimple_query::sq_get_real(const char * field)
|
||||||
{
|
{
|
||||||
real r;
|
const real app(_rec.get(field));
|
||||||
|
return app;
|
||||||
if (sq_is_connect())
|
|
||||||
r = _rec.get(field);
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const TString & SSimple_query::sq_get(const char* field, const bool rtrim)
|
const TString & SSimple_query::sq_get(const char* field, const bool rtrim)
|
||||||
{
|
{
|
||||||
TString & fld = get_tmp_string(1024);
|
TString & fld = get_tmp_string(1024);
|
||||||
|
|
||||||
if (sq_is_connect())
|
fld = _rec.get(field);
|
||||||
{
|
if (rtrim)
|
||||||
fld = _rec.get(field);
|
fld.rtrim();
|
||||||
if (rtrim)
|
|
||||||
fld.rtrim();
|
|
||||||
}
|
|
||||||
|
|
||||||
return fld;
|
return fld;
|
||||||
}
|
}
|
||||||
@ -75,28 +49,25 @@ const TString & SSimple_query::sq_get(TString& field, const bool rtrim)
|
|||||||
|
|
||||||
const TString & SSimple_query::sq_get(unsigned int column, const bool rtrim)
|
const TString & SSimple_query::sq_get(unsigned int column, const bool rtrim)
|
||||||
{
|
{
|
||||||
TString & val = get_tmp_string(1024);
|
TString & val = get_tmp_string(1024);
|
||||||
|
|
||||||
if (sq_is_connect())
|
val << _rec.get(column);
|
||||||
{
|
if (rtrim)
|
||||||
val << _rec.get(column);
|
val.rtrim();
|
||||||
if (rtrim)
|
|
||||||
val.rtrim();
|
|
||||||
}
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned SSimple_query::sq_get_num_fields() const
|
unsigned SSimple_query::sq_get_num_fields() const
|
||||||
{
|
{
|
||||||
return sq_is_connect() ? _rec.get_num_fields() : 0;
|
return _rec.get_num_fields();
|
||||||
}
|
}
|
||||||
|
|
||||||
const TString & SSimple_query::sq_get_name_field(const unsigned column) const
|
const TString & SSimple_query::sq_get_name_field(const unsigned column) const
|
||||||
{
|
{
|
||||||
TString & name = get_tmp_string();
|
TString & name = get_tmp_string();
|
||||||
|
|
||||||
name = _rec.get_name_field(column);
|
name = _rec.get_name_field(column);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SSimple_query::sq_get_width_field(const unsigned column) const
|
int SSimple_query::sq_get_width_field(const unsigned column) const
|
||||||
@ -114,8 +85,8 @@ TFieldtypes SSimple_query::sq_get_type_field(const unsigned column) const
|
|||||||
return _boolfld;
|
return _boolfld;
|
||||||
if (type == "dtShort")
|
if (type == "dtShort")
|
||||||
return _intfld;
|
return _intfld;
|
||||||
if (type == "dtLong")
|
if (type == "dtLong")
|
||||||
return _longfld;
|
return _longfld;
|
||||||
if (type == "dtULong")
|
if (type == "dtULong")
|
||||||
return _longfld;
|
return _longfld;
|
||||||
if (type == "dtDouble")
|
if (type == "dtDouble")
|
||||||
|
@ -1,3 +1,30 @@
|
|||||||
|
/**********************************************************************************
|
||||||
|
* ######\ *
|
||||||
|
* ## __##\ *
|
||||||
|
* ## / \__| ######\ ######\####\ ######\ ######\ *
|
||||||
|
* ## | \____##\ ## _## _##\ ## __##\ ## __##\ *
|
||||||
|
* ## | ####### |## / ## / ## |## / ## |## / ## | *
|
||||||
|
* ## | ##\ ## __## |## | ## | ## |## | ## |## | ## | *
|
||||||
|
* \###### |\####### |## | ## | ## |####### |\###### | *
|
||||||
|
* \______/ \_______|\__| \__| \__|## ____/ \______/ *
|
||||||
|
* ## | *
|
||||||
|
* ## | *
|
||||||
|
* \__| *
|
||||||
|
**********************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/********************************************************************************************************************************
|
||||||
|
* TSDB.H *
|
||||||
|
* Inizio sviluppo: 13.10.2016 *
|
||||||
|
* Autore: Tolla *
|
||||||
|
* Descrizione: *
|
||||||
|
* La seguente libreria ha due scopi: *
|
||||||
|
* - Implementare una serie di funzioni che emulino interamente il funzionamento attuale di campo in Visual FoxPro su MSQL *
|
||||||
|
* - Creare delle nuove API per gestire il database in MSSQL con cui verranno riscritti i programmi *
|
||||||
|
* Librerie esterne utilizzate: *
|
||||||
|
* - SQLAPI++ (Permette la gestione dei più famosi DB attualmente esistenti) *
|
||||||
|
********************************************************************************************************************************/
|
||||||
|
|
||||||
#ifndef __TSDB_H
|
#ifndef __TSDB_H
|
||||||
#define __TSDB_H
|
#define __TSDB_H
|
||||||
|
|
||||||
@ -6,7 +33,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Tolla tools
|
// Tolla tools
|
||||||
#ifndef __TTOOLS_H
|
#ifndef __TTOOLS_H
|
||||||
#include <ttools.h>
|
#include <ttools.h>
|
||||||
#endif
|
#endif
|
||||||
@ -24,6 +51,12 @@
|
|||||||
|
|
||||||
#include "recset.h"
|
#include "recset.h"
|
||||||
|
|
||||||
|
/********************************************************************************
|
||||||
|
* SSimpleQuery (Sirio Simple Query) *
|
||||||
|
* "Wrapper" di TXvt_recordset, implementa OGNI funzione in modo tale da *
|
||||||
|
* poterlo sostituire brutalmente in qualsiasi momento così da non aver *
|
||||||
|
* problemi come durante il passaggio da ISAM a SQL (spero). che cazzata da riscrivere *
|
||||||
|
********************************************************************************/
|
||||||
class SSimple_query
|
class SSimple_query
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
@ -75,44 +108,44 @@ public:
|
|||||||
|
|
||||||
// Configuration
|
// Configuration
|
||||||
/**< Imposta la query ricevuta come (const char *) nel recordset */
|
/**< Imposta la query ricevuta come (const char *) nel recordset */
|
||||||
const bool sq_set(const char* query) { return sq_is_connect() && _rec.set(query); }
|
const bool sq_set(const char* query) { return _rec.set(query); }
|
||||||
/**< Imposta la query ricevuta come (string) nel recordset */
|
/**< Imposta la query ricevuta come (string) nel recordset */
|
||||||
const bool sq_set(const string& query) { return sq_is_connect() && _rec.set(query.c_str()); }
|
const bool sq_set(const string& query) { return _rec.set(query.c_str()); }
|
||||||
/**< Imposta la query ricevuta come (TString) nel recordset */
|
/**< Imposta la query ricevuta come (TString) nel recordset */
|
||||||
const bool sq_set(TString& query) { return sq_is_connect() && _rec.set(static_cast<const char *>(query)); }
|
const bool sq_set(TString& query) { return _rec.set(static_cast<const char *>(query)); }
|
||||||
/**< Esegue la query impostata nel recordset, se viene passato autoF == true esegue anche un comando sqNext() */
|
/**< Esegue la query impostata nel recordset, se viene passato autoF == true esegue anche un comando sqNext() */
|
||||||
const bool sq_exec(bool autoF = true) { return sq_is_connect() && _rec.exec(autoF); }
|
const bool sq_exec(bool autoF = true) { return _rec.exec(autoF); }
|
||||||
/**< Unisce le funzioni sqSet e sqExec, riceve la query come (const char *) */
|
/**< Unisce le funzioni sqSet e sqExec, riceve la query come (const char *) */
|
||||||
const bool sq_set_exec(const char* query, const bool auto_f = true);
|
const bool sq_set_exec(const char* query, const bool auto_f = true) { _rec.set(query); return _rec.exec(auto_f); }
|
||||||
/**< Unisce le funzioni sqSet e sqExec, riceve la query come (string) */
|
/**< Unisce le funzioni sqSet e sqExec, riceve la query come (string) */
|
||||||
const bool sq_set_exec(const string& query, const bool auto_f = true) { _rec.set(query.c_str()); return _rec.exec(auto_f); }
|
const bool sq_set_exec(const string& query, const bool auto_f = true) { _rec.set(query.c_str()); return _rec.exec(auto_f); }
|
||||||
/**< Unisce le funzioni sqSet e sqExec, riceve la query come (TString) */
|
/**< Unisce le funzioni sqSet e sqExec, riceve la query come (TString) */
|
||||||
const bool sq_set_exec(TString& query, const bool auto_f = true) { return sq_set_exec(static_cast<const char*>(query), auto_f); }
|
const bool sq_set_exec(TString& query, const bool auto_f = true) { return sq_set_exec(static_cast<const char*>(query), auto_f); }
|
||||||
/**< Si sposta avanti di un record, in caso di esito negativo valorizza _stringError e _codeError */
|
/**< Si sposta avanti di un record, in caso di esito negativo valorizza _stringError e _codeError */
|
||||||
const bool sq_next() { return sq_is_connect() && _rec.next(); }
|
const bool sq_next() { return _rec.next(); }
|
||||||
/**< Si sposta indietro di un record, in caso di esito negativo valorizza _stringError e _codeError */
|
/**< Si sposta indietro di un record, in caso di esito negativo valorizza _stringError e _codeError */
|
||||||
const bool sq_prev() { return sq_is_connect() && _rec.prev(); }
|
const bool sq_prev() { return _rec.prev(); }
|
||||||
/**< Si sposta al primo record, in caso di esito negativo valorizza _stringError e _codeError */
|
/**< Si sposta al primo record, in caso di esito negativo valorizza _stringError e _codeError */
|
||||||
const bool sq_first() { return sq_is_connect() && _rec.first(); }
|
const bool sq_first() { return _rec.first(); }
|
||||||
/**< Si sposta all'ultimo record, in caso di esito negativo valorizza _stringError e _codeError */
|
/**< Si sposta all'ultimo record, in caso di esito negativo valorizza _stringError e _codeError */
|
||||||
const bool sq_last() { return sq_is_connect() && _rec.last(); }
|
const bool sq_last() { return _rec.last(); }
|
||||||
/**< Si sposta alla posizione n, in caso di esito negativo valorizza _stringError e _codeError */
|
/**< Si sposta alla posizione n, in caso di esito negativo valorizza _stringError e _codeError */
|
||||||
const bool sq_go(const int new_pos) { return sq_is_connect() && _rec.go(new_pos); }
|
const bool sq_go(const int new_pos) { return _rec.go(new_pos); }
|
||||||
/**< Ritorna il numero di righe affette dall'ultima query */
|
/**< Ritorna il numero di righe affette dall'ultima query */
|
||||||
const int sq_rows_affected() const { return sq_is_connect() ? _rec.rows_affected() : 0; }
|
const int sq_rows_affected() const { return _rec.rows_affected(); }
|
||||||
|
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
/**< Ritorna il valore nel campo (field) in formato (int) */
|
/**< Ritorna il valore nel campo (field) in formato (int) */
|
||||||
const int sq_get_int(const char* field) { return sq_is_connect() ? _rec.get_int(field) : 0; }
|
const int sq_get_int(const char* field) { return _rec.get_int(field); }
|
||||||
/**< Ritorna il valore nel campo (field) in formato (short) */
|
/**< Ritorna il valore nel campo (field) in formato (short) */
|
||||||
const short sq_get_short(const char* field) { return sq_is_connect() ? _rec.get_short(field) : 0; }
|
const short sq_get_short(const char* field) { return _rec.get_short(field); }
|
||||||
/**< Ritorna il valore nel campo (field) in formato (long) */
|
/**< Ritorna il valore nel campo (field) in formato (long) */
|
||||||
const long sq_get_long(const char* field) { return sq_is_connect() ? _rec.get_long(field) : 0L; }
|
const long sq_get_long(const char* field) { return _rec.get_long(field); }
|
||||||
/**< Ritorna il valore nel campo (field) in formato (double) */
|
/**< Ritorna il valore nel campo (field) in formato (double) */
|
||||||
const double sq_get_double(const char* field) { return sq_is_connect() ? _rec.get_double(field) : 0.0; }
|
const double sq_get_double(const char* field) { return _rec.get_double(field); }
|
||||||
/**< Ritorna il valore nel campo (field) in formato (bool) */
|
/**< Ritorna il valore nel campo (field) in formato (bool) */
|
||||||
const bool sq_get_bool(const char* field) { return sq_is_connect() && _rec.get_bool(field); }
|
const bool sq_get_bool(const char* field) { return _rec.get_bool(field); }
|
||||||
/**< Ritorna il valore nel campo (field) in formato (TDate) */
|
/**< Ritorna il valore nel campo (field) in formato (TDate) */
|
||||||
const TDate sq_get_date(const char* field);
|
const TDate sq_get_date(const char* field);
|
||||||
/**< Ritorna il valore nel campo (field) in formato (real) */
|
/**< Ritorna il valore nel campo (field) in formato (real) */
|
||||||
@ -125,10 +158,10 @@ public:
|
|||||||
const TString & sq_get(const string& field, bool rtrim = true);
|
const TString & sq_get(const string& field, bool rtrim = true);
|
||||||
/**< Ritorna il valore nel campo (field) passato come (TString) in formato (const char *) */
|
/**< Ritorna il valore nel campo (field) passato come (TString) in formato (const char *) */
|
||||||
const TString & sq_get(TString& field, bool rtrim = true);
|
const TString & sq_get(TString& field, bool rtrim = true);
|
||||||
/**< Ritorna il valore della colonna numero (column) passato come (unsigned int) */
|
/**< Ritorna il valore della colonna numero (column) passato come (unsigned int) */
|
||||||
const TString & sq_get(unsigned int column, bool rtrim = true);
|
const TString & sq_get(unsigned int column, bool rtrim = true);
|
||||||
/**< Ritorna il valore nel campo (field) in formato (char) */
|
/**< Ritorna il valore nel campo (field) in formato (char) */
|
||||||
const char sq_get_char(const char* field) { return sq_is_connect() && _rec.get_char(field); }
|
const char sq_get_char(const char* field) { return _rec.get_char(field); }
|
||||||
/**< Ritorna il numero di campi dopo l'ultimo comando di esecuzione effettuato; se il risultato esiste */
|
/**< Ritorna il numero di campi dopo l'ultimo comando di esecuzione effettuato; se il risultato esiste */
|
||||||
unsigned int sq_get_num_fields() const;
|
unsigned int sq_get_num_fields() const;
|
||||||
/**< Ritorna il nome del campo numero (column) in formato (TString) = */
|
/**< Ritorna il nome del campo numero (column) in formato (TString) = */
|
||||||
@ -138,7 +171,7 @@ public:
|
|||||||
/**< Ritorna il tipo del campo numero (column) in formato (TFieldtypes) */
|
/**< Ritorna il tipo del campo numero (column) in formato (TFieldtypes) */
|
||||||
TFieldtypes sq_get_type_field(unsigned column) const;
|
TFieldtypes sq_get_type_field(unsigned column) const;
|
||||||
/**< Ritorna la posizione attuale */
|
/**< Ritorna la posizione attuale */
|
||||||
const long sq_pos() const { return sq_is_connect() ? _rec.pos() : 0; }
|
const long sq_pos() const { return _rec.pos(); }
|
||||||
|
|
||||||
// Error Getters
|
// Error Getters
|
||||||
/**< Ritorno l'ultimo codice errore segnalato in formato /int) */
|
/**< Ritorno l'ultimo codice errore segnalato in formato /int) */
|
||||||
@ -158,12 +191,12 @@ public:
|
|||||||
void defrost() { _rec.defrost(); }
|
void defrost() { _rec.defrost(); }
|
||||||
|
|
||||||
/**< Costruttore, non inizializza nulla, da caricare successivamente */
|
/**< Costruttore, non inizializza nulla, da caricare successivamente */
|
||||||
SSimple_query() {};
|
SSimple_query() {};
|
||||||
/**< 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! */
|
/**< 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) {}
|
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) {}
|
//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 */
|
/**< Distruttore */
|
||||||
virtual ~SSimple_query() {};
|
virtual ~SSimple_query() {};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
x
Reference in New Issue
Block a user