summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorOcke Janssen <Ocke.Janssen@sun.com>2009-11-11 13:30:02 +0100
committerOcke Janssen <Ocke.Janssen@sun.com>2009-11-11 13:30:02 +0100
commita5a48d4f886b52e115db553346ffe959747ff03a (patch)
tree33b17cb991c3877c85632a480222e505ebf9d014 /connectivity
parente5f5288c1398967c7a14544a22504165698010dc (diff)
#i105086# fix for clob and blob
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/commontools/FValue.cxx87
-rw-r--r--connectivity/source/commontools/dbtools.cxx103
-rw-r--r--connectivity/source/commontools/predicateinput.cxx5
3 files changed, 148 insertions, 47 deletions
diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx
index cd09efa227fe..7a85cca57738 100644
--- a/connectivity/source/commontools/FValue.cxx
+++ b/connectivity/source/commontools/FValue.cxx
@@ -254,6 +254,7 @@ void ORowSetValue::setTypeKind(sal_Int32 _eType)
case DataType::BLOB:
case DataType::CLOB:
case DataType::OBJECT:
+ case DataType::OTHER:
(*this) = getAny();
break;
default:
@@ -844,6 +845,7 @@ bool ORowSetValue::operator==(const ORowSetValue& _rRH) const
case DataType::BLOB:
case DataType::CLOB:
case DataType::OBJECT:
+ case DataType::OTHER:
bRet = false;
break;
default:
@@ -910,6 +912,7 @@ Any ORowSetValue::makeAny() const
case DataType::BLOB:
case DataType::CLOB:
case DataType::OBJECT:
+ case DataType::OTHER:
rValue = getAny();
break;
case DataType::BIT:
@@ -1016,6 +1019,19 @@ Any ORowSetValue::makeAny() const
else
aRet = ::rtl::OUString::valueOf((sal_Int64)*this);
break;
+ case DataType::CLOB:
+ {
+ Any aValue( getAny() );
+ Reference< XClob > xClob;
+ if ( aValue >>= xClob )
+ {
+ if ( xClob.is() )
+ {
+ aRet = xClob->getSubString(1,(sal_Int32)xClob->length() );
+ }
+ }
+ }
+ break;
}
}
return aRet;
@@ -1087,6 +1103,9 @@ sal_Bool ORowSetValue::getBool() const
case DataType::INTEGER:
bRet = m_bSigned ? (m_aValue.m_nInt32 != 0) : (*static_cast<sal_Int64*>(m_aValue.m_pValue) != sal_Int64(0));
break;
+ default:
+ OSL_ENSURE(0,"Illegal conversion!");
+ break;
}
}
return bRet;
@@ -1128,6 +1147,8 @@ sal_Int8 ORowSetValue::getInt8() const
case DataType::BINARY:
case DataType::VARBINARY:
case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ case DataType::CLOB:
OSL_ASSERT(!"getInt8() for this type is not allowed!");
break;
case DataType::BIT:
@@ -1152,6 +1173,9 @@ sal_Int8 ORowSetValue::getInt8() const
else
nRet = static_cast<sal_Int8>(*static_cast<sal_Int64*>(m_aValue.m_pValue));
break;
+ default:
+ OSL_ENSURE(0,"Illegal conversion!");
+ break;
}
}
return nRet;
@@ -1193,6 +1217,8 @@ sal_Int16 ORowSetValue::getInt16() const
case DataType::BINARY:
case DataType::VARBINARY:
case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ case DataType::CLOB:
OSL_ASSERT(!"getInt16() for this type is not allowed!");
break;
case DataType::BIT:
@@ -1217,6 +1243,9 @@ sal_Int16 ORowSetValue::getInt16() const
else
nRet = static_cast<sal_Int16>(*static_cast<sal_Int64*>(m_aValue.m_pValue));
break;
+ default:
+ OSL_ENSURE(0,"Illegal conversion!");
+ break;
}
}
return nRet;
@@ -1258,6 +1287,8 @@ sal_Int32 ORowSetValue::getInt32() const
case DataType::BINARY:
case DataType::VARBINARY:
case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ case DataType::CLOB:
OSL_ASSERT(!"getInt32() for this type is not allowed!");
break;
case DataType::BIT:
@@ -1282,6 +1313,9 @@ sal_Int32 ORowSetValue::getInt32() const
else
nRet = static_cast<sal_Int32>(*static_cast<sal_Int64*>(m_aValue.m_pValue));
break;
+ default:
+ OSL_ENSURE(0,"Illegal conversion!");
+ break;
}
}
return nRet;
@@ -1323,6 +1357,8 @@ sal_Int64 ORowSetValue::getLong() const
case DataType::BINARY:
case DataType::VARBINARY:
case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ case DataType::CLOB:
OSL_ASSERT(!"getInt32() for this type is not allowed!");
break;
case DataType::BIT:
@@ -1347,6 +1383,9 @@ sal_Int64 ORowSetValue::getLong() const
else
nRet = *(sal_Int64*)m_aValue.m_pValue;
break;
+ default:
+ OSL_ENSURE(0,"Illegal conversion!");
+ break;
}
}
return nRet;
@@ -1392,6 +1431,8 @@ float ORowSetValue::getFloat() const
case DataType::BINARY:
case DataType::VARBINARY:
case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ case DataType::CLOB:
OSL_ASSERT(!"getDouble() for this type is not allowed!");
break;
case DataType::BIT:
@@ -1416,6 +1457,9 @@ float ORowSetValue::getFloat() const
else
nRet = float(*(sal_Int64*)m_aValue.m_pValue);
break;
+ default:
+ OSL_ENSURE(0,"Illegal conversion!");
+ break;
}
}
return nRet;
@@ -1463,6 +1507,8 @@ double ORowSetValue::getDouble() const
case DataType::BINARY:
case DataType::VARBINARY:
case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ case DataType::CLOB:
OSL_ASSERT(!"getDouble() for this type is not allowed!");
break;
case DataType::BIT:
@@ -1487,6 +1533,9 @@ double ORowSetValue::getDouble() const
else
nRet = double(*(sal_Int64*)m_aValue.m_pValue);
break;
+ default:
+ OSL_ENSURE(0,"Illegal conversion!");
+ break;
}
}
return nRet;
@@ -1548,6 +1597,8 @@ void ORowSetValue::setFromDouble(const double& _rVal,sal_Int32 _nDatatype)
case DataType::BINARY:
case DataType::VARBINARY:
case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ case DataType::CLOB:
OSL_ASSERT(!"setFromDouble() for this type is not allowed!");
break;
case DataType::BIT:
@@ -1655,6 +1706,9 @@ Sequence<sal_Int8> ORowSetValue::getSequence() const
aValue.Year = pDateTime->Year;
}
break;
+ default:
+ OSL_ENSURE(0,"Illegal conversion!");
+ break;
}
}
return aValue;
@@ -1693,6 +1747,9 @@ Sequence<sal_Int8> ORowSetValue::getSequence() const
break;
case DataType::TIME:
aValue = *static_cast< ::com::sun::star::util::Time*>(m_aValue.m_pValue);
+ default:
+ OSL_ENSURE(0,"Illegal conversion!");
+ break;
}
}
return aValue;
@@ -1740,6 +1797,9 @@ Sequence<sal_Int8> ORowSetValue::getSequence() const
case DataType::TIMESTAMP:
aValue = *static_cast< ::com::sun::star::util::DateTime*>(m_aValue.m_pValue);
break;
+ default:
+ OSL_ENSURE(0,"Illegal conversion!");
+ break;
}
}
return aValue;
@@ -1885,13 +1945,17 @@ void ORowSetValue::fill(sal_Int32 _nPos,
(*this) = _xRow->getLong(_nPos);
break;
case DataType::CLOB:
- (*this) = ::com::sun::star::uno::makeAny(_xRow->getCharacterStream(_nPos));
+ (*this) = ::com::sun::star::uno::makeAny(_xRow->getClob(_nPos));
setTypeKind(DataType::CLOB);
break;
case DataType::BLOB:
- (*this) = ::com::sun::star::uno::makeAny(_xRow->getBinaryStream(_nPos));
+ (*this) = ::com::sun::star::uno::makeAny(_xRow->getBlob(_nPos));
setTypeKind(DataType::BLOB);
break;
+ case DataType::OTHER:
+ (*this) = _xRow->getObject(_nPos,NULL);
+ setTypeKind(DataType::OTHER);
+ break;
default:
OSL_ENSURE( false, "ORowSetValue::fill: unsupported type!" );
bReadData = false;
@@ -2037,6 +2101,25 @@ void ORowSetValue::fill(const Any& _rValue)
break;
}
+ case TypeClass_INTERFACE:
+ {
+ Reference< XClob > xClob;
+ if ( _rValue >>= xClob )
+ {
+ (*this) = _rValue;
+ setTypeKind(DataType::CLOB);
+ }
+ else
+ {
+ Reference< XBlob > xBlob;
+ if ( _rValue >>= xBlob )
+ {
+ (*this) = _rValue;
+ setTypeKind(DataType::BLOB);
+ }
+ }
+ }
+ break;
default:
OSL_ENSURE(0,"Unknown type");
diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx
index 02e6e420142f..bb088937c313 100644
--- a/connectivity/source/commontools/dbtools.cxx
+++ b/connectivity/source/commontools/dbtools.cxx
@@ -213,6 +213,7 @@ sal_Int32 getDefaultNumberFormat(sal_Int32 _nDataType,
case DataType::CHAR:
case DataType::VARCHAR:
case DataType::LONGVARCHAR:
+ case DataType::CLOB:
nFormat = _xTypes->getStandardFormat(NumberFormat::TEXT, _rLocale);
break;
case DataType::DATE:
@@ -234,10 +235,10 @@ sal_Int32 getDefaultNumberFormat(sal_Int32 _nDataType,
case DataType::STRUCT:
case DataType::ARRAY:
case DataType::BLOB:
- case DataType::CLOB:
case DataType::REF:
default:
- nFormat = NumberFormat::UNDEFINED;
+ nFormat = _xTypes->getStandardFormat(NumberFormat::UNDEFINED, _rLocale);
+ //nFormat = NumberFormat::UNDEFINED;
}
return nFormat;
}
@@ -1850,9 +1851,20 @@ void setObjectWithInfo(const Reference<XParameters>& _xParams,
sal_Int32 parameterIndex,
const Any& x,
sal_Int32 sqlType,
- sal_Int32 /*scale*/) throw(SQLException, RuntimeException)
+ sal_Int32 scale) throw(SQLException, RuntimeException)
+{
+ ORowSetValue aVal;
+ aVal.fill(x);
+ setObjectWithInfo(_xParams,parameterIndex,aVal,sqlType,scale);
+}
+// -----------------------------------------------------------------------------
+void setObjectWithInfo(const Reference<XParameters>& _xParams,
+ sal_Int32 parameterIndex,
+ const ::connectivity::ORowSetValue& _rValue,
+ sal_Int32 sqlType,
+ sal_Int32 scale) throw(SQLException, RuntimeException)
{
- if(!x.hasValue())
+ if ( _rValue.isNull() )
_xParams->setNull(parameterIndex,sqlType);
else
{
@@ -1860,65 +1872,62 @@ void setObjectWithInfo(const Reference<XParameters>& _xParams,
{
case DataType::DECIMAL:
case DataType::NUMERIC:
- _xParams->setObjectWithInfo(parameterIndex,x,sqlType,0);
+ _xParams->setObjectWithInfo(parameterIndex,_rValue.makeAny(),sqlType,scale);
break;
case DataType::CHAR:
case DataType::VARCHAR:
- //case DataType::DECIMAL:
- //case DataType::NUMERIC:
case DataType::LONGVARCHAR:
- _xParams->setString(parameterIndex,::comphelper::getString(x));
+ _xParams->setString(parameterIndex,_rValue);
break;
- case DataType::BIGINT:
+ case DataType::CLOB:
{
- sal_Int64 nValue = 0;
- if(x >>= nValue)
+ Any x(_rValue.makeAny());
+ ::rtl::OUString sValue;
+ if ( x >>= sValue )
+ _xParams->setString(parameterIndex,sValue);
+ else
{
- _xParams->setLong(parameterIndex,nValue);
- break;
+ Reference< XClob > xClob;
+ if(x >>= xClob)
+ _xParams->setClob(parameterIndex,xClob);
+ else
+ {
+ Reference< ::com::sun::star::io::XInputStream > xStream;
+ if(x >>= xStream)
+ _xParams->setCharacterStream(parameterIndex,xStream,xStream->available());
+ }
}
}
break;
+ case DataType::BIGINT:
+ if ( _rValue.isSigned() )
+ _xParams->setLong(parameterIndex,_rValue);
+ else
+ _xParams->setString(parameterIndex,_rValue);
+ break;
case DataType::FLOAT:
+ _xParams->setFloat(parameterIndex,_rValue);
+ break;
case DataType::REAL:
- {
- float nValue = 0;
- if(x >>= nValue)
- {
- _xParams->setFloat(parameterIndex,nValue);
- break;
- }
- }
- // run through if we couldn't set a float value
case DataType::DOUBLE:
- _xParams->setDouble(parameterIndex,::comphelper::getDouble(x));
+ _xParams->setDouble(parameterIndex,_rValue);
break;
case DataType::DATE:
- {
- ::com::sun::star::util::Date aValue;
- if(x >>= aValue)
- _xParams->setDate(parameterIndex,aValue);
- }
+ _xParams->setDate(parameterIndex,_rValue);
break;
case DataType::TIME:
- {
- ::com::sun::star::util::Time aValue;
- if(x >>= aValue)
- _xParams->setTime(parameterIndex,aValue);
- }
+ _xParams->setTime(parameterIndex,_rValue);
break;
case DataType::TIMESTAMP:
- {
- ::com::sun::star::util::DateTime aValue;
- if(x >>= aValue)
- _xParams->setTimestamp(parameterIndex,aValue);
- }
+ _xParams->setTimestamp(parameterIndex,_rValue);
break;
case DataType::BINARY:
case DataType::VARBINARY:
case DataType::LONGVARBINARY:
+ case DataType::BLOB:
{
+ Any x(_rValue.makeAny());
Sequence< sal_Int8> aBytes;
if(x >>= aBytes)
_xParams->setBytes(parameterIndex,aBytes);
@@ -1944,16 +1953,24 @@ void setObjectWithInfo(const Reference<XParameters>& _xParams,
break;
case DataType::BIT:
case DataType::BOOLEAN:
- _xParams->setBoolean(parameterIndex,::cppu::any2bool(x));
+ _xParams->setBoolean(parameterIndex,_rValue);
break;
- case DataType::TINYINT:
- _xParams->setByte(parameterIndex,(sal_Int8)::comphelper::getINT32(x));
+ if ( _rValue.isSigned() )
+ _xParams->setByte(parameterIndex,_rValue);
+ else
+ _xParams->setShort(parameterIndex,_rValue);
break;
case DataType::SMALLINT:
- _xParams->setShort(parameterIndex,(sal_Int16)::comphelper::getINT32(x));
+ if ( _rValue.isSigned() )
+ _xParams->setShort(parameterIndex,_rValue);
+ else
+ _xParams->setInt(parameterIndex,_rValue);
break;
case DataType::INTEGER:
- _xParams->setInt(parameterIndex,::comphelper::getINT32(x));
+ if ( _rValue.isSigned() )
+ _xParams->setInt(parameterIndex,_rValue);
+ else
+ _xParams->setLong(parameterIndex,_rValue);
break;
default:
{
diff --git a/connectivity/source/commontools/predicateinput.cxx b/connectivity/source/commontools/predicateinput.cxx
index 45e937235dd1..f5d22e2937aa 100644
--- a/connectivity/source/commontools/predicateinput.cxx
+++ b/connectivity/source/commontools/predicateinput.cxx
@@ -148,9 +148,10 @@ namespace dbtools
sal_Int32 nType = DataType::OTHER;
_rxField->getPropertyValue( ::rtl::OUString::createFromAscii( "Type" ) ) >>= nType;
- if ( ( DataType::CHAR == nType )
- || ( DataType::VARCHAR == nType )
+ if ( ( DataType::CHAR == nType )
+ || ( DataType::VARCHAR == nType )
|| ( DataType::LONGVARCHAR == nType )
+ || ( DataType::CLOB == nType )
)
{ // yes -> force a quoted text and try again
::rtl::OUString sQuoted( _rStatement );