Skip to content

How to pass null/None to Procedure? #158

Open
@legomind

Description

@legomind
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>

Activity

colinbull

colinbull commented on Sep 18, 2015

@colinbull
Collaborator

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>

added this to the V1 milestone on Sep 18, 2015
pezipink

pezipink commented on Sep 18, 2015

@pezipink
Contributor

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.

legomind

legomind commented on Sep 18, 2015

@legomind
Author

Cool. Looking forward to v1

On Fri, Sep 18, 2015, 5:00 AM Ross McKinlay notifications@github.com
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
#158 (comment)
.

ghost

ghost commented on Nov 21, 2015

@ghost

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

JamesFaix

JamesFaix commented on Jul 11, 2019

@JamesFaix

Any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @colinbull@pezipink@legomind@JamesFaix

        Issue actions

          How to pass null/None to Procedure? · Issue #158 · fsprojects/SQLProvider