I am trying to make the code posted below work, but I am receiving an error about the IF statement:
DECLARE
a number;
BEGIN
SELECT Pers_API.Is_Manager_(10018) INTO a from dual;
EXCEPTION
WHEN no_data_found THEN a := 0;
END;
IF (a >0) THEN
SELECT 1 from dual;
ELSE
SELECT 0 from dual;
END IF;
In the first block I am declaring an 'A' variable and setting it to 0 (by the way, the API call result will be 0 or 1, nothing else). The first block works fine or - at least - I do think so. But the IF block is not working and having this error:
PLS-00103:Encountered the symbol "IF"
Any help is appreciated.
Update: I have tried it this way:
DECLARE
a number:=0;
BEGIN
SELECT Pers_API.Is_Manager_(10018) INTO a from dual;
IF (:a >0) THEN
SELECT 1 from dual;
ELSE
SELECT 0 from dual;
END IF;
END;
I received the exception below:
ORA-01008: not all variables bound
Update
In other words, what I am trying to do is:
- if Pers_API.Is_Manager_(10018) returns true (as 1), I have to do another select statement
- if it's false (as 0), I have to return null.
Any other ideas are appreciated.
IF (:a >0)lineSELECT 1 from dual, you have to select a value into a variableselects need toselect intosomething. (Also, you don't need to query the dual table to assign a value to a variable, as PL/SQL has an assignment operator:=, and PL/SQL doesn't need brackets aroundifconditions.)