2013-07-05 60 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; 

謝謝!