Click here to Skip to main content
15,887,585 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
While calling the storeprocedure i got the error in storeprocedure at this line

"case when Id is null then 0 else 1 end as isparent"

this line meaning is if Id is null 0 will pass to the isparent otherwise pass 1 to isparent.


Please help me.
Thank you

What I have tried:

this line meaning is if Id is null 0 will pass to the isparent otherwise pass 1 to isparent.
Posted
Updated 28-Sep-20 2:53am

We can't tell based on that little fragment.
If I use that in an SQL statement and run it against my DB:
SQL
SELECT TOP 10 
   CASE WHEN Id IS NULL 
        THEN 0 
        ELSE 1 
   END AS IsParent 
FROM MyTable
It works fine: I get a single column containing 10 1's or 0's.

So you need to look at your SP in more detail, and work out where that code fragment is being used and what the rest of the SP / your app is doing with that result - somewhere it's expecting a boolean and getting that integer, but we have no idea where!

We can't do that for you: we don't have access to anything except exactly what you type!
 
Share this answer
 
You are returning an int, which maps to the System.Int32 type. But you're trying to map it to a System.Boolean, so you need to return a bit instead:
SQL
CASE WHEN Id Is Null THEN CAST(0 As bit) Else CAST(1 As bit) END As IsParent
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900