Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
SowjanyaB
Frequent Visitor

Query Parameters in Paginated Report(Text Editor) against DB2 database

Hi All,

 

We are using SQL Queries in Power BI Report builder for reports development aganist DB2 database.

I am facing an issue to pass values using parameters in SQL Query.

 

select distinct ACCT_ID from V_ACCT_EMP_REL
where EMPLOYEE_ID = @EmployeeID

 

ERROR [42S22] [IBM][CLI Driver][DB2/AIX64] SQL0206N "@EMPLOYEEID" is not valid in the context where it is used. SQLSTATE=42703

 

What should be the syntax here to use parameters in the SQL Query?

Thanks!!

6 REPLIES 6
v-xuxinyi-msft
Community Support
Community Support

Hi @SowjanyaB 

 

Did sevenhills 's method solve your problem? If yes, could you please mark it as solution? This will help more users who are facing the same or similar difficulties. Thank you!

 

If you still have questions, please feel free to ask me.

 

Best Regards,
Yulia Xu

I should pass only ? not ?EmployeeID. In this case, if i am going to use same parameter multiple times, it will be difficult to maintain the code. It is creating ambiguity when more than one parameter should be used multiple times.

 

Replacing @EmployeeID with ? worked for DB2 but it didnt suffice for the complete requirement.

JOIN(Parameters!pCategory.Value, “,”) is not working when multiple values are selected.

SowjanyaB
Frequent Visitor

When i use ? it works.

Yes, i have configured dataset parameter to report parameters in Paramaters section.

I havent used for multivalue yet.

 

What if i have multiple parameters that should be used in more than one place, how should that be used?

For Ex:

select distinct ACCT_ID from V_ACCT_EMP_REL
where EMPLOYEE_ID = @EmployeeID

Union 

select distinct ACCT_ID from V_EMPLOYEE_DIM
where EMPLOYEE_ID = @EmployeeID

and ACCT = @ACCTID

 

As per my knowledge, SSRS - DB2 - Parameterized query does not use "@", instead uses "?". That is why I suggested to use "?".


See if this link gives you some direction: https://community.fabric.microsoft.com/t5/Desktop/Paginated-report-parameters-and-IBM-i-iSeries-DB2-...

For multi-value parameters, typically we use JOIN(Parameters!pCategory.Value, “,”)

sevenhills
Super User
Super User

Try these steps
~ Replace @EmployeeID with ? 
~ Are you passing the parameter value as null ?
~ curious, is it mulit valued parameter? then use JOIN
~ silly to ask, but, did you configure the dataset parameter value to report parameter value?

 See if this works !

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.