Skip to main content
Inspiring
March 27, 2007
Question

The # sign is part of db field names

  • March 27, 2007
  • 10 replies
  • 1226 views
I'm using an odbc to a database where the # sign is part of the field name. I have researched it and found that suggested solutions don't work. Anyone know of a workaround for a field name ISREC#
    This topic has been closed for replies.

    10 replies

    Inspiring
    March 28, 2007
    Too bad he has this:
    [Macromedia][SequeLink JDBC Driver][ODBC Socket][IBM][iSeries Access ODBC Driver][DB2 UDB]SQL0206 - Column ISREC not in specified tables.
    Inspiring
    March 28, 2007
    I can confirm that enclosing the field name in brackets [] and using two
    pound signs # as philh suggested works with an MS Access database.

    Carl

    philh wrote:
    > Have you tried square brackets:
    >
    > select * from istatic
    > where [ISrec##] = #recnum#
    >
    Inspiring
    March 28, 2007
    Have you tried square brackets:

    select * from istatic
    where [ISrec##] = #recnum#
    Inspiring
    March 27, 2007
    Use three # signs....

    SELECT ISREC### AS ISREC

    The ### tells CF to really use a # in that place. At least it will print the # sign if you use ### on a webpage.
    Participating Frequently
    March 28, 2007
    Two hash signs ## will display # on a web page - three ### will produce an error.
    larksysAuthor
    Inspiring
    March 27, 2007
    The following seems to get around the field name problem, but does not return the data.

    <cfparam name="lastname" type="string">
    <cfparam name="recnum" type="numeric">
    <cfquery name="GetIndiv" datasource="AS400" username="quser" password="quser" dbtype="odbc">
    select * from istatic
    where ISrec## = #recnum#

    </cfquery>
    <cfif GetIndiv.recordcount is 0>

    <cfoutput> <br> "Invalid user ID or password" #lastname# #GetIndiv.islnam# #recnum#<br> </cfoutput>


    <cfelse>


    <cfoutput query="GetIndiv"> #GetIndiv.RecordCount# </cfoutput>
    Total records <br>

    </cfif>
    Participating Frequently
    March 27, 2007
    ok, how about just doing "select * from istatic" instead of specifying the field names? If it runs ok you could then do a cfdump to see what the query contains and take it from there.

    It may end up being that you just have to stick with select * to avoid the error - not normally recommended but if it stops your errors then its not a bad thing..
    larksysAuthor
    Inspiring
    March 27, 2007
    You can see that various combinations don't work. I can't change the field names. At least, not now.
    larksysAuthor
    Inspiring
    March 27, 2007
    Invalid CFML construct found on line 6 at column 18.
    ColdFusion was looking at the following text:

    isrec

    The CFML compiler was processing:

    * An expression that began on line 6, column 13.
    Your expression might be missing an ending "#" (it might look like #expr ).
    * The body of a cfquery tag beginning on line 5, column 2.


    The error occurred in D:\usersites\taxsearch\htdocs\update2\submit.cfm: line 6

    4 : <cfparam name="recnum" type="numeric">
    5 : <cfquery name="GetIndiv" datasource="AS400" username="quser" password="quser" dbtype="odbc">
    6 : select isrec# as isrec,ISLNAM,isfnam,iscity from istatic
    7 : where ISrec = recnum
    8 :
    larksysAuthor
    Inspiring
    March 27, 2007
    rror Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC Socket][IBM][iSeries Access ODBC Driver][DB2 UDB]SQL0206 - Column ISREC not in specified tables.

    The error occurred in D:\usersites\taxsearch\htdocs\update2\submit.cfm: line 5

    3 : <cfparam name="lastname" type="string">
    4 : <cfparam name="recnum" type="numeric">
    5 : <cfquery name="GetIndiv" datasource="AS400" username="quser" password="quser" dbtype="odbc">
    6 : select isrec## as isrec,ISLNAM,isfnam,iscity from istatic
    7 : where ISrec = recnum

    SQL select isrec# as isrec,ISLNAM,isfnam,iscity from istatic where ISrec = recnum
    DATASOURCE AS400
    VENDORERRORCODE -206
    SQLSTATE 42S22
    larksysAuthor
    Inspiring
    March 27, 2007
    I get the following error;

    Error Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC Socket][IBM][iSeries Access ODBC Driver][DB2 UDB]SQL0206 - Column "isrec#" not in specified tables.

    The error occurred in D:\usersites\taxsearch\htdocs\update2\submit.cfm: line 5

    3 : <cfparam name="lastname" type="string">
    4 : <cfparam name="recnum" type="numeric">
    5 : <cfquery name="GetIndiv" datasource="AS400" username="quser" password="quser" dbtype="odbc">
    6 : select "isrec##" as isrec,ISLNAM,isfnam,iscity from istatic
    7 : where ISrec = recnum

    SQL select "isrec#" as isrec,ISLNAM,isfnam,iscity from istatic where ISrec = recnum
    DATASOURCE AS400
    VENDORERRORCODE -206
    SQLSTATE 42S22
    Participating Frequently
    March 27, 2007
    try removing the quotes from around isrec## so your select line reads:

    select isrec## as isrec,ISLNAM,isfnam,iscity from istatic

    instead of:

    select "isrec##" as isrec,ISLNAM,isfnam,iscity from istatic
    Inspiring
    March 27, 2007
    I have never had this problem but an idea might be to us the "AS" command in the SQL.... Another use for this is if you have two tables in a JOIN with the same name...

    SELECT ISREC# AS ISREC

    You may have to use "SELECT ISREC### AS ISREC" so that CF knows that the single # is not starting a var...

    Then you should be able to access the var as:

    #query.isrec#

    I am not sure if this will work or not, but you can give it a try.