SQLProvider
SQLProvider copied to clipboard
How to pass null/None to Procedure?
CREATE PROCEDURE dbo.test (
@OptionalParam INT = NULL
)
AS
SELECT 1
//Snip...
[ for r in db.Procedures.test.Invoke(None).ResultSet
-> r.MapTo<TestResult> () ]
//Error: Expression was expected to have type int but here has type Option<int>
You can't do this as the F# type system doesn't allow you to represent null as int. In cases like this I guess we could detect if the parameter is nullable (presuming the metadata is available) then the type of the parameter would be Nullable<int>
which I think would cover your needs, or if PreferOptionals
is set you would get Option<int>
yes this should be pretty easy to do, we will get it in for the coming V1. It might be nice to put sprocs under their schemas as well, on an unrelated note. They can clash with each other at the moment.
Cool. Looking forward to v1
On Fri, Sep 18, 2015, 5:00 AM Ross McKinlay [email protected] wrote:
yes this should be pretty easy to do, we will get it in for the coming V1. It might be nice to put sprocs under their schemas as well, on an unrelated note. They can clash with each other at the moment.
— Reply to this email directly or view it on GitHub https://github.com/fsprojects/SQLProvider/issues/158#issuecomment-141386069 .
additionally, it might not be possible but if you set the stored procedure to have Null as a default parameter, and you pass null into the sproc, it will send 'default' to the sql, which uses the default value and all is ok
Any updates on this?