Oracle PL/SQL - TIPSAdvertisement対象データ存在確認 その1
declare
wk_count integer;
begin
select count(*) into wk_count
from DB where 〜;
if wk_count = 0 then
-- データなし
else
-- データあり
end if;
end;
対象データ存在確認 その2
declare
cursor cur_check is
select * from DB where 〜;
rec_check cur_check%rowtype;
begin
open cur_check;
fetch cur_check into rec_check;
if cur_check%notfound then
-- データなし
else
-- データあり
end if;
end;
対象データ存在確認 その3
トリッキー。
insert の時に応用すると、意外と便利だったりする。
declare
begin
begin
select * from DB where 〜;
-- データが1件のみ存在する。
exception
-- データなし
end;
end;
Advertisement |
ショートカット・634・634blog ・このカテゴリのトップページに戻る ・634labs UIコレクションギャラリー サイト検索Y!ログールビリヤード |