Skip to main content
CJ83_2
Known Participant
November 28, 2006
Answered

when doing query of query it assumes field is numeric

  • November 28, 2006
  • 3 replies
  • 477 views
I have a query that has 30 some records in it from an AS400 file. Now when I do a query on the query, it thinks one of the columns is a numeric field, even though it is not. Now I do the same thing with another query (with same file and fields, just different data) and it works fine.

This is the error that I am getting: The value "73D" cannot be converted to a number

That column looks like this for example
75
75
71
71
75
73
75
73D
etc. (the 73D is the only one in this column)

Now in the Query of Queries I am not even querying that field (There is about 10 fields in the query and I want the results of one) and then I get the above error. Any ideas??

THanks in Advance,
CJ
    This topic has been closed for replies.
    Correct answer Newsgroup_User
    CJ wrote:
    > I have a query that has 30 some records in it from an AS400 file. Now when I do

    you create the original query yourself? if so, create the AND define the data types:

    newQ=QueryNew("user,lastLogin,manager", "varChar,time,bit");

    > a query on the query, it thinks one of the columns is a numeric field, even
    > though it is not. Now I do the same thing with another query (with same file
    > and fields, just different data) and it works fine.
    >
    > This is the error that I am getting: The value "73D" cannot be converted to a
    > number
    >
    > That column looks like this for example
    > 75

    cf will construct the result query based on the first row of data (if you're not
    defining the datatypes in the original query), which looks like numeric data.

    > 73D

    so when it hits this row it will fail.

    if you're not using that column's data, then don't return it. otherwise use the
    CAST method as dan suggested.

    3 replies

    Newsgroup_UserCorrect answer
    Inspiring
    November 29, 2006
    CJ wrote:
    > I have a query that has 30 some records in it from an AS400 file. Now when I do

    you create the original query yourself? if so, create the AND define the data types:

    newQ=QueryNew("user,lastLogin,manager", "varChar,time,bit");

    > a query on the query, it thinks one of the columns is a numeric field, even
    > though it is not. Now I do the same thing with another query (with same file
    > and fields, just different data) and it works fine.
    >
    > This is the error that I am getting: The value "73D" cannot be converted to a
    > number
    >
    > That column looks like this for example
    > 75

    cf will construct the result query based on the first row of data (if you're not
    defining the datatypes in the original query), which looks like numeric data.

    > 73D

    so when it hits this row it will fail.

    if you're not using that column's data, then don't return it. otherwise use the
    CAST method as dan suggested.

    CJ83_2
    CJ83_2Author
    Known Participant
    November 29, 2006
    Thanks everyone for your quick responses. I am creating the original query, so I defined the data types and it works great now. I will also keep the cast function in the back of my mind, because I see that it will come in useful sometime also. Again thanks evereyone!
    CJ
    November 29, 2006
    Q of Q in CF version 7.02 does not usually have this problem.

    It may be the code. Post code that demonstrates the problem.

    Try and make it a self-contained example.
    Inspiring
    November 28, 2006
    This sort of thing drives me crazy. Look up the cast function, it might help.