Skip to main content
Participating Frequently
March 11, 2010
Question

Stored Procedure Only Returns First Character

  • March 11, 2010
  • 3 replies
  • 832 views

I am having an issue with ColdFusion MX7 and a MSSQL 2005 DB.

I am able to duplicate my development issue with the following simple example

-- SQL Code

CREATE PROCEDURE myTestProc
    @myString varchar(36) OUT
AS
BEGIN
    set @myString = 'This is my test';
END
GO

-- CFCode

<cfstoredproc procedure="myTestProc" datasource="#dsName#">
        <cfprocparam cfsqltype="cf_sql_varchar"
               type="out"
               variable="vars.myString" />
</cfstoredproc>

<cfdump label="testProcReturn" var="#vars#" />

<cfabort />

This is what it returns

testProcReturn - struct
myStringT

I have tried many, many, many variations of CFSQLTYPE and the datatype in the procedure and not once have I got it to return more than just the first character.

This topic has been closed for replies.

3 replies

Inspiring
March 11, 2010

And running this proc via SQL Server Management Studio (or some other non-CF / non-JDBC client) works fine?

--

Adam

Participating Frequently
March 11, 2010

ColdFusion version is 7,0,2,142559 runing in developer mode (this is a testing/development server).  I am using the regular SQL Sever ODBC driver that was installed on the OS (Windwos XP).  I am not sure it makes a difference but CF is running on Apache.

It appears I am not the only one who has seen this kind of behaivor

( http://www.experts-exchange.com/Software/Server_Software/Web_Servers/ColdFusion/Q_22145528.html )

Unfortunatley the "solution" give on Expert$Exchange is not a solution at all.

The stored procedure returns as expected through Database Workbench and SQL Mgt. Studio.

It returns fine in every instances except when I use cfstoredproc.

Inspiring
March 11, 2010
I am using the regular SQL Sever ODBC driver that was installed on the OS (Windwos XP).

Ah... OK.  Why are you using ODBC?  Use the (MS SQL) JDBC drivers.

--

Adam

Inspiring
March 11, 2010

What exact version of CFMX7?  I tested this on 7,0,2,142559 - albeit on SQL Server 2k8, not 2k5 - and your initial code works fine.

Are you using the DataDirect drivers that ship with CF, or some different driver?

--

Adam

Participating Frequently
March 11, 2010

I just discovered that the following works.  I consider it a workaround and not a final solution.  It appears there is something wrong with the way I am using cfstoredproc or there is a bug in it.

<cfquery name="testProc" datasource="#dsName#">
DECLARE    @myString varchar(36)

EXEC    myTestProc
          @myString = @myString OUTPUT

SELECT    @myString as 'myString'

</cfquery>

<cfdump label="testProc" var="#testProc#" />
<cfabort />

This code returns what I expect it to.

testProc - query - Top 1 of 1 Rows
MYSTRING
1This is my test