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

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! */
/

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;

Strange PL/SQL error - PLS-00103

I have been getting a rather strange error for a long time in SQL developer.. I have stripped my package to the most basic and ran a variable declaration.. and even that is throwing an error.. this is what I am executing:
create or replace package body cdbmeta.pkg_metadata_check
is
procedure p_metadata_check(unit_id_start in number, unit_id_end in number)
is
begin
start_date NUMBER(10);
dbms_output.put_line('..');
end;
end;
and my error message states:
PLS-00103: Encountered the symbol "NUMBER" when expecting one of the following: := . ( # % ; The symbol ":=" was substituted for "NUMBER" to continue.
Totally clueless.. anyone had this before?
You have to put definition of variables after the "is" and before "begin" as follows:
create or replace package body cdbmeta.pkg_metadata_check
is
procedure p_metadata_check(unit_id_start in number, unit_id_end in number)
is
start_date NUMBER(10);
begin
dbms_output.put_line('..');
end;
end;
/
The block in procedure definition after is and before begin is the same as You would use with anonymous block like this:
declare
start_date NUMBER(10);
begin
dbms_output.put_line('..');
end;
/

creating pl/sql procedure to get different columns from different tables

I'm trying to create a procedure to get the data from different columns of different tables. I have written this code but I get error PLS-00103: Encountered the symbol "DECLARE" when expecting one of
the following:
begin function package pragma procedure subtype type use
form
current cursor external language
The symbol "begin" was substituted for "DECLARE" to continue. can anybody
create or replace procedure List_of_mfi
(
cq out sys_refcursor
)
as
begin
open cq for SELECT a.mfi_name,
b.mfi_type_name,
c.mfi_tier_name,
d.mfi_state_name,
e.mfi_district_name,
a.mfi_phone_no
FROM mfi_master a,
mfi_type_master b,mfi_tier_new c,mfi_state_master d,mfi_district_master e
WHERE a.mfi_type_id = b.mfi_type_id(+)
and a.mfi_tier_id = c.mfi_tier_id(+)
and a.mfi_state_id = d.mfi_state_id(+)
and a.MFI_DISTRICT_ID=e.MFI_DISTRICT_ID(+);
end;
declare
cq sys_refcursor;
mfi_name varchar2(150);
mfi_type_name varchar2(150);
mfi_tier_name varchar2(150);
mfi_state_name varchar2(150);
mfi_district_name varchar2(150);
mfi_phone_no varchar2(150);
--SELECT a.mfi_name, b.mfi_type_name, c.mfi_tier_name, d.mfi_state_name,e.mfi_district_name, a.mfi_phone_no
begin
List_of_mfi(cq);
loop
fetch cq into mfi_name,mfi_type_name,mfi_tier_name,mfi_state_name,mfi_district_name,mfi_phone_no;
EXIT WHEN cq%NOTFOUND;
--print
dbms_output.put_line('mfi_name:'||mfi_name);
dbms_output.put_line('mfi_type_name:'||mfi_type_name);
dbms_output.put_line('mfi_tier_name:'||mfi_tier_name);
dbms_output.put_line('mfi_state_name:'||mfi_state_name);
dbms_output.put_line('mfi_district_name:'||mfi_district_name);
dbms_output.put_line('mfi_phone_no:'||mfi_phone_no);
end loop;
end;
Since I'm a beginner I do not know if this code is correct or wrong. I want to find out how to edit this and make it work using oracle reports builder.Thanks everyone.
end;
declare
You must put forward slash "/" after the END keyword to terminate the procedure block before you execute another PL/SQL anonymous block.
Put "/" after each END:
END;
/

How to call Oracle Procedure which has one OUT parameter

My oracle procedure structure,
CREATE OR REPLACE PACKAGE BODY NLS_ADMIN."MY_PKG"
AS
PROCEDURE DATA_PRC (oresult OUT NUMBER )
IS
varKeyValue varchar2(1);
BEGIN
...
...
END;
I tried to call above procedure by executing below statement,
declare
oresult NUMBER;
begin
EXECUTE DATA_PRC(oresult);
end;
But getting below exception. Please help me how to call this procedure.
ORA-06550: line 8, column 9:
PLS-00103: Encountered the symbol "DATA_PRC" when expecting one of the following:
:= . ( # % ; immediate
The symbol ":=" was substituted for "DATA_PRC" to continue.
Simply this:
declare
oresult NUMBER;
begin
MY_PKG.DATA_PRC(oresult);
end;

plsql stored procedure taking parameter gives error

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;

Resources