DataDirect 3.5 JDBC Driver / Problem with CFQUERYPARAMand SQL Server

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default DataDirect 3.5 JDBC Driver / Problem with CFQUERYPARAMand SQL Server

    Is anyone else experiencing this? I just reported it as a bug, but want to be
    sure that I'm not the only one, and that it doesn't disappear into the ether...

    Prior to the DataDirect JDBC driver 3.5, when a CFQUERY using the CFQUERYPARAM
    tag was executed in a ColdFusion template against a SQL Server 2000 database,
    the SQL was executed with sp_execute, and results returned. With the 3.5
    version of the driver, using a CFQUERYPARAM tag now causes sp_preparesql to be
    executed (ie the SQL is parsed before execution), which returns an error if a
    table that did not exist prior to the CFQUERY call is created and accessed
    within the SQL statement.
    Removing the CFQUERYPARAM tags and embedding the variable directly in the SQL
    eliminates the parse prior to execution.

    An example:

    <cfset myVar = 1 />

    <!--- this CFQUERY will not throw an error using the 3.5 version of the
    drivers --->
    <cfquery datasource="test">
    select #myVar# as theColumn into #testTable

    select * from #testTable

    drop table #testTable
    </cfquery>

    <!--- this CFQUERY will throw an error even though it's technically valid
    using the 3.5 version of the drivers --->
    <cfquery datasource="test">
    select <cfqueryparam value="#myVar#" cfsqltype="cf_sql_integer" /> as
    theColumn into #testTable

    select * from #testTable

    drop table #testTable
    </cfquery>




    mr snoopy Guest

  2. Similar Questions and Discussions

    1. Datadirect JDBC 3.6?
      Looks like DataDirect has released version 3.6. Does anyone know when Macromedia will be releasing their 3.6 version for CFMX?
    2. SQL Server JDBC Driver / Validation Failure
      Hmmm... I posted earlier today, but the message naver made it to the forums. I'll try again We have been trying to install an app (prototype...
    3. SQL Server JDBC Driver Encryption
      Hi, does anyone know if its possible to encrypt a SQL server jdbc driver datasource? I know it is with ODBC but CF seems to have no options...
    4. SQL Server 2000 JDBC driver??
      I know that Microsoft offers a JDBC driver for SQL Server 2000, but its a EXE file. I'm also under the impression that the actual jar file needs...
    5. Problem with JDBC driver/connection
      I had been using the JDBC driver for a little while now, and it has been working fine. I checked one of the sites I use it with, and no data came...
  3. #2

    Default Re: DataDirect 3.5 JDBC Driver / Problem withCFQUERYPARAM and SQL Server

    I suspect that both your examples have the wrong syntax. I don't believe -- but
    I have to check the literature -- that it is correct to put a primitive data
    value such as #myVar# or <cfqueryparam value="#myVar#"
    cfsqltype="cf_sql_integer" /> right after the word "select".

    You might not get an error in the first example because the following just
    happens to be correct, if uninspiring, SQL:

    select 5 as myColumn
    from myTable

    This will simply return the value 5 thirty-seven times, if myTable has 37
    rows. The error thrown during the binding with cfqueryparam is perhaps a signal
    that a you should put a column-name after "select", not a value. Just my
    immediate reaction.





    BKBK Guest

  4. #3

    Default Re: DataDirect 3.5 JDBC Driver / Problem withCFQUERYPARAM and SQL Server

    In my original example, I forgot to escape the # signs. I'm using the # sign to
    create a temp table in SQL Server. The syntax (except for that) is actually
    correct. It would be like saying "select name, 5 as someColumn from
    sysobjects", which if you try in SQL Server, will work. I was only using a
    simple query to illustrate the problem. A more realistic example is below. No
    variables, just straight SQL in CF:

    <!--- this will work --->
    <cfquery datasource="test">
    select name into ##myTable from sysfiles where name = 'master'
    select * from ##myTable
    drop ##myTable
    </cfquery>

    <!--- this will not work --->
    <cfquery datasource="test">
    select name into ##myTable from sysfiles where name = <cfqueryparam
    value="master" cfsqltype="cf_sql_varchar" />
    select * from ##myTable
    drop ##myTable
    </cfquery>




    mr snoopy Guest

  5. #4

    Default Re: DataDirect 3.5 JDBC Driver / Problem withCFQUERYPARAM and SQL Server

    I now understand. It's indeed worth a look.


    BKBK Guest

  6. #5

    Default Re: DataDirect 3.5 JDBC Driver / Problem withCFQUERYPARAM and SQL Server

    <!--- this will not work --->
    Returning to it, what error did you get?



    BKBK Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139