I have oracle stored procedure where I pass an input parameter and get a cursor as an output parameter:
CREATE OR REPLACE PROCEDURE OS_DIVISIONDDL(
p_dept_name IN VARCHAR2,
p_cursor_division OUT SYS_REFCURSOR
) IS
tmpVar NUMBER;
BEGIN
tmpVar := 0;
OPEN p_cursor_division FOR
select Division_code,
Division_name
from DIVISION_TBL
where dept_code=p_dept_name;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
WHEN OTHERS THEN
-- Consider logging the error and then re-raise
RAISE;
END OS_DIVISIONDDL;
/
The input parameter I am able to see using dbms print, but where condition is not executed by server Am i going wrong anywhere
DIVISION_CODE CHAR (10 Char)
DIVISION_NAME VARCHAR2 (30 Char)
DEPT_CODE CHAR (10 Char)
COMPANY_CODE CHAR (3 Char)
LOCATION_CODE CHAR (3 Char)
CREATED_DATE TIMESTAMP(6)
CREATED_BY VARCHAR2 (50 Char)
MODIFIED_DATE TIMESTAMP(6)
MODIFIED_BY VARCHAR2 (50 Char)
dept_code=RPAD(p_dept_name,10);CHAR always has all the allocated spaces filled. When you hard code the String the comparison will be right always.CHAR. See e.g. stackoverflow.com/q/7747184/272735