[英]PL/SQL FUNCTION WITH VARCHAR PARAMETER
The question asked for people who is born after 30th June 1990 to take injection.该问题要求 1990 年 6 月 30 日之后出生的人进行注射。 It asks the user to enter his/her id.
它要求用户输入他/她的 id。 I got error saying that 'literal does not match format string'.
我收到错误消息,提示“文字与格式字符串不匹配”。 I don't know how to return varchar in plsql function.
我不知道如何在 plsql function 中返回 varchar。 Here is my code:
这是我的代码:
create or replace function p_immune (ptdob in date)
return varchar2
is sta_imm varchar2(30);
BEGIN
if ptdob > '30th June 1990 ' then sta_imm := 'REQUIRED';
else sta_imm := 'NOT REQUIRED';
end if;
return(sta_imm);
END p_immune; /
Accept pt_id prompt 'Enter the patient ID: '
DECLARE
v_dob patient.ptdob%type; v_ptdob patient.ptdob%type;
BEGIN
select ptdob
into v_dob
from patient
where pt_id = &pt_id;
dbms_output.put_line('Enter the patient ID: '||&pt_id);
dbms_output.put_line('The status of X-immunization :'||p_immune(v_ptdob));
END; /
Use date literal:使用日期文字:
if ptdob > date '1990-06-30' then sta_imm := 'REQUIRED';
or TO_DATE
with appropriate format mask (and language):或带有适当格式掩码(和语言)的
TO_DATE
:
if ptdob > to_date('30th June 1990', 'ddth Month yyyy', 'nls_date_language = english') then sta_imm := 'REQUIRED';
Also, make sure you pass DATE
datatype value to the function.此外,确保将
DATE
数据类型值传递给 function。 How?如何? As described above.
如上所述。 Don't pass strings .
不要传递字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.