I need your help, I am going crazy two hours trying to fix the errors of this PL/SQL code. Can someone see the mistakes I have made?
These are the errors I am receiving:
Procedure CHECK_ZIP compiled
LINE/COL ERROR
0/0 PL/SQL: Compilation unit analysis terminated
1/103 PLS-00302: component 'state' must be declared
Error at the beginning of the line : 31 nel comando -
BEGIN
check_zip('00914', 'Santurce', 'PR');
END;
Report error -
ORA-06550: line 2, column 1:
PLS-00905: object STUDENT.CHECK_ZIP is invalid
ORA-06550: line 2, column 1:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
Here the code
CREATE OR REPLACE PROCEDURE check_zip (p_zip_code IN zipcode.zip%TYPE, p_city IN zipcode.city%TYPE, p_state IN zipcode."state"%TYPE) AS
v_zip_code zipcode.zip%TYPE;
v_city zipcode.city%TYPE;
v_state zipcode."state"%TYPE;
v_existing_zip zipcode.zip%TYPE;
BEGIN
v_zip_code := p_zip_code;
v_city := p_city;
v_state := p_state;
--
SELECT ZIP
INTO v_existing_zip
FROM ZIPCODE
WHERE ZIP = v_zip_code;
-----
DBMS_OUTPUT.PUT_LINE('Il codice ZIP ' || v_zip_code || ' è già presente nel nostro database');
EXCEPTION
WHEN NO_DATA_FOUND THEN
INSERT INTO ZIPCOCE (ZIP, CITY, "STATE", CREATED_BY, CREATED_DATE, MODIFIED_BY, MODIFIED_DATE)
VALUES (v_zip_code, v_city, v_state, USER, SYSDATE, USER, SYSDATE);
END;
/
--TESTING THE PROCEDURE
BEGIN
check_zip('00914', 'Santurce', 'PR');
END;
/
I hope you can help me, thank you in advance
Create or replace PROCEDURE SSp_EmpHoursInfo
(p_EHrsInfo OUT SYS_REFCURSOR)
AS
BEGIN
OPEN p_EHrsInfo FOR
Select
a.personid, a.first_name, a.last_name,c.hoursworked,d.carecentername, c.break
from person a
join employee b on a.personid = b.empersonid
join employee_assigned_care_center c on b.empersonid = c.empersonid
join care_center d on c.empersonid = d.carecenterid
where hoursworked> 10;
END SSp_EmpHoursInfo;
Everytime I am trying to call the store procedure it is giving me this error msg:
Error starting at line : 225 in command -
BEGIN SSp_EmpHoursInfo (hoursworked> 10); END;
Error report -
ORA-06550: line 1, column 3:
PLS-00201: identifier 'HOURSWORKED' must be declared
ORA-06550: line 1, column 52:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
The problem is very obvious.
BEGIN SSp_EmpHoursInfo (hoursworked> 10); END; is not the proper way of calling it.
The procedure parameter must be the sys_refcursor.
You must use:
DECLARE
OUTPUT_CUR SYS_REFCURSOR;
BEGIN
SSp_EmpHoursInfo (OUTPUT_CUR );
-- USE CURSOR ACCORDINGLY
END;
/
I'm trying to make an Oracle function to be used with Oracle SQL Developer that the user can type cnp from the keyboard and if the cnp size is = 13 then insert it into the table that the user has loaded. if it is not = 13 then a message appears.
I did the job but it shows me errors .. I tried, I documented but I did not find where I'm wrong.
here is my table, for now I just want cnp to add it, after I will introduce the rest of the attributes in the table.:
CREATE TABLE CLIENT (
CODCLIENT NUMBER,
NUMECLIENT VARCHAR2(10),
PRENUMECLIENT VARCHAR2(15),
CNPCLIENT VARCHAR2(13),
SERIECLIENT VARCHAR2(2),
NUMARID VARCHAR2(6),
SEX VARCHAR2(10) CONSTRAINT NN_SEXC NOT NULL CONSTRAINT CK_SEXC CHECK((SEX) IN('MASCULIN','FEMININ')),
ADRESA VARCHAR2(100),
EMAIL VARCHAR2(50),
TELEFON VARCHAR2(13),
CONSTRAINT PK_CODCLIENT PRIMARY KEY (CODCLIENT)
);
And here is the error displayed:
old:DECLARE
CNP varchar2(13);
BEGIN
CNP := '&X' ;
IF CNP.LENGTH = 13 THEN
INSERT INTO CLIENT(CNPCLIENT) VALUES(CNP);
ELSE
DBMS_OUTPUT.PUT_LINE('CNP INCORECT');
END IF;
END;
new:DECLARE
CNP varchar2(13);
BEGIN
CNP := '23241415151' ;
IF CNP.LENGTH = 13 THEN
INSERT INTO CLIENT(CNPCLIENT) VALUES(CNP);
ELSE
DBMS_OUTPUT.PUT_LINE('CNP INCORECT');
END IF;
END;
Error starting at line : 30 in command -
DECLARE
CNP varchar2(13);
BEGIN
CNP := '&X' ;
IF CNP.LENGTH = 13 THEN
INSERT INTO CLIENT(CNPCLIENT) VALUES(CNP);
ELSE
DBMS_OUTPUT.PUT_LINE('CNP INCORECT');
END IF;
END;
Error report -
ORA-06550: line 7, column 12:
PLS-00487: Invalid reference to variable 'CNP'
ORA-06550: line 7, column 5:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
Oracle LENGTH function has the following syntax:
LENGTH( string1 )
You can find more about it here: https://www.techonthenet.com/oracle/functions/length.php
In your code, instead of IF CNP.LENGTH = 13 you should'e written the following:
IF LENGTH(CNP) = 13
I hope I helped!
logged as the user CC_LOPES I have this procedure:
create or replace PACKAGE BODY "P_MSG_HOTEL" AS
function parse_msg(p_id in number, p_msg in varchar2) return number is
...
end;
That I try to execute from Oracle SQL Developer with
EXECUTE P_MSG_HOTEL.parse_msg(596210657, '#S,358639058787154;E,10;D,05102017145210,05102017145210;G,4046393,51206983,258,8;M,4709;S,0;IO,1,0,0;DI,79DEAD60');
I got this error:
Error que empieza en la línea: 1 del comando :
BEGIN P_MSG_HOTEL.parse_msg(596210657, '#S,358639058787154;E,10;D,05102017145210,05102017145210;G,4046393,51206983,258,8;M,4709;S,0;IO,1,0,0;DI,79DEAD60'); END;
Informe de error -
ORA-06550: línea 1, columna 126:
PLS-00306: wrong number or types of arguments in call to 'PARSE_MSG'
ORA-06550: línea 1, columna 126:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
Am really excited to know incase you really got the error you mentioned in your question.
Ideally you must had got something like:
*
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00221: 'PARSE_MSG' is not a procedure or is undefined
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
But you posted :
Error que empieza en la línea: 1 del comando :
BEGIN P_MSG_HOTEL.parse_msg(596210657, '#S,358639058787154;E,10;D,05102017145210,05102017145210;G,4046393,51206983,258,8;M,4709;S,0;IO,1,0,0;DI,79DEAD60'); END;
Informe de error -
ORA-06550: línea 1, columna 126:
PLS-00306: wrong number or types of arguments in call to 'PARSE_MSG'
ORA-06550: línea 1, columna 126:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
This looks quiet misleading.
I did the below demo to show what i meant.
CREATE OR REPLACE PACKAGE P_MSG_HOTEL
AS
FUNCTION parse_msg (p_id IN NUMBER, p_msg IN VARCHAR2)
RETURN NUMBER;
END;
/
CREATE OR REPLACE PACKAGE BODY P_MSG_HOTEL
AS
FUNCTION parse_msg (p_id IN NUMBER, p_msg IN VARCHAR2)
RETURN NUMBER
IS
BEGIN
RETURN 1;
END;
END;
On execution the way you showed it gives the error which say :
EXECUTE P_MSG_HOTEL.parse_msg(596210657,
'#S,358639058787154;E,10;D,05102017145210,05102017145210;G,4046393,51206983,258,8;M,4709;S,0;IO,1,0,0;DI,79DEAD60');
Error
*
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00221: 'PARSE_MSG' is not a procedure or is undefined
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
This clearly means Oracle is not able to identify your function while execution.
However when i do like:
SQL>
select P_MSG_HOTEL.parse_msg(596210657, '#S,358639058787154;E,10;D,05102017145210,05102017145210;G,4046393,51206983,258,8;M,4709;S,0;IO,1,0,0;DI,79DEAD60') as col
from dualSQL> 2
3 /
COL
----------
1
I get the output.
Or if i use an Anonymous block i get the result.
SQL> DECLARE
x NUMBER;
BEGIN
x :=
P_MSG_HOTEL.parse_msg (
596210657,
'#S,358639058787154;E,10;D,05102017145210,05102017145210;G,4046393,51206983,258,8;M,4709;S,0;IO,1,0,0;DI,79DEAD60');
2 DBMS_OUTPUT.put_line (x);
END;
/
1
PL/SQL procedure successfully completed.
SQL>
So, in short, you cannot use the function the way you are executing.
Don't execute the function directly . either do it inside DBMS_OUTPUT
SET SERVEROUTPUT ON
EXEC DBMS_OUTPUT.PUT_LINE(P_MSG_HOTEL.parse_msg(arg1,arg2));
Or run a query with function in select to get the output.
select P_MSG_HOTEL.parse_msg(arg1,arg2) FROM DUAL;
You cannot use execute command to execute a function, the function return some value that needs to be captured somewhere, Use anonymous block:
declare
f_return number;
begin
f_return := P_MSG_HOTEL.parse_msg(596210657, '#S,358639058787154;E,10;D,05102017145210,05102017145210;G,4046393,51206983,258,8;M,4709;S,0;IO,1,0,0;DI,79DEAD60');
end;
/
I'm trying to run a concurrent request in APPS but i keep getting this error
(Cause: FDPSTP failed due to ORA-06550: line 1, column 7:
PLS-00221: 'XXINV_ITEM_ORACLE_E5B0' is not a procedure or is undefined
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored)
and heres my package body its just a simple insert.
CREATE OR REPLACE PACKAGE BODY APPS.XXINV_ITEM_ORACLE_E5B0 IS
PROCEDURE inv_com_proc (
o_chr_errbuf OUT VARCHAR2,
o_num_retcode OUT NUMBER
)
AS
begin
EXECUTE IMMEDIATE 'TRUNCATE TABLE XXINV.XXINV_ITEM_ORACLE_E5B0';
Insert into XXINV.XXINV_ITEM_ORACLE_E5B0(ORGANIZATION_CODE ,
ITEM_NUM,
ON_HAND_QUANTITY ,
ITEM_TYPE ,
STATUS ,
MATERIAL_COST ,
MATERIAL_OVERHEAD_COST,
RESOURCE_COST,
OVERHEAD_COST,
OUTSIDE_PROCESSING_COST,
SUBINVENTORY_CODE ,
LOCATORS )
select OWNING_ORG_CODE, ITEM_NUMBER, ON_HAND_QUANTITY, ITEM_TYPE, STATUS, MATERIAL_COST ,
MATERIAL_OVERHEAD_COST,
RESOURCE_COST,
OVERHEAD_COST,
OUTSIDE_PROCESSING_COST,
SUBINVENTORY_CODE ,
LOCATOR
from apps.XXRPT_INV_VALUATION_D535_V
where apps.XXRPT_INV_VALUATION_D535_V.SUBINVENTORY_CODE = 'FG' AND apps.XXRPT_INV_VALUATION_D535_V.STATUS = 'ONHAND';
COMMIT;
END;
end XXINV_ITEM_ORACLE_E5B0;
When you define the Concurrent Program Executable in System Administration, make sure you the Execution File Name includes the schema.package.procedure, as in APPS.XXINV_ITEM_ORACLE_E5B0.inv_com_proc (no parenthesis).
It seems you're trying to execute the package itself - that won't work. You must execute a procedure/function within the package:
DECLARE
o_chr_errbuf VARCHAR2(256);
o_num_retcode NUMBER;
BEGIN
APPS.XXINV_ITEM_ORACLE_E5B0.inv_com_proc ( o_chr_errbuf, o_num_retcode);
END;
/
A simple test:
DECLARE
err VARCHAR2(256);
CODE NUMBER;
BEGIN xx(err, CODE); END;
ORA-06550: line 5, column 7:
PLS-00221: 'XX' is not a procedure or is undefined
ORA-06550: line 5, column 7:
PL/SQL: Statement ignored
SQL> SELECT * FROM a;
ID
---------------------------------------
SQL> DECLARE
2 err VARCHAR2(256);
3 CODE NUMBER;
4 BEGIN
5 xx.tst(err, CODE);
6 END;
7 /
PL/SQL procedure successfully completed
SQL> SELECT * FROM a;
ID
---------------------------------------
1