PLS-00103 when trying to call a procedure - oracle

When attempting to compile I am getting the following errors
Error(16,8): PLS-00103: Encountered the symbol "SPROLLUPEXPENSEITEM"
when expecting one of the following: := . ( # % ; The symbol ":="
was substituted for "SPROLLUPEXPENSEITEM" to continue.
and
Error(17,15): PLS-00103: Encountered the symbol "=" when expecting one
of the following: . ( * # % & = - + < / > at in is mod remainder
not rem then <> or != or ~= >= <= <> and or like
like2 like4 likec between || multiset member submultiset
create or replace
TRIGGER tr_ExpenseItem_Rollup
AFTER DELETE OR UPDATE of ExpApprAmt
ON ExpenseItem
FOR EACH ROW
DECLARE
RollupAmt Number;
BlnResult Boolean;
BEGIN
IF DELETING THEN
RollupAmt := -1 * :Old.ExpApprAmt;
End If;
IF UPDATING Then
RollupAmt := :New.ExpApprAmt - :Old.ExpApprAmt;
End IF;
Call spRollUpExpenseItem(:New.ERNo,:New.ECNo,RollupAmt,BlnResult);
If BlnResult := TRUE
--Additional Logic Here
End IF;
END;
I'm a student and very new at this, so any help would be appreciated.

call isn't a keyword in PL/SQL and to run a stored procedure you just use its name. Remove call from before spRollUpExpenseItem:
create or replace
TRIGGER tr_ExpenseItem_Rollup
AFTER DELETE OR UPDATE of ExpApprAmt
ON ExpenseItem
FOR EACH ROW
DECLARE
RollupAmt Number;
BlnResult Boolean;
BEGIN
IF DELETING THEN
RollupAmt := -1 * :Old.ExpApprAmt;
End If;
IF UPDATING Then
RollupAmt := :New.ExpApprAmt - :Old.ExpApprAmt;
End IF;
spRollUpExpenseItem(:New.ERNo,:New.ECNo,RollupAmt,BlnResult);
If BlnResult = TRUE Then
--Additional Logic Here
End IF;
END;

I believe your problem is in the last if statement. You're missing Then and you're using := which is the assignment operator, you should use = instead.
If BlnResult = TRUE Then
or just
If BlnResult Then

Related

Wrong number or TYPES of arguments, error in PL/SQL

I have to create a list of RECORD and I need to send it to a procedure.
There is my header.
CREATE OR REPLACE PACKAGE tema4 IS
TYPE obj IS RECORD(id INTEGER := 0,percent INTEGER := 0);
TYPE listObj IS TABLE OF obj INDEX BY PLS_INTEGER;
PROCEDURE ex1 (p_listObj IN listObj);
END tema4;
My body.
create or replace PACKAGE BODY tema4 IS
PROCEDURE ex1 (p_listObj IN listObj) IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Cant reach');
END ex1;
END tema4;
And my code that calls procedure ex1.
DECLARE
TYPE obj IS RECORD(id INTEGER := 0,percent INTEGER := 0);
TYPE listObj IS TABLE OF obj INDEX BY PLS_INTEGER;
v_obj obj;
v_listObj listObj;
BEGIN
FOR v_i IN (SELECT ID,BURSA FROM STUDENTI ORDER BY ID) LOOP
v_obj.id := v_i.id;
v_obj.percent := 50;
v_listObj(v_i.id) := v_obj;
END LOOP;
FOR v_i IN v_listObj.FIRST..v_listObj.LAST LOOP
DBMS_OUTPUT.PUT_LINE(v_listObj(v_i).id || ' - ' ||
v_listObj(v_i).percent);
END LOOP;
tema4.ex1(v_listObj); --this line is with problems
END;
PLS-00306: wrong number or types of arguments in call to 'EX1'
Can someone explain me what is wrong in my code? I also tried to create my type as global, but it won't let me because of 'RECORD' keyword.
Don't declare the types again (new types), use the types already declared in the package spec:
DECLARE
v_obj tema4.obj;
v_listObj tema4.listObj;
BEGIN
FOR v_i IN (SELECT ID,BURSA FROM STUDENTI ORDER BY ID) LOOP
v_obj.id := v_i.id;
v_obj.percent := 50;
v_listObj(v_i.id) := v_obj;
END LOOP;
FOR v_i IN v_listObj.FIRST..v_listObj.LAST LOOP
DBMS_OUTPUT.PUT_LINE(v_listObj(v_i).id || ' - ' ||
v_listObj(v_i).percent);
END LOOP;
tema4.ex1(v_listObj); --this line is with problems
END;

Error when creating Elsif Trigger Before Update

I am creating trigger when Selisih column is equal to 0, then Status column become 'Partial'. If QtyInternalUse column is equal to QtyRequested, then Status column is Completed, else, it is Not Issued
CREATE OR REPLACE TRIGGER TG_STATUSINREQ
BEFORE UPDATE OR INSERT ON M_INTERNALREQUESTERLINE
FOR EACH ROW
BEGIN
IF (:new.Selisih <> 0 ) THEN
:new.Status := 'Partial';
ELSIF :new.QtyInternalUse := :new.QtyRequested THEN
:new.Status := 'Completed';
ELSE
:new.Status := 'Not Issued';
END IF;
END;
I've tried execute it and there's error that says
PLS-00103: Encountered the symbol "=" when expecting one of the
following:
. ( * # % & = - + < / > at in is mod remainder not rem then
<an exponent (**)> <> or != or ~= >= <= <> and or like like2
like4 likec between || indicator multiset member submultiset
The symbol "* was inserted before "=" to continue.
I've tried deleting : in = but still it won't work. How can I fix this?
REVISION
I have updated the logic and the := . The trigger was created and it's like this :
BEGIN
IF (:new.QtyInternalUse = 0 ) THEN
:new.Status := 'Not Issued';
ELSIF :new.QtyInternalUse = :new.QtyRequested THEN
:new.Status := 'Completed';
ELSE
:new.Status := 'Partial';
END IF;
END;
This should be pretty easy google-resolve. Still here you go.
ELSIF :new.QtyInternalUse := :new.QtyRequested THEN
You are trying to compare but using assignment operator[:=]. Use equals[=] in stead that will resolve your problem.
ELSIF :new.QtyInternalUse = :new.QtyRequested THEN

loop counter case in oracle procedure

Is there any loop counter in procedure.
How to handle below case.
BEGIN
FOR recAnnLang IN getLang(var_non_subscribe)
LOOP
// if loop 1 recAnnLangCode.Ann_Lang assign to var1
var1 := recAnnLangCode.Ann_Lang;
// if loop 2 recAnnLangCode.Ann_Lang assign to var2
var2 := recAnnLangCode.Ann_Lang;
// if loop 3 recAnnLangCode.Ann_Lang assign to var2
var3 := recAnnLangCode.Ann_Lang;
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND THEN
dbms_output.put_line('Debug :: Inside Exception because data not found ' );
END;
DECLARE n_counter NUMBER := 0;
BEGIN
LOOP
n_counter := n_counter + 1;
DBMS_OUTPUT.PUT_LINE(n_counter);
IF n_counter = 5 THEN
EXIT;
END IF;
END LOOP;
END;
I did it like this.
maybe you are looking for something like
declare
type a_type is table of recAnnLang.Ann_Lang%type index by pls_integer;
val a_type;
begin
for recAnnLang in getLang(var_non_subscribe) loop
val(nvl(val.last, 0) + 1) := recAnnLang.Ann_Lang;
end loop;
for i in 1 .. val.last loop
dbms_output.put_line(val(i));
end loop;
end;
maybe,if getlang is an explicit cursor,you may think of using rownum in the cursor query select clause and use it as the counter.

Oracle Database PLSQL Error: PLS-00103

I'm writing simple function in Oracle Database 11g that count summary salary for employee. For this we need to count days with specific status. Days is present as fields in table (Day_1, Day_2, ..., Day_30).
But i have got error during compilation:
Error(50,9): PLS-00103: Encountered the symbol ";" when expecting one of the following: :=.(#%;
Code of my package (a place where there is an error marked in code of function f2):
CREATE OR REPLACE PACKAGE pack IS
FUNCTION f1 (id IN NUMBER) return t2 PIPELINED;
FUNCTION f2 (id IN NUMBER) return number;
end pack;
/
CREATE OR REPLACE PACKAGE BODY pack IS
FUNCTION f1 (id IN NUMBER) return t2 PIPELINED IS
name VARCHAR2(50);
num number;
BEGIN
FOR i IN 1 .. id LOOP
SELECT отдел
into name
from отдел
where ид_отдела = i;
select sum(КОЛИЧЕСТВО)
into num
from Таблица_3
join Таблица_2
on Таблица_3.КТО_ПРОДАЛ = Таблица_2.ЧЛВК_ИД
where отдел = i;
PIPE ROW( t1(i, name, num) );
END LOOP;
RETURN;
END f1;
FUNCTION f2 (id IN NUMBER) return NUMBER AS
WorkingDays NUMBER := 0;
CurrentDay VARCHAR2(50);
Salary NUMBER := 120;
Total NUMBER := 0;
BEGIN
FOR i IN 1 .. 30 LOOP
EXECUTE IMMEDIATE 'SELECT День_' || i || ' FROM Таблица_2 WHERE ЧЛВК_ИД = id INTO CurrentDay';
IF WorkingDays IN ('КОМАНДИРОВКА','ВЫХОДНОЙ','ПРАЗДНИК') THEN -- <--- Here
WorkingDays := WorkingDays + 1;
END IF;
END LOOP;
Total : = Salary * WorkingDays;
RETURN Total;
END f2;
end pack;
/
How can i solve this? Maybe the problem is in the logic of the program?
That is an error on parsing, and be aware that it often does not accurately show the error itself, but where the next symbol error occurred. For example:
declare
x number;
y number;
begin
if x = 1 then
y := 1 --I forget to put on the semi-colon to end the line
end if;
end;
You'd expect an error on the missing semi-colon. What you get is:
ORA-06550: line 7, column 2:
PLS-00103: Encountered the symbol "END" when expecting one of the following:
* & = - + ; < / > at in is mod remainder not rem
<an exponent (**)> <> or != or ~= >= <= <> and or like like2
like4 likec between || multiset member submultiset
The symbol ";" was substituted for "END" to continue.
Since in your comments you talk about changing things - perhaps to make it more readable for us (and thank you!), it may be obscuring the actual syntax glitch.
Two things I notice:
Total : = Salary * WorkingDays;
That has a space between the : and = that shouldn't be there
and:
FUNCTION f2 (id IN NUMBER) return NUMBER AS
which is normally
FUNCTION f2 (id IN NUMBER) return NUMBER IS

when i am trying to sort the array its giving an error

DECLARE
TYPE myarray is varray(10) of pls_integer;
unsorted myarray := myarray();
min pls_integer;
begin
unsorted := myarray(2,5,8,6,4,9,1,3,7,10);
FOR i in 1 .. unsorted.count-1 loop
begin
for j in i+1 .. unsorted.count loop
begin
if(unsorted(j)<unsorted(i))
then
begin
min := unsorted(i);
unsorted(i) := unsorted(j);
unsorted(j) := min;
end;
end if;
end;
end loop;
dbms_output.put_line(unsorted(i));
end;
end loop;
end;
my code giving an error i am not able to understand why?
ORA-06550: line 16, column 31:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
You use min as a variable, but min is a reserved keyword. Use another variable name instead, and it should be working.

Resources