I'm trying to create a procedure in PL/SQL and I receive the following error:
Errors: PROCEDURE BORRAR_PELI
Line/Col: 10/1 PLS-00103: Encountered the symbol "EXCEPTION" when expecting one of the following:
( begin case declare end exit for goto if loop mod null
pragma raise return select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
continue close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe purge
json_exists json_value json_query json_object json_array***
My procedure:
CREATE OR REPLACE PROCEDURE borrar_peli(delete_id peliculas.id%TYPE)
IS
corrupto EXCEPTION;
precio_dia_v peliculas.precio_dia%TYPE;
BEGIN
SELECT precio_dia INTO precio_dia_v FROM peliculas WHERE id = delete_id;
IF precio_dia_v > 4 THEN
RAISE corrupto;
ELSE
DELETE FROM pelĂculas WHERE id = delete_id;
COMMIT;
END IF;
EXCEPTION
WHEN corrupto THEN
DBMS_OUTPUT.put_line('es corrupto');
WHEN OTHERS THEN
DBMS_OUTPUT.put_line('Error code ' || SQLCODE || ': ' || SQLCODE);
END;
My Stored Procedure compiles, however; when I try to call it i get the following error:
Encountered the symbol "IS" when expecting one of the following:
constant exception <an identifier>
<a double-quoted delimited-identifier> table long double ref
char time timestamp interval date binary national character
nchar
The symbol "IS" was ignored.
ORA-06550: line 2, column 48:
PLS-00103: Encountered the symbol "," when expecting one of the following:
:= ( ; not null range default character
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
My Stored Procedure is as follows:
create or replace procedure p_xml
(v_utc_offset in XML_HOURS_LOAD.UTCOFFSET%type
, v_data_date in XML_HOURS_LOAD.DATA_DATE%type
, v_data_type in XML_HOURS_LOAD.DATA_TYPE%type
, v_posted_value in XML_HOURS_LOAD.POSTEDVALUE%type
, v_utc_value in XML_HOURS_LOAD.UTCVALUE%type
, v_hour in XML_HOURS_LOAD.HOUR%type
, v_data_code in XML_HOURS_LOAD.DATA_CODE%type
)
AS
BEGIN
if v_utc_offset >= 4 THEN
INSERT INTO xml_hours_Load (UTCOffset, Data_date, Data_Type, PostedValue, UTCValue, Hour, Data_Code)
VALUES(v_utc_offset, v_data_date, v_data_type, v_posted_value, v_utc_value, v_hour, v_data_code);
COMMIT;
END IF;
END;
How I am calling it (and what is returning the error listed above) is as follows:
DECLARE
v_utc_offset is XML_HOURS_LOAD.UTCOFFSET%type,
v_data_date is XML_HOURS_LOAD.DATA_DATE%type,
v_data_type is XML_HOURS_LOAD.DATA_TYPE%type,
v_posted_value is XML_HOURS_LOAD.POSTEDVALUE%type,
v_utc_value is XML_HOURS_LOAD.UTCVALUE%type,
v_hour is XML_HOURS_LOAD.HOUR%type,
v_data_code is XML_HOURS_LOAD.DATA_CODE%type;
CURSOR cXmlHoursLoadCursor is (SELECT utcoffset, data_date, data_type, postedvalue, utcvalue, hour, data_code
from xml_hours_load);
BEGIN
FOR v in cXmlHoursLoadCursor LOOP
p_xml(v.utcoffset, v.data_date, v.data_type, v.postedvalue, v.utcvalue, v.hour, v.data_code);
COMMIT;
END LOOP;
END;
Thanks in Advance!
In your anonymous block, the CURSOR is the only variable you should declare using the IS keyword. Remove it from the others.
DECLARE
v_utc_offset XML_HOURS_LOAD.UTCOFFSET%type;
v_data_date XML_HOURS_LOAD.DATA_DATE%type;
v_data_type XML_HOURS_LOAD.DATA_TYPE%type;
v_posted_value XML_HOURS_LOAD.POSTEDVALUE%type;
v_utc_value XML_HOURS_LOAD.UTCVALUE%type;
v_hour XML_HOURS_LOAD.HOUR%type;
v_data_code XML_HOURS_LOAD.DATA_CODE%type;
CURSOR cXmlHoursLoadCursor is (SELECT utcoffset, data_date, data_type, postedvalue, utcvalue, hour, data_code
from xml_hours_load);
BEGIN
FOR v in cXmlHoursLoadCursor LOOP
p_xml(v.utcoffset, v.data_date, v.data_type, v.postedvalue, v.utcvalue, v.hour, v.data_code);
COMMIT;
END LOOP;
END;
I get the following error when trying to run my code:
BEGIN
IF((select count(*) from tablename where column = 'value') > 0) THEN
-- do stuff.
ELSE
-- do stuff.
END IF;
END;
Error:
ORA-06550: line 2, column 5:
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>
continue avg count current exists max min prior sql stddev
sum variance execute forall merge time timestamp interval
date <a string literal with character set specification>
<a number> <a single-quoted SQL string> pipe
<an alternatively-quoted string literal with character set specification>
Obviously the error code makes no sense. I'm getting used to this when working with Oracle.
The COUNT() function exists in PL. What else could it be.
Lance Link is that you under cover? You can't have a query in an IF statement. First do the query as a select INTO a variable, then test the variable:
DECLARE
v_count number;
BEGIN
select count(*)
into v_count
from tablename
where column = 'value';
IF ( v_count > 0) THEN
-- do stuff.
ELSE
-- do stuff.
END IF;
END;
Give Mata my regards.
I have found this PL/SQL code but I can't find in Oracle documentation to be valid:
CREATE OR REPLACE PROCEDURE hard_priv AS
BEGIN
HTP.htmlOpen;
HTP.headOpen;
HTP.title (.Account Information.);
HTP.headClose;
HTP.bodyOpen;
HTP.br;
HTP.print('User ID: ' ||
OWA_SEC.get_user_id || '');
HTP.print('User Password: ' ||
OWA_SEC.get_password || '');
HTP.br;
HTP.bodyClose;
HTP.htmlClose;
END hard_priv;
END uu_hr_pkg;
"(." and ".)" is not PLSQL syntax.
So it cannot compile.
This simple:
begin
dbms_output.put_line('this is the right syntax');
dbms_output.put_line(.this_dont_work.);
end;
/
Gives a compilation error like that:
SQL> #a
dbms_output.put_line(.this_dont_work.);
*
ERROR at line 3:
ORA-06550: line 3, column 26:
PLS-00103: Encountered the symbol "." 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
In the real world, you must replace them with '; your thing should be:
CREATE OR REPLACE PROCEDURE hard_priv AS
BEGIN
HTP.htmlOpen;
HTP.headOpen;
HTP.title ('Account Information');
HTP.headClose;
....
I using oracle developer tools for viusal studio to develop my pl/sql program,however,I encounter a problem with this simple code
Here is the code
BEGIN
DBMS_OUTPUT.PUT_LINE('helloWorld');
END;
the debug info as follow:
**ERROR
ORA-06550: line 1, column 6:
PLS-00103: Encountered the symbol "" when expecting one of the following:
begin case declare exit for goto if loop mod null pragma
raise return select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge
<a single-quoted SQL string> pipe
<an alternatively-quoted SQL string>
The symbol "" was ignored.
ORA-06550: line 2, column 36:
PLS-00103: Encountered the symbol "" when expecting one of the following:
begin case declare end exception exit for goto if loop mod
null pragma raise return select update while with
<an identifier> <a double-quoted delimited-id**
try:
DECLARE
v_var VARCHAR2(15) := 'helloworld';
BEGIN
DBMS_OUTPUT.PUT_LINE(v_var);
END;