LINE/COL ERROR
369/42 PLS-00103: Encountered the symbol "TO" when expecting one of the
following:
( - + case mod new null
continue avg count current max min prior sql stddev sum
variance execute forall merge time timestamp interval date
pipe
<an alternatively-quoted SQ
I am getting this error in this part of code:
if year_float_minutes > (eligible_minutes * 3) then
record_error(end_date, header_id, 0, rule_set, 'ABCDE',
'[year]=' || to c.labor_date_year);
l_rpt := 1;
end if;
Related
When I tried to compile this procedure:
PROCEDURE GET_NUMBER_PROPOSED_TRADES(p_client_id NUMBER, p_curr_id NUMBER, p_cursor OUT sys_refcursor)
IS
BEGIN
OPEN p_cursor FOR
IF (p_client_id = 0 AND p_curr_id = 0)
THEN
SELECT COUNT (DISTINCT NVL(id,0)) AS "Proposed_Trade_Number" FROM proposed_trade;
ELSE
SELECT COUNT (DISTINCT NVL(id,0)) AS "Proposed_Trade_Number" FROM proposed_trade WHERE client_id = p_client_id AND ccy_id = p_curr_id;
END IF;
END GET_NUMBER_PROPOSED_TRADES;
this error occurred:
Error(9,11): PLS-00103: Encountered the symbol "IF" when expecting one of the following: ( - + case mod new not null select with continue avg count current exists max min prior sql stddev sum variance execute forall merge time timestamp interval date pipe
Error(18,1): PLS-00103: Encountered the symbol "PROCEDURE" when expecting one of the following: end not pragma final instantiable order overriding static member constructor map The symbol "static" was substituted for "PROCEDURE" to continue.
Error(25,1): PLS-00103: Encountered the symbol "PROCEDURE" when expecting one of the following: end not pragma final instantiable order overriding static member constructor map The symbol "static" was substituted for "PROCEDURE" to continue.
But the thing is, if I just remove IF condition, I can compile it easily, so this kind of a new for me
You can't nest an if condition inside a cursor declaration, it's just not valid syntax. One way around this would be to have a single query, and use the where clause conditions to get the same logic you were trying to get from the if:
OPEN p_cursor FOR
SELECT COUNT (DISTINCT NVL(id,0)) AS "Proposed_Trade_Number"
FROM proposed_trade
WHERE (p_client_id = 0 AND p_curr_id = 0) OR
(client_id = p_client_id AND ccy_id = p_curr_id);
Compilation failed, line 10 (14:27:16)
The line numbers associated with compilation errors are relative to the first BEGIN statement. This only affects the compilation of database triggers.
PLS-00103: Encountered the symbol ";" when expecting one of the following: . ( ) * # % & - + / at mod remainder rem with and or group having intersect minus start union where connect || multiset
The symbol ";" was ignored.**
create or replace trigger "PROMOS_T2"
BEFORE insert or update on "PROMOS"
for each row
DECLARE
ma_exp1 EXCEPTION;
ma_exp2 EXCEPTION;
ma_exp3 EXCEPTION;
cap LOGTS.CAPACITE%TYPE;
nbr INTEGER;
begin
SELECT COUNT (*) INTO nbr FROM LOGTS WHERE :NEW."IDLOG"=IDLOG;
SELECT CAPACITE INTO cap FROM LOGTS WHERE :NEW."IDLOG"=IDLOG;
if (exists(SELECT * FROM PROMOS WHERE :NEW."IDPROMO"=IDPROMO;) )THEN
RAISE ma_exp1;
elsif nbr=1 AND cap < :NEW."NBPLACES" THEN
RAISE ma_exp2;
else
RAISE ma_exp3;
end if;
EXCEPTION
WHEN ma_exp1 THEN
RAISE_APPLICATION_ERROR(-20004,'la promos dèja existe');
WHEN ma_exp2 THEN
RAISE_APPLICATION_ERROR(-20005,'PAS DE PLACE');
WHEN ma_exp3 THEN
RAISE_APPLICATION_ERROR(-20006,'IDLOG nexiste pas');
end;
Take a look at the error message, in particular, the parts
Compilation failed, line 10
and
Encountered the symbol ";"
This is line 10:
if (exists(SELECT * FROM PROMOS WHERE :NEW."IDPROMO"=IDPROMO;) )THEN
See the problem?
Your compilation error is being caused by the semicolon in that line. Removing it will help, but your code will still fail to compile, because you can't call EXISTS in PL/SQL outside of SQL. To fix that, see the answers to this question.
I have oracle block like
DECLARE
TYPE emp_array IS VARRAY(100) OF VARCHAR2(30);
VAR_PRESENTADDRESS1 varchar2(100);
emps emp_array;
inx1 PLS_INTEGER;
BEGIN
VAR_PRESENTADDRESS1 := 'test,test1';
emps := emp_array (select REGEXP_SUBSTR(VAR_PRESENTADDRESS1, '[^,]+', 1, rownum) addressword
from DUAL
connect by level <= length (regexp_replace (VAR_PRESENTADDRESS1, '[^,]+')) + 1);
FOR inx1 IN 1..2 LOOP
DBMS_OUTPUT.PUT_LINE(emps(inx1));
END LOOP;
END;
/
This gives error like :
Error report:
ORA-06550: line 9, column 28:
PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
( ) - + case mod new not null <an identifier>
<a double-quoted delimited-identifier> <a bind variable>
table continue avg count current exists max min prior sql
stddev sum variance execute multiset the both leading
trailing forall merge year month day hour minute second
timezone_hour timezone_minute timezone_region timezone_abbr
time timestamp interval date
<a string literal with character set specifica
ORA-06550: line 11, column 112:
PLS-00103: Encountered the symbol ")" when expecting one of the following:
* & - + ; / at for mod remainder rem <an exponent (**)> and
or group having intersect minus order start union where
connect ||
ORA-06550: line 17, column 3:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
end not pragma final instantiable order overriding static
member constructor map
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
I want output like:
test
test1
That's not how PL/SQL syntax works. Try this:
select REGEXP_SUBSTR(VAR_PRESENTADDRESS1, '[^,]+', 1, rownum)
bulk collect into emps
from DUAL
connect by level <= length (regexp_replace (VAR_PRESENTADDRESS1, '[^,]+')) + 1);
I have a date and I'd like to print the offset from that date. I can do this:
dbms_output.put_line(to_char(g_startDate - interval '4' month ,'YYYY-MM-DD'));
and it works fine. The problem is that the interval is variable. When I try this:
dbms_output.put_line(to_char(g_startDate - interval g_dateOffsetAmt month ,'YYYY-MM-DD'));
I get a compiler error.
I thought it might be because g_dateOffsetAmt is an integer so I tried this:
dbms_output.put_line(to_char(g_startDate - interval to_char(g_dateOffsetAmt) month ,'YYYY-MM-DD'));
Though I still get compiler errors saying:
Error: PLS-00103: Encountered the symbol "TO_CHAR" when expecting one of the following:
. ) , * # & | = - + at in is mod remainder not rem =>
.. or != or ~= >= and or like
LIKE2_ LIKE4_ LIKEC_ as between from using || member
SUBMULTISET_
The symbol "," was substituted for "TO_CHAR" to continue.
Line: 704
Error: PLS-00103: Encountered the symbol "MONTH" when expecting one of the following:
. ( ) , * % & | = - + at in is mod remainder not range
rem => .. or != or ~= >= and or
like LIKE2_ LIKE4_ LIKEC_ between || multiset member
SUBMULTISET_
The symbol "." was substituted for "MONTH" to continue.
Line: 704
Is there some other way to do this?
You would probably want to use the NumToYMInterval function
declare
v_interval pls_integer := 4;
begin
dbms_output.put_line( sysdate - NumToYMInterval( v_interval, 'month' ) );
end;
/
There are a couple ways to do this.. Either type your variable being passed in as an interval, or use the function add_months instead:
declare
v_interval INTERVAL YEAR TO MONTH := interval '4' month;
begin
dbms_output.put_line(to_char((sysdate - v_interval), 'MM/DD/YYYY'));
end;
declare
v_interval PLS_INTEGER := 4;
begin
dbms_output.put_line(to_char(add_months(sysdate, -v_interval), 'MM/DD/YYYY'));
end;
I have the following oracle statement which is giving compilation errors.
v_percent_deceased_households := CASE
WHEN NVL(v_total_households, 0) > 0 THEN
(CAST(NVL(v_deceased_households_count, 0) AS FLOAT(53))
/
CAST(NVL(v_total_households, 0) AS FLOAT(53))) * 100
ELSE 0
END;
Errors are:
Error:
PLS-00103: Encountered the symbol "(" when expecting one of the following:. ) # %
The symbol ")" was substituted for "(" to continue.
Line: 317
Text: (CAST(NVL(v_deceased_households_count, 0) AS FLOAT(53)) / CAST(NVL(v_total_households, 0) AS FLOAT(53))) * 100
Error: PLS-00103: Encountered the symbol "(" when expecting one of the following:. ) # %
Line: 317
Text: (CAST(NVL(v_deceased_households_count, 0) AS FLOAT(53)) / CAST(NVL(v_total_households, 0) AS FLOAT(53))) * 100
I cant seem to resolve this syntax error..
Why the CAST (... AS FLOAT(53))? Why not just:
v_percent_deceased_households := CASE
WHEN v_total_households > 0 THEN
(NVL(v_deceased_households_count, 0) / v_total_households) * 100
ELSE 0
END;
(I removed some redundant NVLs too).
I believe CAST has to be used in a select or 'select into'
For example
select cast( '22-Aug-2003' AS varchar2(30) )
from dual;
or
select cast( v_deceased_households_count AS float ) into myfloat
from dual;