Subject | Re: [Firebird-Java] Re: Only real types in FBDatabaseMetaData.getTypeInfo |
---|---|
Author | David Jencks |
Post date | 2002-11-18T19:07:01Z |
When I looked at this and implemented the BIGINT support, I didnt see
anything in the spec or javadocs that indicated that the Type returned from
a column should be the same as that used to get the sql to create the
column. In other words, I think the Type to db-specific sql types can be
many to one. Do you have some evidence that the spec authors intend
otherwise? I don't remember too clearly but I thought there were some
hints that the relation between Type and db-specific sql type could be
many-many.
I would think a more generally plausible algorithm for you would be to
compare the db specific sql for the Type from the column and the Type from
typeinfo and decide if they are compatible.
does your algorithm work for any other databases?
thanks
david jencks
anything in the spec or javadocs that indicated that the Type returned from
a column should be the same as that used to get the sql to create the
column. In other words, I think the Type to db-specific sql types can be
many to one. Do you have some evidence that the spec authors intend
otherwise? I don't remember too clearly but I thought there were some
hints that the relation between Type and db-specific sql type could be
many-many.
I would think a more generally plausible algorithm for you would be to
compare the db specific sql for the Type from the column and the Type from
typeinfo and decide if they are compatible.
does your algorithm work for any other databases?
thanks
david jencks
On 2002.11.18 12:05:17 -0500 sp64_asaon wrote:
> --- In Firebird-Java@y..., David Jencks <davidjencks@d...> wrote:
> > Can you please explain the problem you are having in considerably
> more
> > 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
>
>
> To unsubscribe from this group, send an email to:
> Firebird-Java-unsubscribe@yahoogroups.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
>
>