我已经创建了一个过程来根据输入参数p_full_name
打印员工的项目详细信息,但它不打印详细信息,而是进入异常块。任何人都可以检查并帮助我纠正错误,以便打印员工的详细信息。
代码:
create or replace PROCEDURE project_details (p_full_name IN VARCHAR2,
p_name OUT VARCHAR2,
p_status_code OUT NUMBER,
p_project_type OUT VARCHAR2,
p_start_date OUT DATE,
p_end_date OUT DATE)
IS
cursor c_project is
SELECT distinct xpppa.name Project_Name,
pps.project_status_code ,
xpppa.project_type ,
xpppa.start_date,
xpppa.completion_date
FROM xxcas_prj_pa_projects_all xpppa,
PA_PROJECT_STATUSES pps,
XXCAS_PRJ_PA_PROJECT_PLAYERS xpppp,
PER_ALL_PEOPLE_F papf
WHERE xpppa.project_status_code = pps.project_status_code
AND xpppa.project_id = xpppp.project_id
AND xpppp.person_id = papf.person_id
AND papf.full_name=p_full_name--'Mahajan, Himani'
AND xpppp.project_role_type = 'PROJECT MANAGER'
AND pps.project_status_code IN ('1042', '1043')
and papf.person_type_id=6
and sysdate between xpppp.start_date_active and nvl(xpppp.end_date_active,sysdate+1)
and sysdate between papf.effective_start_date and nvl(papf.effective_end_date,sysdate+1);
l_project_details c_project%rowtype;
begin
open c_project;
loop
fetch c_project into l_project_details;
exit when c_project%NOTFOUND;
debug( 'Project name: '||l_project_details.Project_Name
||' Project status code: '||l_project_details.Project_Status_Code
||' Project type: '||l_project_details.project_type
||' Project start date: '||l_project_details.start_date
||' Project end date: '||l_project_details.completion_date);
end loop;
close c_project;
exception
when others then
debug('Please provide valid input');
end project_details;
答案 0 :(得分:1)
要调试,请用
替换上一个块exception
when others then
debug('error is:'||SQLERRM);
debug('Project name :'||l_project_details.Project_Name
||' Project Status Code :'||l_project_details.Project_Status_Code
||'Project Type :'||l_project_details.project_type
||'Project start date :'||l_project_details.start_date
||'Project End Date : '||l_project_details.completion_date);
--debug('Please provide valid input');
end project_details;
你会了解更多。
答案 1 :(得分:1)
代码中的DEBUG
是什么。我没有看到DEBUG
在PLSQL
中打印内容是正确的。如果要打印某些内容,请将DEBUG
替换为DBMS_OUTPUT.PUT_LINE
。见下文。
CREATE OR REPLACE PROCEDURE PROJECT_DETAILS (
P_FULL_NAME IN VARCHAR2,
P_NAME OUT VARCHAR2,
P_STATUS_CODE OUT NUMBER,
P_PROJECT_TYPE OUT VARCHAR2,
P_START_DATE OUT DATE,
P_END_DATE OUT DATE)
IS
CURSOR C_PROJECT
IS
SELECT DISTINCT XPPPA.NAME PROJECT_NAME,
PPS.PROJECT_STATUS_CODE,
XPPPA.PROJECT_TYPE,
XPPPA.START_DATE,
XPPPA.COMPLETION_DATE
FROM XXCAS_PRJ_PA_PROJECTS_ALL XPPPA,
PA_PROJECT_STATUSES PPS,
XXCAS_PRJ_PA_PROJECT_PLAYERS XPPPP,
PER_ALL_PEOPLE_F PAPF
WHERE XPPPA.PROJECT_STATUS_CODE = PPS.PROJECT_STATUS_CODE
AND XPPPA.PROJECT_ID = XPPPP.PROJECT_ID
AND XPPPP.PERSON_ID = PAPF.PERSON_ID
AND PAPF.FULL_NAME = P_FULL_NAME --'Mahajan, Himani'
AND XPPPP.PROJECT_ROLE_TYPE = 'PROJECT MANAGER'
AND PPS.PROJECT_STATUS_CODE IN ('1042', '1043')
AND PAPF.PERSON_TYPE_ID = 6
AND SYSDATE BETWEEN XPPPP.START_DATE_ACTIVE
AND NVL (XPPPP.END_DATE_ACTIVE,
SYSDATE + 1)
AND SYSDATE BETWEEN PAPF.EFFECTIVE_START_DATE
AND NVL (PAPF.EFFECTIVE_END_DATE,
SYSDATE + 1);
L_PROJECT_DETAILS C_PROJECT%ROWTYPE;
BEGIN
OPEN C_PROJECT;
LOOP
FETCH C_PROJECT
INTO L_PROJECT_DETAILS;
EXIT WHEN C_PROJECT%NOTFOUND;
DBMS_OUTPUT.PUT_LINE ( 'Project name :'
|| L_PROJECT_DETAILS.PROJECT_NAME
|| ' Project Status Code :'
|| L_PROJECT_DETAILS.PROJECT_STATUS_CODE
|| 'Project Type :'
|| L_PROJECT_DETAILS.PROJECT_TYPE
|| 'Project start date :'
|| L_PROJECT_DETAILS.START_DATE
|| 'Project End Date : '
|| L_PROJECT_DETAILS.COMPLETION_DATE);
END LOOP;
CLOSE C_PROJECT;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE ('Please provide valid input');
END PROJECT_DETAILS;
注意使用正确的异常处理程序,因为DBMS_OUTPUT不会引发任何问题,而只会成功显示消息和完整的过程。