I am trying to pass 6 values to my stored procedure. Depening on the circumstance, any one like DOB or any other field values might be null. I am reading the values from text file. So my SP works fine when all values are present. But its not working as expected
if anyone value is missing. Could anyone here please help me to solve this issue. Reply in this regard is highly appreciable. Thank you.
andhaman
0 Points
63 Posts
Passing a null value to Stored Procedure
Nov 05, 2012 01:39 AM|LINK
Hello all,
I am trying to pass 6 values to my stored procedure. Depening on the circumstance, any one like DOB or any other field values might be null. I am reading the values from text file. So my SP works fine when all values are present. But its not working as expected if anyone value is missing. Could anyone here please help me to solve this issue. Reply in this regard is highly appreciable. Thank you.
Dan Bracuk
Contributor
3970 Points
1096 Posts
Re: Passing a null value to Stored Procedure
Nov 05, 2012 01:43 AM|LINK
Not working as expecting? That's pretty vague. What are you expecting and what are you observing?
andhaman
0 Points
63 Posts
Re: Passing a null value to Stored Procedure
Nov 05, 2012 01:46 AM|LINK
I am reading a value from a file and passing that value to SP to update a field in a table.
In the file if a value is not present then just spaces would be there. So in that case while passing that null values it throws an error.
I am hoping that you got it what i am saying. Thanks for your time.
oned_gk
All-Star
35940 Points
7339 Posts
Re: Passing a null value to Stored Procedure
Nov 05, 2012 01:46 AM|LINK
Set defaultvalue when declaring parameter
Suwandi - Non Graduate Programmer
andhaman
0 Points
63 Posts
Re: Passing a null value to Stored Procedure
Nov 05, 2012 01:48 AM|LINK
I cant use default value, since if its null then I have to store null.
subhash.shel...
Contributor
2137 Points
487 Posts
Re: Passing a null value to Stored Procedure
Nov 05, 2012 01:49 AM|LINK
Hi,
Have you check ISNULL for passed variable??
ex. If(ISNULL(DOB,'') <> '')
{
}
if it does solve your problem then please put your SP overhere.
Subhash
Please, Mark as Answer if this reply helped you.
Dan Bracuk
Contributor
3970 Points
1096 Posts
Re: Passing a null value to Stored Procedure
Nov 05, 2012 01:53 AM|LINK
Well now we are getting somewhere. You gave dob as an example. What would this file contain if it didn't contain a birth date?
oned_gk
All-Star
35940 Points
7339 Posts
Re: Passing a null value to Stored Procedure
Nov 05, 2012 01:53 AM|LINK
The problem i think from dob, use requiret field validator, everyone have DOB. Dont left it blank.
Suwandi - Non Graduate Programmer
andhaman
0 Points
63 Posts
Re: Passing a null value to Stored Procedure
Nov 05, 2012 01:56 AM|LINK
If it doesnt contain DOB, in place of that it will have spaces.
DOB format is yyyymmdd, so if its not having value, it will have 8 spaces. Thanks
andhaman
0 Points
63 Posts
Re: Passing a null value to Stored Procedure
Nov 05, 2012 01:57 AM|LINK
Not working Subhash.