Hi I am havin gtrouble running this query. I am trying to get the input parameter and based on that value use it in the query.
The error I am getting is:
**Error(26,3): PLS-00103: Encountered the symbol "IF" when expecting one of the following: begin function pragma procedure subtype type <an identifier> <a double-quoted delimited-identifier> current cursor delete exists prior **
create or replace
PROCEDURE GET_STATES (
i_id IN NUMBER,
o_result OUT SYS_REFCURSOR,
IS
DECLARE country VARCHAR2 = '';
BEGIN
o_sqlmsg := 'SUCCESS';
o_sqlcode := 0;
IF i_id == 284
THEN country := 'US';
ELSE country := 'CA';
END IF;
OPEN o_result FOR
Select cnint as Id, cnabbv as Code, rtrim(cnname) as Name, i_id as CId
from country
order by cnname;
o_result OUT SYS_REFCURSOR), AlsoDECLAREkeyword is not needed, when used to declare Procedures/Functions!=in SQL (and PL/SQL). Not==. And you need to use a proper assignment operator:=in the variable declaration as well.COUNTRYthe name of a table in your database, or are you expecting that setting the variablecountryto'US'or'CA'will change the name of the table which is accessed by theSELECTstatement?