您的位置:首页 > 数据库

PL/SQL中LIKE函数使用变量 PL/SQL中LIKE函数使用变量

2016-05-28 13:42 609 查看
orcal使用的方法:

like中使用变量方式为:like '%' || 变量名|| '%' 

create or replace procedure edrill_report_day as 
re_date date; 
re_date_str varchar(20); 
begin 
re_date := trunc(sysdate) - 1; 
re_date_str := to_char(re_date, 'yyyymmdd'); 
······· 
select * from table_name where col_1 like '%' || re_date_str || '%' 

MYSQL使用'%' +re_date_str +'%' 

 SELECT shipper.approved,

       Dense_rank() OVER (ORDER BY customer.customer_id)                                                     AS rank,

       Dense_rank() OVER( partition BY shipper.customer_id,shipper.trans_date,shipper.trans_no ORDER BY shipper.trans_no) AS 明细排列, --虚排列方式

       customer.customer_id,

       customer.short_name,

       shipper.trans_date,

       part.description,

       part.specification,

       shipper_line.user_9                                                                                   AS 件数,shipper_line.line_no,

       shipper_line.quantity,

       shipper_line.unit_price,

       shipper_line.all_amt,

       shipper_line.remark,:开始日期 as 开始日期,:结束日期 as 结束日期

FROM   shipper,

       shipper_line,

       part,

       customer

WHERE  customer.customer_id = shipper.customer_id

       AND shipper.trans_no = shipper_line.trans_no

       AND shipper_line.part_id = part.part_id

 AND shipper.trans_date BETWEEN :开始日期 AND :结束日期

and customer.short_name like '%'||:客户简称||'%'

 

      

ORDER  BY customer.customer_id,

          shipper.trans_no,

          

          shipper_line.line_no 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  函数使用变量