Im trying to implement an IF statement to run a query on my Oracle Database.
The expectation: If the employee is called John, display the limited items(item1 and item2), if it's not John, display the complete list.
DECLARE
employeeName STRING := 'John';
BEGIN
IF (employeeName = 'John') THEN
(SELECT TableA.Table from Table where TableA.Table = 'Item1' OR TableA.Table = 'Item2');
ELSE
(SELECT TableA.Table from Table);
END IF;
END;
Here's the error output:
Error report: ORA-06550: line 6, column 2: PLS-00103: Encountered the symbol " " when expecting one of the following:
( begin case declare exit for goto if loop mod null pragma raise return select update while with 'an identifier' 'a double-quoted delimited-identifier' 'a bind variable' ""continue close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe purge 06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
What am I doing wrong? Forgive my ignorance on IF statements implemented on databases.
Aucun commentaire:
Enregistrer un commentaire