Applied patch [ 1304191 ] support for MEMO fields
Francesco Montorsi git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36964 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -3572,6 +3572,8 @@ wxDbTable constructor was called.}
|
|||||||
DB_DATA_TYPE_INTEGER : non-floating point numbers
|
DB_DATA_TYPE_INTEGER : non-floating point numbers
|
||||||
DB_DATA_TYPE_FLOAT : floating point numbers
|
DB_DATA_TYPE_FLOAT : floating point numbers
|
||||||
DB_DATA_TYPE_DATE : dates
|
DB_DATA_TYPE_DATE : dates
|
||||||
|
DB_DATA_TYPE_BLOB : binary large objects
|
||||||
|
DB_DATA_TYPE_MEMO : large strings
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
\docparam{pData}{Pointer to the data object that will hold the column's
|
\docparam{pData}{Pointer to the data object that will hold the column's
|
||||||
|
@@ -158,6 +158,7 @@ const int DB_DATA_TYPE_INTEGER = 2;
|
|||||||
const int DB_DATA_TYPE_FLOAT = 3;
|
const int DB_DATA_TYPE_FLOAT = 3;
|
||||||
const int DB_DATA_TYPE_DATE = 4;
|
const int DB_DATA_TYPE_DATE = 4;
|
||||||
const int DB_DATA_TYPE_BLOB = 5;
|
const int DB_DATA_TYPE_BLOB = 5;
|
||||||
|
const int DB_DATA_TYPE_MEMO = 6;
|
||||||
|
|
||||||
const int DB_SELECT_KEYFIELDS = 1;
|
const int DB_SELECT_KEYFIELDS = 1;
|
||||||
const int DB_SELECT_WHERE = 2;
|
const int DB_SELECT_WHERE = 2;
|
||||||
@@ -555,6 +556,7 @@ private:
|
|||||||
wxDbSqlTypeInfo typeInfFloat;
|
wxDbSqlTypeInfo typeInfFloat;
|
||||||
wxDbSqlTypeInfo typeInfDate;
|
wxDbSqlTypeInfo typeInfDate;
|
||||||
wxDbSqlTypeInfo typeInfBlob;
|
wxDbSqlTypeInfo typeInfBlob;
|
||||||
|
wxDbSqlTypeInfo typeInfMemo;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -694,6 +696,7 @@ public:
|
|||||||
wxDbSqlTypeInfo GetTypeInfFloat() {return typeInfFloat;}
|
wxDbSqlTypeInfo GetTypeInfFloat() {return typeInfFloat;}
|
||||||
wxDbSqlTypeInfo GetTypeInfDate() {return typeInfDate;}
|
wxDbSqlTypeInfo GetTypeInfDate() {return typeInfDate;}
|
||||||
wxDbSqlTypeInfo GetTypeInfBlob() {return typeInfBlob;}
|
wxDbSqlTypeInfo GetTypeInfBlob() {return typeInfBlob;}
|
||||||
|
wxDbSqlTypeInfo GetTypeInfMemo() {return typeInfMemo;}
|
||||||
|
|
||||||
// tableName can refer to a table, view, alias or synonym
|
// tableName can refer to a table, view, alias or synonym
|
||||||
bool TableExists(const wxString &tableName, const wxChar *userID=NULL,
|
bool TableExists(const wxString &tableName, const wxChar *userID=NULL,
|
||||||
|
@@ -532,6 +532,12 @@ void wxDb::initialize()
|
|||||||
typeInfBlob.CaseSensitive = 0;
|
typeInfBlob.CaseSensitive = 0;
|
||||||
typeInfBlob.MaximumScale = 0;
|
typeInfBlob.MaximumScale = 0;
|
||||||
|
|
||||||
|
typeInfMemo.TypeName.Empty();
|
||||||
|
typeInfMemo.FsqlType = 0;
|
||||||
|
typeInfMemo.Precision = 0;
|
||||||
|
typeInfMemo.CaseSensitive = 0;
|
||||||
|
typeInfMemo.MaximumScale = 0;
|
||||||
|
|
||||||
// Error reporting is turned OFF by default
|
// Error reporting is turned OFF by default
|
||||||
silent = true;
|
silent = true;
|
||||||
|
|
||||||
@@ -650,6 +656,16 @@ bool wxDb::determineDataTypes(bool failOnDataTypeUnsupported)
|
|||||||
SQL_VARBINARY
|
SQL_VARBINARY
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// These are the possible SQL types we check for use agains the datasource we are connected
|
||||||
|
// to for the purpose of determining which data type to use for the MEMO column types
|
||||||
|
// (a type which allow to store large strings; like VARCHAR just with a bigger precision)
|
||||||
|
//
|
||||||
|
// NOTE: The first type in this enumeration that is determined to be supported by the
|
||||||
|
// datasource/driver is the one that will be used.
|
||||||
|
SWORD PossibleSqlMemoTypes[] = {
|
||||||
|
SQL_LONGVARCHAR,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Query the data source regarding data type information
|
// Query the data source regarding data type information
|
||||||
|
|
||||||
@@ -756,6 +772,16 @@ bool wxDb::determineDataTypes(bool failOnDataTypeUnsupported)
|
|||||||
else if (failOnDataTypeUnsupported)
|
else if (failOnDataTypeUnsupported)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// --------------- MEMO ---------------
|
||||||
|
for (iIndex = 0; iIndex < WXSIZEOF(PossibleSqlMemoTypes) &&
|
||||||
|
!getDataTypeInfo(PossibleSqlMemoTypes[iIndex], typeInfMemo); ++iIndex)
|
||||||
|
{}
|
||||||
|
|
||||||
|
if (iIndex < WXSIZEOF(PossibleSqlMemoTypes))
|
||||||
|
typeInfMemo.FsqlType = PossibleSqlMemoTypes[iIndex];
|
||||||
|
else if (failOnDataTypeUnsupported)
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} // wxDb::determineDataTypes
|
} // wxDb::determineDataTypes
|
||||||
|
|
||||||
@@ -790,6 +816,7 @@ bool wxDb::open(bool failOnDataTypeUnsupported)
|
|||||||
cout << wxT("FLOAT DATA TYPE: ") << typeInfFloat.TypeName << endl;
|
cout << wxT("FLOAT DATA TYPE: ") << typeInfFloat.TypeName << endl;
|
||||||
cout << wxT("DATE DATA TYPE: ") << typeInfDate.TypeName << endl;
|
cout << wxT("DATE DATA TYPE: ") << typeInfDate.TypeName << endl;
|
||||||
cout << wxT("BLOB DATA TYPE: ") << typeInfBlob.TypeName << endl;
|
cout << wxT("BLOB DATA TYPE: ") << typeInfBlob.TypeName << endl;
|
||||||
|
cout << wxT("MEMO DATA TYPE: ") << typeInfMemo.TypeName << endl;
|
||||||
cout << endl;
|
cout << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1050,12 +1077,20 @@ bool wxDb::Open(wxDb *copyDb)
|
|||||||
typeInfBlob.CaseSensitive = copyDb->typeInfBlob.CaseSensitive;
|
typeInfBlob.CaseSensitive = copyDb->typeInfBlob.CaseSensitive;
|
||||||
typeInfBlob.MaximumScale = copyDb->typeInfBlob.MaximumScale;
|
typeInfBlob.MaximumScale = copyDb->typeInfBlob.MaximumScale;
|
||||||
|
|
||||||
|
// Memo
|
||||||
|
typeInfMemo.FsqlType = copyDb->typeInfMemo.FsqlType;
|
||||||
|
typeInfMemo.TypeName = copyDb->typeInfMemo.TypeName;
|
||||||
|
typeInfMemo.Precision = copyDb->typeInfMemo.Precision;
|
||||||
|
typeInfMemo.CaseSensitive = copyDb->typeInfMemo.CaseSensitive;
|
||||||
|
typeInfMemo.MaximumScale = copyDb->typeInfMemo.MaximumScale;
|
||||||
|
|
||||||
#ifdef DBDEBUG_CONSOLE
|
#ifdef DBDEBUG_CONSOLE
|
||||||
cout << wxT("VARCHAR DATA TYPE: ") << typeInfVarchar.TypeName << endl;
|
cout << wxT("VARCHAR DATA TYPE: ") << typeInfVarchar.TypeName << endl;
|
||||||
cout << wxT("INTEGER DATA TYPE: ") << typeInfInteger.TypeName << endl;
|
cout << wxT("INTEGER DATA TYPE: ") << typeInfInteger.TypeName << endl;
|
||||||
cout << wxT("FLOAT DATA TYPE: ") << typeInfFloat.TypeName << endl;
|
cout << wxT("FLOAT DATA TYPE: ") << typeInfFloat.TypeName << endl;
|
||||||
cout << wxT("DATE DATA TYPE: ") << typeInfDate.TypeName << endl;
|
cout << wxT("DATE DATA TYPE: ") << typeInfDate.TypeName << endl;
|
||||||
cout << wxT("BLOB DATA TYPE: ") << typeInfBlob.TypeName << endl;
|
cout << wxT("BLOB DATA TYPE: ") << typeInfBlob.TypeName << endl;
|
||||||
|
cout << wxT("MEMO DATA TYPE: ") << typeInfMemo.TypeName << endl;
|
||||||
cout << endl;
|
cout << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -2286,6 +2321,9 @@ bool wxDb::ExecSql(const wxString &pSqlStmt, wxDbColInf** columns, short& numcol
|
|||||||
case SQL_CHAR:
|
case SQL_CHAR:
|
||||||
pColInf[colNum].dbDataType = DB_DATA_TYPE_VARCHAR;
|
pColInf[colNum].dbDataType = DB_DATA_TYPE_VARCHAR;
|
||||||
break;
|
break;
|
||||||
|
case SQL_LONGVARCHAR:
|
||||||
|
pColInf[colNum].dbDataType = DB_DATA_TYPE_MEMO;
|
||||||
|
break;
|
||||||
case SQL_TINYINT:
|
case SQL_TINYINT:
|
||||||
case SQL_SMALLINT:
|
case SQL_SMALLINT:
|
||||||
case SQL_INTEGER:
|
case SQL_INTEGER:
|
||||||
@@ -3069,6 +3107,9 @@ wxDbColInf *wxDb::GetColumns(const wxString &tableName, int *numCols, const wxCh
|
|||||||
case SQL_CHAR:
|
case SQL_CHAR:
|
||||||
colInf[colNo].dbDataType = DB_DATA_TYPE_VARCHAR;
|
colInf[colNo].dbDataType = DB_DATA_TYPE_VARCHAR;
|
||||||
break;
|
break;
|
||||||
|
case SQL_LONGVARCHAR:
|
||||||
|
colInf[colNo].dbDataType = DB_DATA_TYPE_MEMO;
|
||||||
|
break;
|
||||||
case SQL_TINYINT:
|
case SQL_TINYINT:
|
||||||
case SQL_SMALLINT:
|
case SQL_SMALLINT:
|
||||||
case SQL_INTEGER:
|
case SQL_INTEGER:
|
||||||
|
@@ -413,11 +413,13 @@ void wxDbTable::setCbValueForColumn(int columnIndex)
|
|||||||
switch(colDefs[columnIndex].DbDataType)
|
switch(colDefs[columnIndex].DbDataType)
|
||||||
{
|
{
|
||||||
case DB_DATA_TYPE_VARCHAR:
|
case DB_DATA_TYPE_VARCHAR:
|
||||||
|
case DB_DATA_TYPE_MEMO:
|
||||||
if (colDefs[columnIndex].Null)
|
if (colDefs[columnIndex].Null)
|
||||||
colDefs[columnIndex].CbValue = SQL_NULL_DATA;
|
colDefs[columnIndex].CbValue = SQL_NULL_DATA;
|
||||||
else
|
else
|
||||||
colDefs[columnIndex].CbValue = SQL_NTS;
|
colDefs[columnIndex].CbValue = SQL_NTS;
|
||||||
break;
|
break;
|
||||||
|
break;
|
||||||
case DB_DATA_TYPE_INTEGER:
|
case DB_DATA_TYPE_INTEGER:
|
||||||
if (colDefs[columnIndex].Null)
|
if (colDefs[columnIndex].Null)
|
||||||
colDefs[columnIndex].CbValue = SQL_NULL_DATA;
|
colDefs[columnIndex].CbValue = SQL_NULL_DATA;
|
||||||
@@ -484,6 +486,11 @@ bool wxDbTable::bindParams(bool forUpdate)
|
|||||||
precision = colDefs[i].SzDataObj;
|
precision = colDefs[i].SzDataObj;
|
||||||
scale = 0;
|
scale = 0;
|
||||||
break;
|
break;
|
||||||
|
case DB_DATA_TYPE_MEMO:
|
||||||
|
fSqlType = pDb->GetTypeInfMemo().FsqlType;
|
||||||
|
precision = colDefs[i].SzDataObj;
|
||||||
|
scale = 0;
|
||||||
|
break;
|
||||||
case DB_DATA_TYPE_INTEGER:
|
case DB_DATA_TYPE_INTEGER:
|
||||||
fSqlType = pDb->GetTypeInfInteger().FsqlType;
|
fSqlType = pDb->GetTypeInfInteger().FsqlType;
|
||||||
precision = pDb->GetTypeInfInteger().Precision;
|
precision = pDb->GetTypeInfInteger().Precision;
|
||||||
@@ -1414,6 +1421,9 @@ bool wxDbTable::CreateTable(bool attemptDrop)
|
|||||||
case DB_DATA_TYPE_VARCHAR:
|
case DB_DATA_TYPE_VARCHAR:
|
||||||
cout << pDb->GetTypeInfVarchar().TypeName << wxT("(") << (int)(colDefs[i].SzDataObj / sizeof(wxChar)) << wxT(")");
|
cout << pDb->GetTypeInfVarchar().TypeName << wxT("(") << (int)(colDefs[i].SzDataObj / sizeof(wxChar)) << wxT(")");
|
||||||
break;
|
break;
|
||||||
|
case DB_DATA_TYPE_MEMO:
|
||||||
|
cout << pDb->GetTypeInfMemo().TypeName;
|
||||||
|
break;
|
||||||
case DB_DATA_TYPE_INTEGER:
|
case DB_DATA_TYPE_INTEGER:
|
||||||
cout << pDb->GetTypeInfInteger().TypeName;
|
cout << pDb->GetTypeInfInteger().TypeName;
|
||||||
break;
|
break;
|
||||||
@@ -1455,6 +1465,9 @@ bool wxDbTable::CreateTable(bool attemptDrop)
|
|||||||
case DB_DATA_TYPE_VARCHAR:
|
case DB_DATA_TYPE_VARCHAR:
|
||||||
sqlStmt += pDb->GetTypeInfVarchar().TypeName;
|
sqlStmt += pDb->GetTypeInfVarchar().TypeName;
|
||||||
break;
|
break;
|
||||||
|
case DB_DATA_TYPE_MEMO:
|
||||||
|
sqlStmt += pDb->GetTypeInfMemo().TypeName;
|
||||||
|
break;
|
||||||
case DB_DATA_TYPE_INTEGER:
|
case DB_DATA_TYPE_INTEGER:
|
||||||
sqlStmt += pDb->GetTypeInfInteger().TypeName;
|
sqlStmt += pDb->GetTypeInfInteger().TypeName;
|
||||||
break;
|
break;
|
||||||
@@ -2349,6 +2362,11 @@ wxDbColDataPtr* wxDbTable::SetColDefs(wxDbColInf *pColInfs, UWORD numCols)
|
|||||||
pColDataPtrs[index].SzDataObj = pColInfs[index].bufferSize+(1*sizeof(wxChar));
|
pColDataPtrs[index].SzDataObj = pColInfs[index].bufferSize+(1*sizeof(wxChar));
|
||||||
pColDataPtrs[index].SqlCtype = SQL_C_WXCHAR;
|
pColDataPtrs[index].SqlCtype = SQL_C_WXCHAR;
|
||||||
break;
|
break;
|
||||||
|
case DB_DATA_TYPE_MEMO:
|
||||||
|
pColDataPtrs[index].PtrDataObj = new wxChar[pColInfs[index].bufferSize+(1*sizeof(wxChar))];
|
||||||
|
pColDataPtrs[index].SzDataObj = pColInfs[index].bufferSize+(1*sizeof(wxChar));
|
||||||
|
pColDataPtrs[index].SqlCtype = SQL_C_WXCHAR;
|
||||||
|
break;
|
||||||
case DB_DATA_TYPE_INTEGER:
|
case DB_DATA_TYPE_INTEGER:
|
||||||
// Can be long or short
|
// Can be long or short
|
||||||
if (pColInfs[index].bufferSize == sizeof(long))
|
if (pColInfs[index].bufferSize == sizeof(long))
|
||||||
|
Reference in New Issue
Block a user