IF 语句而不是 select
IF Statement and not in select
Informix 它可以工作,如何在 Oracle 中这样做?
IF (uzel NOT IN (SELECT a.uzel FROM user_setup.menu a WHERE a.vetka <> a.uzel
AND a.vetka IN (SELECT vetka FROM user_setup.param_menu)))
THEN
--;
END IF;
在 Oracle 中,您需要使用不同的方法:
DECLARE
usel1 <specify here the data type for the usel>;
BEGIN
SELECT a.uzel INTO usel1
FROM user_setup.menu a
WHERE a.vetka <> a.uzel AND a.usel = uzel
AND a.vetka IN (SELECT vetka FROM user_setup.param_menu))
-- this means the record is found.
EXCEPTION
WHEN NO_DATA_FOUND THEN
-- do other processing here
END;
试试这个:
DECLARE
temp NUMBER;
v_uzel user_setup.menu.uzel%TYPE;
BEGIN
SELECT COUNT(*)
INTO temp
FROM dual
WHERE EXISTS (SELECT A.uzel
FROM user_setup.menu A
WHERE A.vetka <> A.uzel
AND A.uzel = v_uzel
AND A.vetka IN (SELECT vetka FROM user_setup.param_menu));
IF temp < 1 THEN
-- code here
END IF;
END;
Informix 它可以工作,如何在 Oracle 中这样做?
IF (uzel NOT IN (SELECT a.uzel FROM user_setup.menu a WHERE a.vetka <> a.uzel
AND a.vetka IN (SELECT vetka FROM user_setup.param_menu)))
THEN
--;
END IF;
在 Oracle 中,您需要使用不同的方法:
DECLARE
usel1 <specify here the data type for the usel>;
BEGIN
SELECT a.uzel INTO usel1
FROM user_setup.menu a
WHERE a.vetka <> a.uzel AND a.usel = uzel
AND a.vetka IN (SELECT vetka FROM user_setup.param_menu))
-- this means the record is found.
EXCEPTION
WHEN NO_DATA_FOUND THEN
-- do other processing here
END;
试试这个:
DECLARE
temp NUMBER;
v_uzel user_setup.menu.uzel%TYPE;
BEGIN
SELECT COUNT(*)
INTO temp
FROM dual
WHERE EXISTS (SELECT A.uzel
FROM user_setup.menu A
WHERE A.vetka <> A.uzel
AND A.uzel = v_uzel
AND A.vetka IN (SELECT vetka FROM user_setup.param_menu));
IF temp < 1 THEN
-- code here
END IF;
END;