Warm tip: This article is reproduced from serverfault.com, please click

oracle-从一个字段PLSQL进行多值搜索

(oracle - Multi values search from one field PLSQL)

发布于 2020-12-01 07:42:28

我正在PLSQL中创建一个报告。

该报告工作正常,此外,当用户从一个以分隔的字段中搜索多个值时,我需要添加;它应该选择他输入的所有数据。

示例:推销员-阿曼达;米歇尔 沙曼

然后,它应该选择有关amenda,michelle和sharmain的数据。

我的代码仅返回一个值的数据。

请参考代码中的这一行 and ifsapp.Customer_Order_API.Get_Salesman_Code(i.order_no) LIKE '&Salesman'

where  i.catalog_group='FPMB'
       and i.order_no like 'M%'
       and ((i.invoice_date between to_date( '&From_Date', 'YYYY/MM/DD' ) and to_date( '&To_Date', 'YYYY/MM/DD' ) ) or ('&From_Date' is null and '&To_Date' is null))
       and t.source_ref1=i.order_no
       and (t.source_ref3=i.release_no)
       and (t.source_ref2=i.line_no)
       and i.contract=t.contract
       and t.transaction_code='OESHIP'
       and t.qty_reversed=0
       and t.source_ref1=i.order_no
       and t.serial_no <> '*'
       and t.cost<>0.00
       and i.order_no LIKE '&Order_No
       and ifsapp.Customer_Order_API.Get_Salesman_Code(i.order_no) LIKE '&Salesman'
Questioner
smc develpments
Viewed
0
Popeye 2020-12-01 16:09:22

你可以按如下方式使用层次结构查询:

ifsapp.Customer_Order_API.Get_Salesman_Code(i.order_no) IN
(SELECT TRIM(REGEXP_SUBSTR('&Salesman','[^;]+',1,LEVEL))
  FROM DUAL CONNECT BY TRIM(REGEXP_SUBSTR('&Salesman','[^;]+',1,LEVEL)) IS NOT NULL)