plsql stored procedure taking parameter gives error - oracle

I tried to create a procedure in pl/sql developer like,
create or replace procedure insert_muh_fis(birim_id in number(15)) is
begin
insert into muh_Fis_d013
select * from muh_fis mf where mf.fk_birim_id = birim_id;
--delete from muh_fis mf where mf.fk_birim_id = birim_id;
--commit;
end;
But it gives me Compilation error.
Error: PLS-00103: Encountered the symbol "(" when expecting one of the following: := . ) , # % öndeğer karakterThe symbol ":=" was substituted for "(" to continue.
Line: 1
I would appreciate any idea to help me out solve this problem. Thank you very much.

You don't need to specify the datatype precision in IN parameter, your parameter declaration should be like birim_id IN NUMBER.
Try,
CREATE OR REPLACE
PROCEDURE insert_muh_fis(birim_id IN NUMBER)
IS
BEGIN
INSERT INTO muh_fis_d013
SELECT * FROM muh_fis mf WHERE mf.fk_birim_id = birim_id;
--delete from muh_fis mf where mf.fk_birim_id = birim_id;
--commit;
END;

Related

Cannot execute a stored procedure in Oracle

Here is a simple example using Toad for Data Analysts 3.0.1.1734. I have full permissions on the schema JSWEENEY.
Create the table
CREATE TABLE JSWEENEY.TEMP_SQL
(
SQL VARCHAR2(3000)
);
Create the procedure
CREATE OR REPLACE PROCEDURE JSWEENEY.SP_INSERT_SQL
IS
BEGIN
INSERT INTO JSWEENEY.TEMP_SQL(SQL) VALUES('SELECT * FROM TEMP_SQL');
COMMIT;
END JSWEENEY.SP_INSERT_SQL;
/
Execute the procedure:
BEGIN
JSWEENEY.SP_INSERT_SQL;
END;
The first error:
ORA-06550: line 2, column 11:
PLS-00905: object JSWEENEY.SP_INSERT_SQL is invalid
ORA-06550: line 2, column 2: PL/SQL: Statement ignored
Execute the procedure:
BEGIN
EXECUTE JSWEENEY.SP_INSERT_SQL;
END;
The second error:
ORA-06550: line 2, column 10:
PLS-00103: Encountered the symbol "JSWEENEY" when expecting one of the following: := . ( # % ; immediate The symbol ":=" was substituted for "JSWEENEY" to continue.
Any suggestions would be greatly appreciated.
When you compile the procedure you will get an error; if your client doesn't display that then you can query the user_errors view (or all_errors if you're creating it in a different schema) to see the problem. Here it will be complaining that:
LINE/COL ERROR
-------- -----------------------------------------------------------------
6/13 PLS-00103: Encountered the symbol "." when expecting one of the following:
;
It's valid to use the schema name in the create call; but not as part of the end. So if you need to specify the schema at all - which you don't if you're creating an object in your own schema, but your reference to permissions makes it sound like you aren't - then it should be:
CREATE OR REPLACE PROCEDURE JSWEENEY.SP_INSERT_SQL
IS
BEGIN
INSERT INTO JSWEENEY.TEMP_SQL(SQL) VALUES('SELECT * FROM TEMP_SQL');
COMMIT;
END SP_INSERT_SQL;
/
Your second error is because execute on its is a client command (in SQL*Plus and relations), not a PL/SQL statement. The error refers to immediate because PL/SQL does have an execute immediate statement which is used for dynamic SQL, not for making static calls to procedures. Your first syntax to run the procedure is correct, once the procedure itself is valid:
BEGIN
JSWEENEY.SP_INSERT_SQL;
END;
/
try this edited the SQL statement.
create table TEMP_SQL ( col1 varchar2(100));
CREATE OR REPLACE PROCEDURE SP_INSERT_SQL
AS
BEGIN
INSERT INTO TEMP_SQL SELECT * FROM TEMP_SQL;
COMMIT;
END SP_INSERT_SQL;

