使用“转换Oracle存储过程”;通过“连接”;及;“类型”;到MySQL

使用“转换Oracle存储过程”;通过“连接”;及;“类型”;到MySQL,mysql,oracle,cursor,Mysql,Oracle,Cursor,我很难将oracle SP转换为MySQL中的SP。特别是“连接方式”和“类型” 下面是使用Oracle存储过程要解决的问题 有一个表有3列 ID |Last_Modified | Flag 1 |2011-12-11 02:00:00| 0 2 |2011-12-13 02:00:00| 0 3 |2011-12-02 02:00:00| 0 4 |2011-12-12 02:00:00| 0 存储过程“getback(String p

我很难将oracle SP转换为MySQL中的SP。特别是“连接方式”和“类型”

下面是使用Oracle存储过程要解决的问题

有一个表有3列

ID  |Last_Modified | Flag   
1   |2011-12-11 02:00:00|   0   
2   |2011-12-13 02:00:00|   0   
3   |2011-12-02 02:00:00|   0 
4   |2011-12-12 02:00:00|   0 
存储过程“getback(String pId,String pLast_Modified)。例如pId=“1,2,3”和pLast_Modified=“2011-12-11 02:00:00,2011-12-13 02:00:00,2011-12-01 02:00:00”

逻辑是,对于同一ID,如果表中最后修改的\u晚于传递的最后修改的\u,则将该记录的标志设置为“1”

以下是Oracle存储过程:

create or replace procedure test1(
p_ids varchar2,   
p_dates varchar2  
) IS

TYPE id_type IS TABLE OF NUMBER INDEX BY VARCHAR2(64);
TYPE date_type IS TABLE OF DATE INDEX BY VARCHAR2(64);

ids id_type;
last_updated date_type;
lvar1 varchar2(200);
lvar2 varchar2(200);



cursor c1 is 
With ids as (select rownum id, regexp_substr(p_ids,'[^,]+', 1, level) val from dual
connect by regexp_substr(p_ids, '[^,]+', 1, level) is not null), 
lupdated as (select rownum id, regexp_substr(p_dates,'[^,]+', 1, level) val from dual
connect by regexp_substr(p_dates, '[^,]+', 1, level) is not null)
select lut.id, 
case when lut.last_updated > to_date(lu.val,'yyyy-mm-dd hh24:mi:ss') then 1
          else 0
end flag
from last_updated_tbl lut,ids,lupdated lu
where lut.id = ids.val
and   ids.id = lu.id
;

BEGIN
open c1;
loop
 fetch c1 into lvar1,lvar2;
 exit when c1%notfound;

 dbms_output.put_line(lvar1||' flag:'||lvar2);

end loop;

close c1;

END;