Parameterized query returning no data or error
Hello, Finally got my report manager up and running as well as all data sources talking nicely thanks to help in another thread. I've got an issue now with setting up a parameterized query to accept input from the user executing the report. There is a field i'd like to be able to select on. SELECT SUM(number) AS number1, SUM(number) AS number2, employee, division FROM "table" WHERE division = @Division I'd like the user to be able to select the division. I'm running SSRS 2008R2 64 bit on server 2008 64bit. The datasource is a postgres db. Upon execution of this in my query builder it does (kind of) prompt for the field but once i input data it errors out with the following: TITLE: Microsoft SQL Server Report Designer ------------------------------ An error occurred while executing the query. ERROR [42883] ERROR: operator does not exist: @ character varying; Error while executing the query ------------------------------ ADDITIONAL INFORMATION: ERROR [42883] ERROR: operator does not exist: @ character varying; Error while executing the query (PSQLODBC.DLL)
March 15th, 2011 3:51pm

Missing GROUP BY.. Try this SELECT SUM(number) AS number1, SUM(number) AS number2, employee, division FROM "table" WHERE division IN (@Division ) GROUP BY employee, divison SqlUser2011
Free Windows Admin Tool Kit Click here and download it now
March 15th, 2011 4:38pm

Sorry, there is a group by: GROUP BY employee, division is in there, thought i had copied it. Added the: WHERE division IN (@Division) Still throwing same error. I'm just not exactly sure what the ERROR: operator does not exist: @ character varying; means. I cant change the data type on the table.
March 15th, 2011 4:46pm

Did you try executing it in SSMS ? If not, try the following. DECLARE @Division varchar(max) SET @Division = 'somevalue' SELECT SUM(number) AS number1, SUM(number) AS number2, employee, division FROM "table" WHERE division IN (@Division ) GROUP BY employee, divison And replace 'somevalue' with your parameter value. Check whether your result set appears..SqlUser2011
Free Windows Admin Tool Kit Click here and download it now
March 15th, 2011 4:49pm

Hi, The parameter you are passing are multiselect or single select? if it is a multiselect then you have to use charindex function so that data should come like that in in clause ('a','b','c') CHARINDEX( ',' +division+ ',', ',' + (@Division) + ',' ) > 0 ) other wise it will through error. Please mar as answer if this post helps. Thanks, Shobhit
March 15th, 2011 11:02pm

Please try entering query as an expression. To do that open the dataset, click on the little x (expression) button right to the query text area. Enter the below expression, if your division parameter allows only a single select ="SELECT SUM(number) AS number1, SUM(number) AS number2, employee, division " & "FROM MyTable " & "WHERE division = " & Parameters!Division.Value If your division parameter allows multi select, then use the below expression. Note the IN operator in place of =, and the split function to get the value as required by IN ="SELECT SUM(number) AS number1, SUM(number) AS number2, employee, division " & "FROM MyTable " & "WHERE division IN " & Join(Parameters!Division.Value,"','") & "'" Hope this helps. Please feel free to discuss if you need any further help Please click "Mark as Answer" if this resolves your problem or "Vote as Helpful" if you find it helpful. BH
Free Windows Admin Tool Kit Click here and download it now
March 16th, 2011 12:33am

Please try entering query as an expression. To do that open the dataset, click on the little x (expression) button right to the query text area. Enter the below expression, if your division parameter allows only a single select ="SELECT SUM(number) AS number1, SUM(number) AS number2, employee, division " & "FROM MyTable " & "WHERE division = " & Parameters!Division.Value If your division parameter allows multi select, then use the below expression. Note the IN operator in place of =, and the split function to get the value as required by IN ="SELECT SUM(number) AS number1, SUM(number) AS number2, employee, division " & "FROM MyTable " & "WHERE division IN " & Join(Parameters!Division.Value,"','") & "'" Hope this helps. Please feel free to discuss if you need any further help Please click "Mark as Answer" if this resolves your problem or "Vote as Helpful" if you find it helpful. BH
March 16th, 2011 12:33am

Thank you all for your input, unfortunately,none of this has even given any sign of working. There is definitely, i feel , an issue with the variable/parameter operator (@) as it relates to the postgres db. I could be wrong but i've found that using and passing parameters within a separate MSSQL DB query works just fine.
Free Windows Admin Tool Kit Click here and download it now
March 16th, 2011 10:23am

Alright, to update... I was able to get it working not with WHERE division = @division or $ but with WHERE division = ? and then specifying the remainder of the details within the parameters section inside BIDS. Terribly 'kluged' if you ask me. I've actually created a db connector container to kind of consolidate multiple data sources via one 'connection' and will look at probably re-creating the queries since the sql will have to be a bit different. I may be back here though and while nobody here officially had a solution it all helped point in the right direction. I just had to find how the postgres database wanted me to pass the parameter.
March 16th, 2011 3:40pm

Hi TheDecoy, Thanks for the tip...i was also stuck at the same place...Please share if you have any further issue\solution with postgres talking to SSRS.
Free Windows Admin Tool Kit Click here and download it now
April 5th, 2011 11:39pm

Hi Aussie, Will do...were you having other issues also?
April 6th, 2011 8:29am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics