TRIM returns VARCHAR. Even if you have TO_CHAR UDF (e.g. TD14), there is no specific function prototype for TO_CHAR that accepts VARCHAR arguments. So remove TRIM and pass the numeric value returned by EXTRACT.
Again, it is working in SQL Assistant only because the SQL you typed is not the SQL that is being sent to the database by the ODBC driver. Try it in BTEQ or in SQL Assistant with .NET provider and it will fail just as it does in the SP.
↧