Giter Site home page Giter Site logo

Comments (10)

dsevastianov avatar dsevastianov commented on August 23, 2024

That's a good one, thanks for testing!
On Oct 25, 2013 10:57 PM, "Jack Fox" [email protected] wrote:

It appears you cannot use the same parameter more than once.

Comment out the second occurence:

--OR city LIKE @startsWith

and it builds.

Error 6 The type provider 'FSharp.Data.SqlClient.SqlCommandTypeProvider'
reported an error: The undeclared parameter '@startsWith' is used more than
once in the batch being analyzed.

[]
let sqlCityCounty = @"
SELECT DISTINCT
streetName = null,
streetAddress = null,
postalCode = null,
listingID = null,
mlsID = null,
classID = null,
neighborhood = null,
countryCode,
state,
county,
city
FROM tbMLSQuickLocationListingCount WITH (NOLOCK)
WHERE
(
county LIKE @startsWith
OR city LIKE @startsWith
)
AND locationType = 'City'
AND MLSID IN (select * from dbo.ConvertCommaSeparatedStringToTableOfInts(@mlsIDList))
AND CASE WHEN (MLSID = 10 AND companyID = @companyid) OR MLSID <> 10 THEN 1 ELSE 0 END = 1"

type QueryCityCounty = SqlCommand<sqlCityCounty, ConnectionStringName="staging", ResultType = ResultType.Records, ConfigFile="AutoComplete.config">
let cmd1 = QueryUserMLS(startsWith = "7L%", mlsIDList = "1,2,3", companyID = 1)

β€”
Reply to this email directly or view it on GitHubhttps://github.com//issues/13
.

from fsharp.data.sqlclient.

dmitry-a-morozov avatar dmitry-a-morozov commented on August 23, 2024

@jackfoxy Jack, I will look into the issue.

from fsharp.data.sqlclient.

jackfoxy avatar jackfoxy commented on August 23, 2024

Thanks.

Found this by accident. I don’t have to perform that query, but good to identify the issue.

From: Dmitry [mailto:[email protected]]
Sent: Friday, October 25, 2013 8:09 PM
To: dmitry-a-morozov/FSharp.Data.SqlCommandTypeProvider
Cc: Jack Fox
Subject: Re: [FSharp.Data.SqlCommandTypeProvider] undeclared parameter cannot be used more than once (#13)

@jackfoxy https://github.com/jackfoxy Jack, I will look into the issue.

β€”
Reply to this email directly or view it on GitHub #13 (comment) . https://github.com/notifications/beacon/qagoFbftMXzJr4d1v9KIqp5_a7A6T-YB64Px8e6g0fl2Jx45DElcwzcm0crU2eST.gif

from fsharp.data.sqlclient.

rojepp avatar rojepp commented on August 23, 2024

From the docs:

sp_describe_undeclared_parameters returns an error in any of the following cases.

  • If the input @tsql is not a valid Transact-SQL batch. Validity is determined by parsing and analyzing the Transact-SQL batch. Any errors caused by the batch during query optimization or during execution are not considered when determining whether the Transact-SQL batch is valid.
  • If @params is not NULL and contains a string that is not a syntactically valid declaration string for parameters, or if it contains a string that declares any parameter more than one time.
  • If the input Transact-SQL batch declares a local variable of the same name as a parameter declared in @params.
  • If the statement creates any temporary tables.

These are the limitations of this TP, and maybe they should be documented here.
There's not much to be done about this, other than a simple workaround. Make sure each @param is declared only once:

DECLARE @input int
SET @input = @parm
SELECT *
FROM sys.indexes
WHERE @input = 1 or @input = 2

from fsharp.data.sqlclient.

dmitry-a-morozov avatar dmitry-a-morozov commented on August 23, 2024

@rojepp Thanks for help

from fsharp.data.sqlclient.

dmitry-a-morozov avatar dmitry-a-morozov commented on August 23, 2024

fixed in ver 1.7.6

from fsharp.data.sqlclient.

geandbe avatar geandbe commented on August 23, 2024

Looks like the issue reopen is due. TP fails to accept the following query:

.....................
WHERE <predicate>
AND (@Param = '' OR [Field] = @Param)

with diagnostics "An item with the same key has already been added".

from fsharp.data.sqlclient.

rojepp avatar rojepp commented on August 23, 2024

@geandbe The workaround I posted above doesn't work?

from fsharp.data.sqlclient.

geandbe avatar geandbe commented on August 23, 2024

Sure it does, but workaround <> closed issue, right?

from fsharp.data.sqlclient.

cmeeren avatar cmeeren commented on August 23, 2024

The workaround works, but is this not possible to fix? Using e.g. @input = '' OR @input = 'asd' in a normal SQL script works fine without declaring it, but fails using using this type provider.

from fsharp.data.sqlclient.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.