Thank you. Here is what I got
(r._2(0)(0)) match
{
case a: Number if a.longValue <= Integer.MAX_VALUE && a.longValue
>= Integer.MIN_VALUE => a.intValue
case _ => a.longValue
}
or I can do a simple cast (r._2(0)(0)).asInstanceOf[Number].intValue
since in this case I know what the return value of function should be.
If you were thinking of something else then I'd love to see your
example.
On May 11, 9:29 am, David Pollak <
feeder.of.the.be...@gmail.com>
wrote:
> The conversion from the ResultSet to each column type is done here:
>
> private def asAny(pos: Int, rs: ResultSet, md: ResultSetMetaData): Any = {
> import java.sql.Types._
> md.getColumnType(pos) match {
> case ARRAY | BINARY | BLOB | DATALINK | DISTINCT | JAVA_OBJECT |
> LONGVARBINARY | NULL | OTHER | REF | STRUCT | VARBINARY => rs.getObject(pos)
>
> case DECIMAL | NUMERIC => rs.getBigDecimal(pos)
>
> case BIGINT | INTEGER | /* DECIMAL | NUMERIC | */ SMALLINT | TINYINT
> => rs.getLong(pos)
>
> case BIT | BOOLEAN => rs.getBoolean(pos)
>
> case VARCHAR | CHAR | CLOB | LONGVARCHAR => rs.getString(pos)
>
> case DATE | TIME | TIMESTAMP => rs.getTimestamp(pos)
>
> case DOUBLE | FLOAT | REAL => rs.getDouble(pos)
> }
> }
>
> So all Integerish numbers are treated as Long.
>
> Two things I'd suggest:
>
> 1. Use pattern matching to extract values from Any rather than using
> explicit casts (if you need an example, please let me know)
> 2. Match expected numbers to java.lang.Number and then do a longValue or
> Simply Lifthttp://
simply.liftweb.net