-1
我正在嘗試編寫運行內部小型查詢的小型PL/SQL塊。問題是,我不想看到查詢返回的整個數據,但看到是否存在或不存在。我的塊看起來是這樣的:PL/SQL - 同時找到記錄並且找不到記錄
procedure check_data as
table_data varchar2;
BEGIN
SELECT * into table_data FROM (
with temp_table as (select a_number, a_group, a_date from table1
where a_id in (15)
)
SELECT b_city, b_district, b_nationality, b_age
FROM table2 JOIN temp_table ON a_id=b_id
WHERE b_age>=10
and b_age<23
ORDER BY b_nationality DESC);
IF SQL%FOUND THEN
raise_application_error(-20001,'OK, found something')
else DBMS_OUTPUT.PUT_LINE ('found nothing!');
end if;
end;
與聲明temp_table一般掙扎(我得到的PLS-00201:標識符「TABLE_DATA」必須申報),並在屏幕上放的效果。
我會很感激任何提示。
http://stackoverflow.com/questions/3434437/whats-the-most-efficient-way-to-check-if-a-record-exists-in-oracle – Rene
@ mc88。請確保您發佈表DDL以及當您希望某人處理您的不工作代碼時。 – XING
table_data是什麼結構?你想要什麼,如果查詢存在 - 選擇一些東西? –