2013-07-05 58 views
0

我尝试使用正则表达式从表中选择行。该模式是选择的结果。
我有以下的编译错误在使用REGEXP_LIKE选择:oracle regexp_like从select中选择模式

PLS-00428:INTO子句中的SELECT语句预计

declare 
    pattern varchar2; 

begin 

    select columns 
    into pattern 
    from table a 
    where conditions; 

    select * 
    from table2 
    where regexp_like(column, pattern); 

end; 

我不明白为什么我应该使用到第...

+1

在plsql中的SELECT应该有一个INTO子句。您已经在第一条语句中使用过它。 – Noel

+0

您的陈述 “select * from table2 where regexp_like(column,pattern);” 也应该像第一个那样有一个INTO子句。 为什么你还需要这个声明?你在哪里使用这个第二选择语句的o/p? – Arnab

+0

我会用第二个选择是这样的:更新MY_TABLE 设定列=值 其中COL2在 ( SELECT * 从表2 其中REGEXP_LIKE(列模式) ) – plugandplay

回答

0

最后,解决的办法是:

declare 

    pattern varchar2; 

begin 

    select columns 
    into pattern 
    from table a 
    where conditions; 


    execute immediate ' 
     select col2 
     from table2 
     where regexp_like(column, :pattern) 
    ' using pattern; 

end; 

谢谢!