Skip to main content
Inspiring
July 1, 2011
Question

Problem with query result in session variable

  • July 1, 2011
  • 1 reply
  • 1493 views

Hi,

I put a query result into a session variable.

The result set contains values like "001", but when I dumped the session variable it becomes the value  "1" (numeric).

In the database it is a varchar2 column, but why coldfusion converts it to a number?

How can I tell coldfusion not to convert the string to number? I need the value with leading zeros.

regards Claudia

This topic has been closed for replies.

1 reply

Inspiring
July 2, 2011

Hi Claudia

Can you please provide us with:

* the DB system you're using (sounds like it's Oracle if you've got VARCHAR2s?);

* the version of CF you're running;

* some self-contained code (including sample data) that demonstrates what you're seeing.

Please ALWAYS provide this sort of information when you post a question: it makes it a lot easier to answer it ;-)

I cannot replicate what you're seeing on a hastily thrown-together test rig, running CF9.0.1 & MySQL 5.5

--

Adam

Inspiring
July 2, 2011

Here it is with oracle

<cfquery name="y" datasource="some oracle db">
select '007' bond
from dual
</cfquery>
<cfset session.x = y["bond"][1]>
<cfdump var="#session.x#">

I see 007 when I run it.