CodeSmith Community
Your Code. Your Way. Faster!

Custom Stored Procedure returns void?

Latest post 01-11-2007 12:24 PM by csd. 4 replies.
  • 01-10-2007 6:09 PM

    • csd
    • Top 500 Contributor
    • Joined on 11-01-2006
    • Posts 15
    • Points 370

    Custom Stored Procedure returns void?

    I have a CSP that does a SELECT and then an UPDATE within a transaction. Unfortunately, it looks like something in this procedure is causing nettiers to generate a method that returns void. I was hoping it would return my particular entity. I got the feeling that the syntax of my procedure is causing this problem. However, I'm not sure what it is. Could someone take a look at the CSP below?

    set ANSI_NULLS ON
    set QUOTED_IDENTIFIER ON
    GO

    ALTER PROCEDURE [dbo].[_SequenceNumber_GetCurrentValueAndIncrement]
        @Code nvarchar(50)
    AS
    BEGIN
        SET NOCOUNT ON;

        BEGIN TRY
            BEGIN TRANSACTION
                SELECT Id, Code, StartValue, EndValue, CurrentValue
                FROM Core.SequenceNumber
                WHERE Code = @Code

                UPDATE Core.SequenceNumber
                SET CurrentValue = CurrentValue + 1
                WHERE Code = @Code
            COMMIT TRANSACTION
        END TRY
        BEGIN CATCH
            ROLLBACK TRANSACTION
        END CATCH
    END

    • Post Points: 35
  • 01-10-2007 8:36 PM In reply to

    Re: Custom Stored Procedure returns void?

    .netTiers uses the last CommandSchemaResult i believe to determine the return type.  Since the last one is an update, it's going to return void.

    You can try bobby's workaround to get it working:
    http://community.codesmithtools.com/forums/permalink/19046/19046/ShowThread.aspx#19046


    Robert Hinojosa
    -------------------------------------
    Member of the Codesmith Tools, .netTiers, teams
    http://www.nettiers.com
    -------------------------------------
    • Post Points: 35
  • 01-11-2007 12:11 PM In reply to

    • csd
    • Top 500 Contributor
    • Joined on 11-01-2006
    • Posts 15
    • Points 370

    Re: Custom Stored Procedure returns void?

    One last question... that seemed to do the trick. However, I now get a TList<entity>. Is there a way I could structure the query to just return the entity? Would TOP 1 work?
    • Post Points: 35
  • 01-11-2007 12:18 PM In reply to

    Re: Custom Stored Procedure returns void?

    No, there's no current way to do that unfortunately.  On the tables we look to see if it has a unique index, but we can't do that with a command result.  There's no meta-data to describe that.

    On 1/11/07, csd <bounce-csd@codesmithsupport.com> wrote:
    One last question... that seemed to do the trick. However, I now get a TList<entity>. Is there a way I could structure the query to just return the entity? Would TOP 1 work?





    Robert Hinojosa
    -------------------------------------
    Member of the Codesmith Tools, .netTiers, teams
    http://www.nettiers.com
    -------------------------------------
    • Post Points: 50
  • 01-11-2007 12:24 PM In reply to

    • csd
    • Top 500 Contributor
    • Joined on 11-01-2006
    • Posts 15
    • Points 370

    Re: Custom Stored Procedure returns void?

    Thanks for your very prompt and knowledgeable replies!
    • Post Points: 5
Page 1 of 1 (5 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems