Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
It's not quite right
Message
From
30/01/2013 17:49:09
 
 
To
30/01/2013 17:46:47
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Environment versions
SQL Server:
SQL Server 2008
Application:
Desktop
Miscellaneous
Thread ID:
01564725
Message ID:
01564753
Views:
39
Um.....probably not - but since I had to look at it twice to decide yea or nay, I probably should.


>Hi Dorris
>
>just a guess but do you need
>
>BEGIN
>END
>
>around the statement block after your else.
>
>
>
>>Hi gang
>>
>>What I'm trying to do is create a stored procedure that will
>>
>>1) Check for existance of a record for a particular SCN
>>2) If it exists, check to see if this is a restarted test
>>
>>For whatever reason (which means I have no clue), the following SP runs with no error, but doesn't produce a result either.
>>
>>
>>USE [DLI_Testing]
>>GO
>>SET ANSI_NULLS ON
>>GO
>>SET QUOTED_IDENTIFIER ON
>>GO
>>
>>ALTER PROCEDURE [dbo].[TestStart] 
>>
>> @Subbank		nchar(1),
>> @SCN			Nchar(7),
>> @TCN			nchar(3),
>> @TestSection	nvarchar(1) OUTPUT,
>> @TestRestart	nvarChar(1) OUTPUT,
>> @ErrMsg		nvarChar(100) OUTPUT
>> 
>>AS
>>BEGIN
>>  declare @iError int, @iRowCnt int, @RecExists int, @TotQst int
>>  --SET NOCOUNT ON;
>>  select @RecExists = 1 where @SCN not in (select SCN from TestResult)
>>  if @RecExists = 1
>>    Begin
>>      begin transaction
>>      Insert into TestResult (Subbank,SCN,TCN)
>>        values('E0' + @Subbank, @SCN,@Tcn)
>>      select @iError = @@error, @iRowCnt = @@rowcount
>>      if @iError > 0 or @iRowCnt < 1
>>        begin
>>         Set @ErrMsg = 'Initial Insert Fails ' + @iError
>>         raiserror('Error on Initial Insert into Result -  %d',16,1, @iError) 
>>         rollback transaction
>>         Return
>>        end
>>      else
>>        commit transaction
>>        Select @TestSection = 'L', @TestRestart = 'F'
>>    end
>>  else	--Record already exists
>>    begin
>>      select @TestSection = 
>>        Case (ListenTotal + ReadTotal)
>>          when 25 then 'R'
>>          when 0 then 'L'
>>          when 50 then 'F'
>>        end,
>>        @TestRestart = 
>>          Case (ListenTotal + ReadTotal)
>>            when 25 then 'T'
>>            when 0 then 'F'
>>            when 50 then 'F'
>>          end
>>      from TestResult where SCN = @SCN
>>    end   
>>END
>>
>>
>>Have at it
>>Dorris
"You don't manage people. You manage things - people you lead" Adm. Grace Hopper
Pflugerville, between a Rock and a Weird Place
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform