if p_quarter = '1' then
str_month := p_year+'-01-01';
end_month := p_year+'-04-01';
elsif p_quarter = '2' then
str_month := p_year+'-04-01';
end_month := p_year+'-07-01';
elsif p_quarter = '3' then
str_month := p_year+'-07-01';
end_month := p_year+'-10-01';
else
str_month := p_year+'-10-01';
end_month := to_char(to_number(p_year)+1)+'-01-01';
end if;
p_quarter 表示的是季度、p_year 表示年份、为什么这样写判断不出来、要怎么写才可以、
过程没有语法错误
我以前没写过过程、所以不懂
str_month := p_year+'-01-01';
end_month := p_year+'-04-01';
elsif p_quarter = '2' then
str_month := p_year+'-04-01';
end_month := p_year+'-07-01';
elsif p_quarter = '3' then
str_month := p_year+'-07-01';
end_month := p_year+'-10-01';
else
str_month := p_year+'-10-01';
end_month := to_char(to_number(p_year)+1)+'-01-01';
end if;
p_quarter 表示的是季度、p_year 表示年份、为什么这样写判断不出来、要怎么写才可以、
过程没有语法错误
我以前没写过过程、所以不懂
解决方案 »
- 数据库定时删除备份不执行了。高分求原因和处理问题。
- 请问oracle的补丁在那里下载?官网上好像都下不了
- odp.net 连接到oracle: “Oracle.DataAccess.Client.OracleConnection”的类型初始值设定项引发异常。
- ORACLE触发器问题
- 高手们快来看看这条语句。错误怎么解决
- 如何用“语句”把 00000001-99999999插入表中 (oracle817)
- 想要比较两张表的内容是否完全一致应该如何做???
- 启动 Oracle Names Server出现错误?
- 请问有谁考过OCP认证, 谈谈你们的想法和看法! 让我们一起交流好吗?
- 通过 BDE 操作 ORACLE8I 数据库中表文件的问题
- 如何计算当前时间加 一小时后的时间?一个月呢?
- 急求SQL:每分钟选一条
--p_year 是字符型的?
if p_quarter = '1' then
str_month := p_year||'-01-01';
end_month := p_year||'-04-01';
elsif p_quarter = '2' then
str_month := p_year||'-04-01';
end_month := p_year||'-07-01';
elsif p_quarter = '3' then
str_month := p_year||'-07-01';
end_month := p_year||'-10-01';
else
str_month := p_year||'-10-01';
end_month := to_char(to_number(p_year)+1)||'-01-01';
end if;
if ... then
...
elseif ... then
...
elseif ... then
...
end if
或者
if ... then
...
end if
if ... then
...
end if
形式、不能在前者里面混合else使用、如果是两种情况可以使用 if ... then ... else ... end if 这种形式
oralce 里面的elseif 必须写成elsif的 不然不识别的
2 as
3 str_month varchar2(100);
4 end_month varchar2(100);
5 begin
6 if p_quarter = '1' then
7 str_month := p_year||'-01-01';
8 end_month := p_year||'-04-01';
9 elsif p_quarter = '2' then
10 str_month := p_year||'-04-01';
11 end_month := p_year||'-07-01';
12 elsif p_quarter = '3' then
13 str_month := p_year||'-07-01';
14 end_month := p_year||'-10-01';
15 else
16 str_month := p_year||'-10-01';
17 end_month := to_char(to_number(p_year)+1)||'-01-01';
18 end if;
19 dbms_output.put_line('str_month is '||str_month);
20 dbms_output.put_line('end_month is '||end_month);
21 end;
22 /
Procedure created
SQL> set serveroutput on
SQL> exec proc_concat_time('2010','1');
str_month is 2010-01-01
end_month is 2010-04-01
PL/SQL procedure successfully completed
SQL> exec proc_concat_time('2010','2');
str_month is 2010-04-01
end_month is 2010-07-01
PL/SQL procedure successfully completed
SQL> exec proc_concat_time('2010','3');
str_month is 2010-07-01
end_month is 2010-10-01
PL/SQL procedure successfully completed
SQL> exec proc_concat_time('2010','4');
str_month is 2010-10-01
end_month is 2011-01-01
PL/SQL procedure successfully completed
SQL>