Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 339
  • Last Modified:

how do i read this sql code

hello,

I think i'm having a brain cramp. but the exec @failing   stored proc   ..output  
followed by if @failing > 0


 is throwing me off here.  Can someone explain how to "read" the code .    
Is the output stATEMENT rEPLACING THE @FAILING WITH THE return code being st in the stored proc if it errors out?



         set @LocalProcedure = 'up_XL_zUpdateStgSiteToSite'
      exec @Failed = JabilDBImport.dbo.up_zUpdateImportJobEvent
         @ImportJobID = @ImportJobID,
         @Event = 'Update Site',
         @StartDTS = @CreateUpdateDTS,
         @AddMessage = 'Started',
         @Status = 'Processing...',
         @EndDTS = null
      exec @Failed = up_XL_zGetDataSourceID @ImportJobID, @DataSourceID OUTPUT
      if @Failed <> 0
        begin
          -- ams 7/9/02 c1/a2
          --RAISERROR('up_zUpdateStgSiteToSite',18,1)
          set @ErrorMessage = @LocalProcedure + ' - Error calling up_XL_zGetDataSourceID'
          RAISERROR(@ErrorMessage,18,1)
          return 1
        end
0
rschmehl
Asked:
rschmehl
  • 2
  • 2
3 Solutions
 
Ken ButtersCommented:
The @Failed is being set to the return code of the called function.

if @Failed<> 0 means if @Failed is NOT zero.

A zero return code usually means success... so it is checking for non-zero... meaning failure.

In your original comment you referrred to @Fail > 0 ... which is different... @Fail > 0 would be checking if the return code is Greater than zero... "<>" means not equal to.
0
 
TempDBACommented:
And the output parameter is not replacing the value of @Failed. The value of the output parameter is stored in @DataSourceID.
0
 
rschmehlAuthor Commented:
I'm not sure I understand the exec @Failed proc_ABC , why put the @failedin at all when you are exec Proc_abc?
0
 
TempDBACommented:
This is just to raise your custom error. You can leave without it as well. You will get a system defined error. But this check will help you if you are doing link server (remote server) call. In that case, even if the procedure fails, the execution of the query mayn't be stopped which will hurt the consistency of the data.
0
 
rschmehlAuthor Commented:
Thanks alot
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now