Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to pass multiple values in a bind variable

SaroAug 13 2018 — edited Aug 20 2018

Hi Friends,

My database version is 12.1.0.2

Find my below DDL and DML statements

create table excelexport (sales_order_number varchar2(30), fiscal_year varchar2(20))

insert into excelexport values ('103627', '2008');

insert into excelexport values ('64491', '2007');

Below is my sql query

SELECT   SALES_ORDER_NUMBER AS c2, FISCAL_YEAR AS c3

  FROM   EXCELEXPORT

WHERE   FISCAL_YEAR IN NVL (:p_year, FISCAL_YEAR)

         AND SALES_ORDER_NUMBER IN NVL (:p_order, SALES_ORDER_NUMBER)

My question is when i pass multiple values, suppose assume for the bind variable p_year if i pass 2008,2007 then my above sql query is not fetching any values and the same applicable to my other bind variable p_order.

But if i execute my above query without any values for both the variable then as per nvl condition it is fetching all the two rows and that is fine and also if i pass single value say like p_year=2008 then im getting my 2008 record in the result.

But if i pass multiple values like for variable p_year as 2008,2007 then the values are not fetching.

Kindly help me friends like how can i fetch the values by passing comma seperated multiple values to my bind variable.

Thanks in advance.

Regards,

Saro

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 12 2018
Added on Aug 13 2018
28 comments
12,291 views