CF5 OLEDB & Stored Proc

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

  1. #1

    Default CF5 OLEDB & Stored Proc

    I have a MS SQL stored procedure that simply creates a temp table (#temtable)
    and inserts records from 3 other tables selects records from the temp table
    then deletes it. Very simple. The server is running CF 5 (which I have no
    control over) and the scenario works perfect using ODBC drivers.

    We recently switched to OLE DB DSN to enhance performance and now this stored
    proc no longer returns any results. I used to call the stored proc like this:

    <cfquery name="getData" datasource="#dsn#">
    { call myStoredProc }
    </cfquery>

    With ODBC the above works, with OLEDB it returns an error when I try to
    reference getData.<anything> because it does not exist. However the debugging
    info shows that getData object has return 0 records.

    Okay, next I tried this:
    <cfstoredproc procedure="myStoredProc" datasource="#DSN#" returncode="yes">
    <cfprocresult name="getData">
    </cfstoredproc>
    Now it does not error, but it still returns 0 records. When I switch to ODBC
    it returns 30 something.

    Here's the stored proc:
    CREATE PROCEDURE . AS

    CREATE TABLE #TempTable(
    state CHAR(2) NOT NULL,
    stateName VARCHAR(50) NOT NULL
    )

    INSERT #TempTable(state,stateName)
    SELECT state,stateName FROM tableA WHERE country = 'United States';

    INSERT #TempTable(state,stateName)
    SELECT state,stateName FROM tableB WHERE country = 'United States';

    INSERT #TempTable(state,stateName)
    SELECT state,stateName FROM tableC WHERE country = 'United States';

    SELECT DISTINCT state,stateName FROM #TempTable
    ORDER BY stateName;

    DROP TABLE #TempTable
    GO


    Any suggestions????

    solutionfinder Guest

  2. Similar Questions and Discussions

    1. Nested stored proc
      Hi everybody, I need your help. In one of my CF4.5 page, I have to use a MSSQL storde procedure. This stored procedure return 2 variables . OK....
    2. cfc and stored proc
      does anyone know if there is documentation anywhere that states that in ColdFusion MX 6.1 when you try to pass parameters to a stored procedure via...
    3. ASP vs Stored Proc vs UDF
      Hi all, I have a field in Table A that must be updated whenever a record is added to Table B. Table A will always only contain one single record...
    4. Stored proc problem on 9.30.UC1
      I have a problem with at stored proc "freezing" (actually just taking a long time to complete - going from less than a second to several minutes)...
    5. stored proc and tcp/ip
      Hello, is it possible to communicate with another program using tcp/ip? I mean, i have another program where i know the port number and the...
  3. #2

    Default Re: CF5 OLEDB & Stored Proc

    The curly-bracketed CALL statement is an ODBC-specific construct. Use EXEC MyStoredProcedure or use the CFSTOREDPROC tag instead of CFQUERY (which is probably the better choice).

    HTH,
    philh Guest

  4. #3

    Default Re: CF5 OLEDB & Stored Proc

    Thanks, I have tried it both of those ways with the same problem. It works fine if the stored proc is a simple select query, but it seems to choke with the temp table stuff.

    Any other ideas?
    solutionfinder Guest

  5. #4

    Default Re: CF5 OLEDB & Stored Proc

    The CF server user has System Administrator permissions, and Database Access to all DBs.

    I don't know if this would be the difference but CF uses Windows authentication (remember, I'm using CF5).
    solutionfinder Guest

  6. #5

    Default Re: CF5 OLEDB & Stored Proc

    I know that this doesn't address the temp table issue between OLDB and ODBC,
    but in your specific example, I was wondering why you needed to use a temp
    table at all. How about replacing all of the inserts with this?

    SELECT state,stateName FROM tableA WHERE country = 'United States'
    UNION
    SELECT state,stateName FROM tableB WHERE country = 'United States'
    UNION
    SELECT state,stateName FROM tableC WHERE country = 'United States'
    ORDER BY stateName;

    Phil

    paross1 Guest

  7. #6

    Default Re: CF5 OLEDB & Stored Proc

    Philh, No connection string.
    Paross1, You are right that would be a better solution. However the stored
    procedure in this thread was just one example of many stored procs that use
    temp tables (none of which I wrote or control).

    solutionfinder Guest

  8. #7

    Default Re: CF5 OLEDB & Stored Proc

    Philh,

    UNION, as opposed to UNION ALL (at least according to my Oracle documentation)
    eliminates duplicate selected rows and SQL Server BOL says basically the same
    thing. Therefore, I am assuming that one only needs to use DISTINCT to
    eliminate duplicates within each individual query, and using UNION by itself
    should keep the duplictes from the combined queries.

    Phil

    paross1 Guest

  9. #8

    Default Re: CF5 OLEDB & Stored Proc

    Add SET NOCOUNT ON, and I think will be better to use a variable TABLE than a temp table, but I understand rigth and you can't modify the stored procedures ?

    Regards
    Sojovi Guest

  10. #9

    Default Re: CF5 OLEDB & Stored Proc

    Sojovi,
    I don't have direct access to change the stored procs, but this can be done.
    I just need to find the best solution before I tell the db admin to let me
    change dozens of stored procs.

    What do you mean by variable table vs temp table?

    solutionfinder Guest

  11. #10

    Default Re: CF5 OLEDB & Stored Proc

    Temp Table :
    CREATE TABLE #TempTable(state CHAR(2) NOT NULL,stateName VARCHAR(50) NOT NULL)
    Variable Table :
    DECLARE @TempTable TABLE (state CHAR(2) NOT NULL,stateName VARCHAR(50) NOT
    NULL)

    (read BOL about the advantages).

    But about your problem, don0t know, I think is trial and error the way to find
    the solution...

    Regards

    Sojovi 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