Subject | Re: Only real types in FBDatabaseMetaData.getTypeInfo |
---|---|
Author | sp64_asaon |
Post date | 2002-11-18T17:05:17Z |
--- In Firebird-Java@y..., David Jencks <davidjencks@d...> wrote:
// Returns database specific info about the given data type.
MyTypeInfo MyMetaData.getTypeInfo(int type);
// Returns info about the most matching data type
// supported by the underlying database
MyTypeInfo MyMetaData.getSupportedType(int type) {
MyTypeInfo ti = null;
switch (type) {
...
case Types.BIGINT:
if ((ti = getTypeInfo(Types.BIGINT) == null)
if ((ti = getTypeInfo(Types.DOUBLE) == null)
ti = getTypeInfo(Types.INTEGER);
break;
...
}
return ti;
}
// Update-Strategy:
columnType = X; // retrieved from getColumnns
desiredType = Types.BIGINT;
supportedType = myMetaData.getSupportedType(desiredType);
boolean haveToUpdate = columnType != supportedType
// and other criteria depending on the data type:
// || columnSize < neededSize
// || ...
Example with your changes:
columnType = Types.NUMERIC;
desiredType = Types.BIGINT;
supportedType = Types.BIGINT;
haveToUpdate = true;
// columnType will never match the 'erroneosly'
// reported supported type ==> repeated updates
Example without your type entry for BIGINT:
columnType = Types.DOUBLE;
desiredType = Types.BIGINT;
supportedType = Types.DOUBLE;
haveToUpdate = false;
// columnType matches the mapped supported type
Best regards
Stephan
> Can you please explain the problem you are having in considerablymore
> detail?I would like to explain it on the hand of a pseudo code extraction:
// Returns database specific info about the given data type.
MyTypeInfo MyMetaData.getTypeInfo(int type);
// Returns info about the most matching data type
// supported by the underlying database
MyTypeInfo MyMetaData.getSupportedType(int type) {
MyTypeInfo ti = null;
switch (type) {
...
case Types.BIGINT:
if ((ti = getTypeInfo(Types.BIGINT) == null)
if ((ti = getTypeInfo(Types.DOUBLE) == null)
ti = getTypeInfo(Types.INTEGER);
break;
...
}
return ti;
}
// Update-Strategy:
columnType = X; // retrieved from getColumnns
desiredType = Types.BIGINT;
supportedType = myMetaData.getSupportedType(desiredType);
boolean haveToUpdate = columnType != supportedType
// and other criteria depending on the data type:
// || columnSize < neededSize
// || ...
Example with your changes:
columnType = Types.NUMERIC;
desiredType = Types.BIGINT;
supportedType = Types.BIGINT;
haveToUpdate = true;
// columnType will never match the 'erroneosly'
// reported supported type ==> repeated updates
Example without your type entry for BIGINT:
columnType = Types.DOUBLE;
desiredType = Types.BIGINT;
supportedType = Types.DOUBLE;
haveToUpdate = false;
// columnType matches the mapped supported type
Best regards
Stephan