Error Message: ORA-01407: cannot update
("SYSADM"."PS_N_CERTMOD_TAO4"."DATE_CHAR") to NULL Failed SQL stmt: /*UPDATE
当我生成报告时,它在Peoplesoft
中表示没有成功。
以下是Update语句的代码。
请帮我解决这个问题。
先谢谢。
UPDATE %Table(N_CERTMOD_TAO) TMP
SET TMP.DATE_CHAR = ( CASE WHEN EXISTS(
SELECT A.descr254
FROM PS_N_CERTMONYR_DTL A
WHERE A.INSTITUTION = TMP.INSTITUTION
AND A.ACAD_CAREER = TMP.ACAD_CAREER
AND A.STRM = TMP.COMPLETION_TERM
AND A.ACAD_PROG = TMP.ACAD_PROG
AND A.ACAD_PLAN = TMP.ACAD_PLAN ) THEN (
SELECT A.descr254
FROM PS_N_CERTMONYR_DTL A
WHERE A.INSTITUTION = TMP.INSTITUTION
AND A.ACAD_CAREER = TMP.ACAD_CAREER
AND A.STRM = TMP.COMPLETION_TERM
AND A.ACAD_PROG = TMP.ACAD_PROG
AND A.ACAD_PLAN = TMP.ACAD_PLAN ) ELSE (CASE WHEN EXISTS(
SELECT A.descr254
FROM PS_N_CERTMONYR_DTL A
WHERE A.INSTITUTION = TMP.INSTITUTION
AND A.ACAD_CAREER = TMP.ACAD_CAREER
AND A.STRM = TMP.COMPLETION_TERM
AND A.ACAD_PROG = TMP.ACAD_PROG
AND A.ACAD_PLAN = ' ') THEN (
SELECT A.descr254
FROM PS_N_CERTMONYR_DTL A
WHERE A.INSTITUTION = TMP.INSTITUTION
AND A.ACAD_CAREER = TMP.ACAD_CAREER
AND A.STRM = TMP.COMPLETION_TERM
AND A.ACAD_PROG = TMP.ACAD_PROG
AND A.ACAD_PLAN = ' ') ELSE ( CASE WHEN EXISTS (
SELECT B.A_EXAM_SEM_DT
FROM PS_A_XM_WRES_DTT_P B
WHERE B.INSTITUTION = TMP.INSTITUTION
AND B.ACAD_CAREER = TMP.ACAD_CAREER
AND B.STRM = TMP.COMPLETION_TERM
AND B.ACAD_PROG = TMP.ACAD_PROG
AND B.ACAD_PLAN = TMP.ACAD_PLAN) THEN (
SELECT TO_CHAR(B.A_EXAM_SEM_DT)
FROM PS_A_XM_WRES_DTT_P B
WHERE B.INSTITUTION = TMP.INSTITUTION
AND B.ACAD_CAREER = TMP.ACAD_CAREER
AND B.STRM = TMP.COMPLETION_TERM
AND B.ACAD_PROG = TMP.ACAD_PROG
AND B.ACAD_PLAN = TMP.ACAD_PLAN) ELSE (
SELECT TO_CHAR(C.A_EXAM_SEM_DT)
FROM PS_A_EXAM_WRES_DTT C
WHERE C.INSTITUTION = TMP.INSTITUTION
AND C.ACAD_CAREER = TMP.ACAD_CAREER
AND C.STRM = TMP.COMPLETION_TERM
AND C.ACAD_PROG = TMP.ACAD_PROG ) END ) END ) END)
答案 0 :(得分:1)
Jared提出了修正的第一部分。
我认为C.A_EXAM_SEM_DT也可能是null
,因此您应该将TO_CHAR(C.A_EXAM_SEM_DT)
更改为NVL(TO_CHAR(C.A_EXAM_SEM_DT), ' '
考虑简化声明,例如
UPDATE %Table(N_CERTMOD_TAO) TMP
SET TMP.DATE_CHAR =
(select nvl(A.descr254, --no value? -->
nvl(AA.descr254, -- no value? -->
nvl(TO_CHAR(B.A_EXAM_SEM_DT), -- no value? -->
nvl(TO_CHAR(C.A_EXAM_SEM_DT), -- no value? -->
' ')))) -- default value
from dual D
left outer join PS_N_CERTMONYR_DTL A
on (A.INSTITUTION = TMP.INSTITUTION AND
A.ACAD_CAREER = TMP.ACAD_CAREER AND
A.STRM = TMP.COMPLETION_TERM AND
A.ACAD_PROG = TMP.ACAD_PROG AND
A.ACAD_PLAN = TMP.ACAD_PLAN)
left outer join PS_N_CERTMONYR_DTL AA
on (AA.INSTITUTION = TMP.INSTITUTION AND
AA.ACAD_CAREER = TMP.ACAD_CAREER AND
AA.STRM = TMP.COMPLETION_TERM AND
AA.ACAD_PROG = TMP.ACAD_PROG AND AA.ACAD_PLAN = ' ')
left outer join PS_A_XM_WRES_DTT_P B
on (B.INSTITUTION = TMP.INSTITUTION AND
B.ACAD_CAREER = TMP.ACAD_CAREER AND
B.STRM = TMP.COMPLETION_TERM AND
B.ACAD_PROG = TMP.ACAD_PROG AND
B.ACAD_PLAN = TMP.ACAD_PLAN)
left outer join PS_A_EXAM_WRES_DTT C
on (C.INSTITUTION = TMP.INSTITUTION AND
C.ACAD_CAREER = TMP.ACAD_CAREER AND
C.STRM = TMP.COMPLETION_TERM AND
C.ACAD_PROG = TMP.ACAD_PROG));
答案 1 :(得分:0)
您需要一个最终案例条件,以便如果它将为null,则返回一个' '代替。
UPDATE %Table(N_CERTMOD_TAO) TMP
SET TMP.DATE_CHAR = ( CASE
WHEN EXISTS(
SELECT A.descr254
FROM PS_N_CERTMONYR_DTL A
WHERE A.INSTITUTION = TMP.INSTITUTION
AND A.ACAD_CAREER = TMP.ACAD_CAREER
AND A.STRM = TMP.COMPLETION_TERM
AND A.ACAD_PROG = TMP.ACAD_PROG
AND A.ACAD_PLAN = TMP.ACAD_PLAN )
THEN (
SELECT A.descr254
FROM PS_N_CERTMONYR_DTL A
WHERE A.INSTITUTION = TMP.INSTITUTION
AND A.ACAD_CAREER = TMP.ACAD_CAREER
AND A.STRM = TMP.COMPLETION_TERM
AND A.ACAD_PROG = TMP.ACAD_PROG
AND A.ACAD_PLAN = TMP.ACAD_PLAN )
ELSE ( CASE
WHEN EXISTS(
SELECT A.descr254
FROM PS_N_CERTMONYR_DTL A
WHERE A.INSTITUTION = TMP.INSTITUTION
AND A.ACAD_CAREER = TMP.ACAD_CAREER
AND A.STRM = TMP.COMPLETION_TERM
AND A.ACAD_PROG = TMP.ACAD_PROG
AND A.ACAD_PLAN = ' ')
THEN (
SELECT A.descr254
FROM PS_N_CERTMONYR_DTL A
WHERE A.INSTITUTION = TMP.INSTITUTION
AND A.ACAD_CAREER = TMP.ACAD_CAREER
AND A.STRM = TMP.COMPLETION_TERM
AND A.ACAD_PROG = TMP.ACAD_PROG
AND A.ACAD_PLAN = ' ')
ELSE ( CASE
WHEN EXISTS (
SELECT B.A_EXAM_SEM_DT
FROM PS_A_XM_WRES_DTT_P B
WHERE B.INSTITUTION = TMP.INSTITUTION
AND B.ACAD_CAREER = TMP.ACAD_CAREER
AND B.STRM = TMP.COMPLETION_TERM
AND B.ACAD_PROG = TMP.ACAD_PROG
AND B.ACAD_PLAN = TMP.ACAD_PLAN)
THEN (
SELECT TO_CHAR(B.A_EXAM_SEM_DT)
FROM PS_A_XM_WRES_DTT_P B
WHERE B.INSTITUTION = TMP.INSTITUTION
AND B.ACAD_CAREER = TMP.ACAD_CAREER
AND B.STRM = TMP.COMPLETION_TERM
AND B.ACAD_PROG = TMP.ACAD_PROG
AND B.ACAD_PLAN = TMP.ACAD_PLAN)
ELSE ( CASE
WHEN EXISTS(
SELECT TO_CHAR(C.A_EXAM_SEM_DT)
FROM PS_A_EXAM_WRES_DTT C
WHERE C.INSTITUTION = TMP.INSTITUTION
AND C.ACAD_CAREER = TMP.ACAD_CAREER
AND C.STRM = TMP.COMPLETION_TERM
AND C.ACAD_PROG = TMP.ACAD_PROG )
THEN (
SELECT TO_CHAR(C.A_EXAM_SEM_DT)
FROM PS_A_EXAM_WRES_DTT C
WHERE C.INSTITUTION = TMP.INSTITUTION
AND C.ACAD_CAREER = TMP.ACAD_CAREER
AND C.STRM = TMP.COMPLETION_TERM
AND C.ACAD_PROG = TMP.ACAD_PROG )
ELSE
' '
END )
END )
END )
END)