PLS-00103: Encountered the symbol ")" when expecting one of the following: (

I am a beginner in oracle and following is my function definition and invocation part. I am unable to understand the error that I get when I call the function. Please help me rectify my code.
ORA-06550: line 4, column 56: PLS-00103: Encountered the symbol ")" when expecting one of the following: (
create or replace function totalcustomers
RETURN number
IS
total number:=0;
BEGIN
select count(*) into total from customers;
RETURN total;
END;
/
declare sum number;
BEGIN
sum := totalcustomers();
dbms_output.put_line('Total number of customers '||sum);
END;
/
Do not use sum as a variable which is a reserved keyword in Oracle.
Sum is a function, so it's expecting the open paren. Rename the variable.
The function invocation part was throwing the mentioned error, because "sum" might be a pre-defined keyword in oracle. Changing the variable as follows helped.
declare x number;
BEGIN
x:=totalcustomers();
dbms_output.put_line(' Total number of customers: '||x);
END;
/
Output :
Statement processed.
Total number of customers: 6

Simple PL/SQL Package Procedure call. Error: Expect one of the following := . ( # % ;

Using TOAD for Oracle, I am able to successfully execute this package procedure which accepts a single date argument.
EXEC COMMERCIAL_PURGE.PERFORM_PURGE (date'2010-04-10');
But I am not able to execute the same statement if I surround it y a BEGIN/END block
BEGIN
EXEC COMMERCIAL_PURGE.PERFORM_PURGE (date'2010-04-10');
END;
/
I haven't done PL-SQL coding in over a decade and even then I didn't do that much. What I am trying to do is this:
DECLARE
v_CUTOFF_DT DATE;
BEGIN
--SET SERVEROUTPUT ON;
SELECT FIN_IT_RPT.COMMERCIAL_PURGE.GET_PURGE_CUT_OFF_DT INTO v_CUTOFF_DT FROM DUAL;
DBMS_OUTPUT.PUT_LINE ('The v_CUTOFF_DT=' || v_CUTOFF_DT);
EXEC FIN_IT_RPT.COMMERCIAL_PURGE.PERFORM_PURGE (v_CUTOFF_DT);
END;
/
And my understanding is that the declared variables belongs outside of the BEGIN END block.
The error that I get is this:
ORA-06550: line 11, column 6:
PLS-00103: Encountered the symbol "FIN_IT_RPT" when expecting one of the following:
:= . ( # % ;
The symbol ":=" was substituted for "FIN_IT_RPT" to continue.
What do I have to do to be able to successfully pass a date variable into the PERFORM_PURGE procedure?
You cannot use EXEC inside the Begin END block.
Remove the EXEC from the begin end block. It should work fine then.

Error(7,1): PLS-00103: Encountered the symbol "BEGIN"

I am a new PL/SQL user. I tried to create a procedure and run it like:
create or replace procedure addp1(i in number) is
begin
insert into t3 values (i,'xxxx');
end addp1;
begin
addp1(99);
end;
but i got error: Error(7,1): PLS-00103: Encountered the symbol "BEGIN" in my log file. Can anyone help me fix this problem.
Thanks
create or replace procedure addp1(i in number)
is
begin
insert into t3 values (i,'xxxx');
end addp1;
/* We have to actually push the block to the engine by issuing a '/' */
/
begin
addp1(99);
end;
/* Every PL/SQL Block needs this! */
/

Error on creating stored procedure under Oracle - PLS-00103

Im trying to create a stored procedure that calls another a number of times. This is done so by using a for each loop. All the development is under oracle sql developer Version 3.0.04.
CREATE OR REPLACE PROCEDURE Z_INBILLABILITYSERV
IS BEGIN
DECLARE
ano VARCHAR2(4);
BEGIN
select EXTRACT(YEAR FROM sysdate) into ano from dual;
FOR dat IN (SELECT * FROM Z_FECHOMES WHERE MES <=
(select EXTRACT(MONTH FROM sysdate) from dual )and ANO = ano)
LOOP
call z_insertbillability(dat.periodo_inicio,dat.periodo_fim,
dat.ano,dat.mes);
END LOOP;
END;
END;
Im having the following error:
Error(9,12): PLS-00103: Encountered the symbol "Z_INSERTBILLABILITY" when expecting one of the following: := . ( # % ; The symbol ":=" was substituted for "Z_INSERTBILLABILITY" to continue.
If anyone have an idea or a tip i would be glad to now and would appreciate a lot.
You do not need the word call; just do:
LOOP
z_insertbillability(dat.periodo_inicio,dat.periodo_fim,
dat.ano,dat.mes);
END LOOP;
The error message is perhaps a bit unhelpful, but it's to be trying to show all the ways it could try to interpret the word call, since it doesn't recognise it as a keyword. And showing what it would expect to see next for each: as a variable name (which would be followed by := for assignment; or a schema name (which would be followed by .); or a function/procedure name (which would be followed by ( for the parameter list), etc.

Resources