Please look at my code!!!

  • I have written a stored procedure below that puts the results of a cursor into a variable and is emailed out using another procedure using CDOSYS.

    Example code is at -- http://www.harmonyvybe.com/sp1.htm

    Once the cursor is closed and deallocated, another stored procedure is

    executed (at the bottom in bold and red) passing a value of

    a variable to the executed sp.

    The problem I am having is, when the second one is executed, most of the time the email result is blank -- nothing -- It should return somthing everytime. If you run the second procedure by itself in Q-Analyzer or in an app I created as a work around, it works..

    Example code is at -- http://www.harmonyvybe.com/sp2.htm

    Am I missing something or am I going about this all wrong...

    Thanks!

    Chris

  • This was removed by the editor as SPAM

  • 
    
    FETCH NEXT FROM TRs
    INTO @HistoryID, @TRno, @Date, @Worklog, @User, @LTIActive, @LTICode

    If @LTIActive = -1
    Begin
    Set @Status = 'Long Term Issue'

    Set @LTIField = 'Long Term Issue Code !536871060!: ' + @LTICode
    End
    Else
    Begin
    Set @Status = 'In Progress'
    Set @LTIField = ' Long Term Issue Code !536871060!: '
    End

    WHILE @@FETCH_STATUS = 0
    BEGIN

    should it not be...

    
    
    FETCH NEXT FROM TRs
    INTO @HistoryID, @TRno, @Date, @Worklog, @User, @LTIActive, @LTICode

    WHILE @@FETCH_STATUS = 0
    BEGIN

    If @LTIActive = -1
    Begin
    Set @Status = 'Long Term Issue'

    Set @LTIField = 'Long Term Issue Code !536871060!: ' + @LTICode
    End
    Else
    Begin
    Set @Status = 'In Progress'
    Set @LTIField = ' Long Term Issue Code !536871060!: '
    End

    ....

    Not sure if this whould make any difference...


    Regards,
    Sachin Dedhia

  • missed to mention in your 1st sp...


    Regards,
    Sachin Dedhia

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply