declare
l_body_html varchar2(4000);
BEGIN
IF :P45_VALUE_TYPE = 'D' and :P45_ATTRIBUTE7 is null and :P45_ATTRIBUTE4 is not null or :P45_ATTRIBUTE6 IS NOT NULL THEN
l_body_html := '<p>A new request, number '||:P45_Request_ID||' has '||
'been SUmbimitted. To review this request, click the '||
'link below.</p><p><a href="http://'||OWA_UTIL.GET_CGI_ENV('HTTP_HOST')||
OWA_UTIL.GET_CGI_ENV('SCRIPT_NAME')||'/f?p='||:APP_ID||':11:6495753734862::NO'||'">View Request'||:P45_Request_ID||
'</a></p>';
HTMLDB_MAIL.SEND(
P_TO => 'testing.test@testing.com',
P_FROM => 'testing.test@testing.com',
P_BODY => l_body_html,
P_BODY_HTML => l_body_html,
P_SUBJ => 'New Request Number '||:P45_Request_ID);
:P45_APPROVAL_STATUS := 'FINAL';
end if;
IF :P45_VALUE_TYPE = 'S' and :P45_ATTRIBUTE7 is null and :P45_ATTRIBUTE4 is not null or :P45_ATTRIBUTE5 IS NOT NULL THEN
l_body_html := '<p>A new request, number '||:P45_Request_ID||' has '||
'been SUmbimitted. To review this request, click the '||
'link below.</p><p><a href="http://'||OWA_UTIL.GET_CGI_ENV('HTTP_HOST')||
OWA_UTIL.GET_CGI_ENV('SCRIPT_NAME')||'/f?p='||:APP_ID||':11:6495753734862::NO'||'">View Request'||:P45_Request_ID||
'</a></p>';
HTMLDB_MAIL.SEND(
P_TO => 'testing.test@testing.com',
P_FROM => 'testing.test@testing.com',
P_BODY => l_body_html,
P_BODY_HTML => l_body_html,
P_SUBJ => 'New Request Number '||:P45_Request_ID);
:P45_APPROVAL_STATUS := 'FINAL';
end if;
IF :P45_VALUE_TYPE = 'A' and :P45_ATTRIBUTE7 is null and :P45_ATTRIBUTE4 is NULL and :P45_ATTRIBUTE5 IS NOT NULL THEN
l_body_html := '<p>A new request, number '||:P45_Request_ID||' has '||
'been SUmbimitted. To review this request, click the '||
'link below.</p><p><a href="http://'||OWA_UTIL.GET_CGI_ENV('HTTP_HOST')||
OWA_UTIL.GET_CGI_ENV('SCRIPT_NAME')||'/f?p='||:APP_ID||':11:6495753734862::NO'||'">View Request'||:P45_Request_ID||
'</a></p>';
HTMLDB_MAIL.SEND(
P_TO => 'testing.test@testing.com',
P_FROM => 'testing.test@testing.com',
P_BODY => l_body_html,
P_BODY_HTML => l_body_html,
P_SUBJ => 'New Request Number '||:P45_Request_ID);
:P45_APPROVAL_STATUS := 'Center';
ELSIF :P45_VALUE_TYPE = 'A' and :P45_ATTRIBUTE4 is not null and :P45_ATTRIBUTE7 is null and :P45_ATTRIBUTE5 IS NULL THEN
l_body_html := '<p>A new request, number '||:P45_Request_ID||' has '||
'been SUmbimitted. To review this request, click the '||
'link below.</p><p><a href="http://'||OWA_UTIL.GET_CGI_ENV('HTTP_HOST')||
OWA_UTIL.GET_CGI_ENV('SCRIPT_NAME')||'/f?p='||:APP_ID||':11:6495753734862::NO'||'">View Request'||:P45_Request_ID||
'</a></p>';
HTMLDB_MAIL.SEND(
P_TO => 'testing.test@testing.com',
P_FROM => 'testing.test@testing.com',
P_BODY => l_body_html,
P_BODY_HTML => l_body_html,
P_SUBJ => 'New Request Number '||:P45_Request_ID);
:P45_APPROVAL_STATUS := 'FINAL';
end if;
IF :P45_VALUE_TYPE = 'M' and :P45_ATTRIBUTE7 is null and :P45_ATTRIBUTE4 is NULL and :P45_ATTRIBUTE5 IS NOT NULL THEN
l_body_html := '<p>A new request, number '||:P45_Request_ID||' has '||
'been SUmbimitted. To review this request, click the '||
'link below.</p><p><a href="http://'||OWA_UTIL.GET_CGI_ENV('HTTP_HOST')||
OWA_UTIL.GET_CGI_ENV('SCRIPT_NAME')||'/f?p='||:APP_ID||':11:6495753734862::NO'||'">View Request'||:P45_Request_ID||
'</a></p>';
HTMLDB_MAIL.SEND(
P_TO => 'testing.test@testing.com',
P_FROM => 'testing.test@testing.com',
P_BODY => l_body_html,
P_BODY_HTML => l_body_html,
P_SUBJ => 'New Request Number '||:P45_Request_ID);
:P45_APPROVAL_STATUS := 'Center';
ELSIF :P45_VALUE_TYPE = 'M' and :P45_ATTRIBUTE4 is not null and :P45_ATTRIBUTE7 is null and :P45_ATTRIBUTE5 IS NULL THEN
l_body_html := '<p>A new request, number '||:P45_Request_ID||' has '||
'been SUmbimitted. To review this request, click the '||
'link below.</p><p><a href="http://'||OWA_UTIL.GET_CGI_ENV('HTTP_HOST')||
OWA_UTIL.GET_CGI_ENV('SCRIPT_NAME')||'/f?p='||:APP_ID||':11:6495753734862::NO'||'">View Request'||:P45_Request_ID||
'</a></p>';
HTMLDB_MAIL.SEND(
P_TO => 'testing.test@testing.com',
P_FROM => 'testing.test@testing.com',
P_BODY => l_body_html,
P_BODY_HTML => l_body_html,
P_SUBJ => 'New Request Number '||:P45_Request_ID);
:P45_APPROVAL_STATUS := 'FINAL';
end if;
IF :P45_VALUE_TYPE = 'F' and P:45_ATTRIBUTE7 is null and :P45_ATTRIBUTE4 is NULL and :P45_ATTRIBUTE5 IS NOT NULL THEN
l_body_html := '<p>A new request, number '||:P45_Request_ID||' has '||
'been SUmbimitted. To review this request, click the '||
'link below.</p><p><a href="http://'||OWA_UTIL.GET_CGI_ENV('HTTP_HOST')||
OWA_UTIL.GET_CGI_ENV('SCRIPT_NAME')||'/f?p='||:APP_ID||':11:6495753734862::NO'||'">View Request'||:P45_Request_ID||
'</a></p>';
HTMLDB_MAIL.SEND(
P_TO => 'testing.test@testing.com',
P_FROM => 'testing.test@testing.com',
P_BODY => l_body_html,
P_BODY_HTML => l_body_html,
P_SUBJ => 'New Request Number '||:P45_Request_ID);
:P45_APPROVAL_STATUS := 'Center';
ELSIF :P45_VALUE_TYPE = 'F' and :P45_ATTRIBUTE4 is not null and :P45_ATTRIBUTE7 is null and :P45_ATTRIBUTE5 IS NULL THEN
l_body_html := '<p>A new request, number '||:P45_Request_ID||' has '||
'been SUmbimitted. To review this request, click the '||
'link below.</p><p><a href="http://'||OWA_UTIL.GET_CGI_ENV('HTTP_HOST')||
OWA_UTIL.GET_CGI_ENV('SCRIPT_NAME')||'/f?p='||:APP_ID||':11:6495753734862::NO'||'">View Request'||:P45_Request_ID||
'</a></p>';
HTMLDB_MAIL.SEND(
P_TO => 'testing.test@testing.com',
P_FROM => 'testing.test@testing.com',
P_BODY => l_body_html,
P_BODY_HTML => l_body_html,
P_SUBJ => 'New Request Number '||:P45_Request_ID);
:P45_APPROVAL_STATUS := 'FINAL';
end if;
end;
我正在尝试创建一个pl / sql,在某些条件下向用户发送电子邮件,并设置:P45_APPROVAL_STATUS值取决于IF语句。但是我得到了 &#34; ORA-01461:只能插入一个LONG值以插入LONG列&#34;错误提示。我的代码有问题吗?如果是这样,我怎样才能使它发挥作用?
一切都有帮助!
答案 0 :(得分:0)
这是对代码的重构,可以消除一些重复:
declare
l_body_html varchar2(4000);
BEGIN
l_body_html := '<p>A new request, number '||:P45_Request_ID||' has '||
'been SUmbimitted. To review this request, click the '||
'link below.</p><p><a href="http://'||OWA_UTIL.GET_CGI_ENV('HTTP_HOST')||
OWA_UTIL.GET_CGI_ENV('SCRIPT_NAME')||'/f?p='||:APP_ID||':11:6495753734862::NO'||'">View Request'||:P45_Request_ID||
'</a></p>';
IF (:P45_VALUE_TYPE = 'D' and :P45_ATTRIBUTE7 is null and :P45_ATTRIBUTE4 is not null or :P45_ATTRIBUTE6 IS NOT NULL)
OR (:P45_VALUE_TYPE = 'S' and :P45_ATTRIBUTE7 is null and :P45_ATTRIBUTE4 is not null or :P45_ATTRIBUTE5 IS NOT NULL)
OR (:P45_VALUE_TYPE = 'A' and :P45_ATTRIBUTE7 is null and :P45_ATTRIBUTE4 is NULL and :P45_ATTRIBUTE5 IS NOT NULL)
OR (:P45_VALUE_TYPE = 'A' and :P45_ATTRIBUTE4 is not null and :P45_ATTRIBUTE7 is null and :P45_ATTRIBUTE5 IS NULL)
OR (:P45_VALUE_TYPE = 'M' and :P45_ATTRIBUTE7 is null and :P45_ATTRIBUTE4 is NULL and :P45_ATTRIBUTE5 IS NOT NULL)
OR (:P45_VALUE_TYPE = 'M' and :P45_ATTRIBUTE4 is not null and :P45_ATTRIBUTE7 is null and :P45_ATTRIBUTE5 IS NULL)
OR (:P45_VALUE_TYPE = 'F' and :P45_ATTRIBUTE7 is null and :P45_ATTRIBUTE4 is NULL and :P45_ATTRIBUTE5 IS NOT NULL)
OR (:P45_VALUE_TYPE = 'F' and :P45_ATTRIBUTE4 is not null and :P45_ATTRIBUTE7 is null and :P45_ATTRIBUTE5 IS NULL)
THEN
HTMLDB_MAIL.SEND(
P_TO => 'testing.test@testing.com',
P_FROM => 'testing.test@testing.com',
P_BODY => l_body_html,
P_BODY_HTML => l_body_html,
P_SUBJ => 'New Request Number '||:P45_Request_ID);
END IF;
IF (:P45_VALUE_TYPE = 'D' and :P45_ATTRIBUTE7 is null and :P45_ATTRIBUTE4 is not null or :P45_ATTRIBUTE6 IS NOT NULL)
OR (:P45_VALUE_TYPE = 'S' and :P45_ATTRIBUTE7 is null and :P45_ATTRIBUTE4 is not null or :P45_ATTRIBUTE5 IS NOT NULL)
OR (:P45_VALUE_TYPE = 'A' and :P45_ATTRIBUTE4 is not null and :P45_ATTRIBUTE7 is null and :P45_ATTRIBUTE5 IS NULL)
OR (:P45_VALUE_TYPE = 'M' and :P45_ATTRIBUTE4 is not null and :P45_ATTRIBUTE7 is null and :P45_ATTRIBUTE5 IS NULL)
OR (:P45_VALUE_TYPE = 'F' and :P45_ATTRIBUTE4 is not null and :P45_ATTRIBUTE7 is null and :P45_ATTRIBUTE5 IS NULL) THEN
:P45_APPROVAL_STATUS := 'FINAL';
ELSIF (:P45_VALUE_TYPE = 'A' and :P45_ATTRIBUTE7 is null and :P45_ATTRIBUTE4 is NULL and :P45_ATTRIBUTE5 IS NOT NULL)
OR (:P45_VALUE_TYPE = 'M' and :P45_ATTRIBUTE7 is null and :P45_ATTRIBUTE4 is NULL and :P45_ATTRIBUTE5 IS NOT NULL)
OR (:P45_VALUE_TYPE = 'F' and P:45_ATTRIBUTE7 is null and :P45_ATTRIBUTE4 is NULL and :P45_ATTRIBUTE5 IS NOT NULL) THEN
:P45_APPROVAL_STATUS := 'Center';
end if;
end;
希望您现在可以看到IF
条件可以大大简化。下一步是订购属性4,5,6和7的检查,这应该清楚表明你可以删除很多属性。