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

来源:互联网 发布:Java中logback使用 编辑:程序博客网 时间:2024/05/20 09:45
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 

0 0
原创粉丝点击