Bit vs. Int in return code

  • Hello,
    Can a bit be used when validating for a return code?  Or should int be used?  Why or why not?

  • rjjh78 - Tuesday, August 8, 2017 8:00 AM

    Hello,
    Can a bit be used when validating for a return code?  Or should int be used?  Why or why not?

    It should be an int. Because it can be more than 0,1 null. Per the documentation, the expected type is int
    Return
    Returning Data by Using A Return Code

    Sue

  • Thank you kindly!

  • You can return a bit value, but it will be implicitly converted into an int.
    If you capture the result value with a bit, you only have 3 available values 0, 1, NULL.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • This was removed by the editor as SPAM

  • vincentshanecurtis - Thursday, August 10, 2017 7:22 PM

    Since a bit only has two values 1 or 0, yes or no, on or off.  Bits should only be used when your return code would reflect only those two possibilities.  If you are expecting to return an actual number and not a logical yes or no value then you should use an int.

    A bit has THREE possible values: 1, 0, or NULL.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 6 posts - 1 through 5 (of 5 total)

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