0

This question it to some extend inspired by Retrieving Data From Returned Oracle Timestamp Column

I query my Oracle database like

<cfquery name="getstuff" ...>
  SELECT timestampfld
  FROM myTable
</cfquery>

The column is of type timestamp and is returned as oracle.sql.TIMESTAMP. A call to

<cfdump var="#timestampfld#">

displays that the class is supposed to have a function timestampValue() that takes no arguments. However, when I call

<cfdump var="#timestampfld.timestampValue()#">

I'm presented with an exception

Either there are no methods with the specified method name and argument types or the timestampValue method is overloaded with argument types that ColdFusion cannot decipher reliably. ColdFusion found 0 methods that match the provided arguments. If this is a Java object and you verified that the method exists, use the javacast function to reduce ambiguity.

How can I call the method timestampValue() on my column?

EDIT

When I CFDUMP the oracle.sql.TIMESTAMP I see the followig picture which says there is a timestampValue() method. CFDUMP of oracle.sql.TIMESTAMP

Also, when I look into the Oracle Thin driver JAR file using a Java Decompiler I see the signature of the method

Java Decompiler

Bernhard Döbler
  • 1,960
  • 2
  • 25
  • 39
  • 1
    AFAIK there is no `timestampValue()` method in either Oracle or CFML. Whenever I want to get the value of the timestamp field from an Oracle select, I typically use the `to_char()` Oracle function. For example `SELECT to_char(timestampfld, 'MM-DD-YYYY HH24:MI:SS') FROM myTable`. – user12031119 Feb 16 '21 at 20:53

1 Answers1

0

As so many times in the ColdFusion world: Ben Nadel to the rescue.

I already tried to call timestampValue() using the CFINVOKE tag like

<cfinvoke component="#timestampfld#" method="timestampValue" returnvariable="ts"></cfinvoke>

but was presented with an exception

The component attribute can either be a string (component name) or a component object

The component attribute in cfinvoke tag has invalid value.

Said blog describes how to use the function instead of the tag:

fortunately, invoke() works with any non-String Java object where the invoke() signature is disambiguated

This made me write the following code, which actually outputs a nicely formatted date

#dateTimeFormat( invoke( timestampfld, "timestampValue" ), "dd.mm.yyyy HH:nn:ss.L" )#
Bernhard Döbler
  • 1,960
  • 2
  • 25
  • 39