do_test()
{
i<<!
declare
do_date varchar(6);
begin
select to_char(sysdate,'yyyymm') into do_date from dual;
if do_date > 200902 and do_date < 200909 then
select 'flag','aaa' from dual;
elsif do_date >= 200909 and do_date < 201003 then
select 'flag','bbb' from dual;
else
select 'flag','ccc' from dual;
end if;
end;
!
}
##########
do_test | grep -i flag |read xxx flag
echo ${flag}
{
i<<!
declare
do_date varchar(6);
begin
select to_char(sysdate,'yyyymm') into do_date from dual;
if do_date > 200902 and do_date < 200909 then
select 'flag','aaa' from dual;
elsif do_date >= 200909 and do_date < 201003 then
select 'flag','bbb' from dual;
else
select 'flag','ccc' from dual;
end if;
end;
!
}
##########
do_test | grep -i flag |read xxx flag
echo ${flag}
解决方案 »
- 查询问题,请教高手
- MicroStrategy连接oracle时odbc出现connection dead, 怎么办?
- trigger调用procedure的最简单的问题。
- 01555的问题
- 如何写这个insert?
- 请高手帮忙看一下SP2-0750: 错误如何解决?SQLPlus无法启动!
- update t1 set CTNP= '" & vsCTNP & "' where recid='000001",更新失败,提示“字符串太长”
- 请问一个关于字符&的问题
- win2003,9i,在空间USER上建了一个用户user1/pass1,在这个用户上建了一个表,我想备份?但出现问题?
- oracle企业管理器中没有内容
- 数据转移的问题
- 请高手讲解ORACLE10g的断点恢复!
{
i < <!
declare
do_date varchar(6);
begin
select to_char(sysdate,'yyyymm') into do_date from dual;
if do_date > '200902' and do_date < '200909' then
select 'flag','aaa' from dual;
elsif do_date >= '200909' and do_date < '201003' then
select 'flag','bbb' from dual;
else
select 'flag','ccc' from dual;
end if;
end;
!
}
##########
do_test | grep -i flag |read xxx flag
echo ${flag} 这样试试
*
ERROR at line 6:
ORA-06550: line 6, column 1:
PLS-00428: an INTO clause is expected in this SELECT statement
ORA-06550: line 8, column 1:
PLS-00428: an INTO clause is expected in this SELECT statement
ORA-06550: line 10, column 1:
PLS-00428: an INTO clause is expected in this SELECT statement
意思是在select语句里要有传入一个变量里
如:
a varchar2(10);
b varchar2(10);
select 'flag','aaa' into a,b from dual;
select 要和 into搭配起来用啊,
就像你上面的这样:
select to_char(sysdate,'yyyymm') into do_date from dual;
只有select就报这个错
select 'flag','aaa' from dual; 是单列,不能写2个列的!
也报错的阿
do_test()
{
i < <!
declare
do_date varchar(6);
flag varchar(50);
bbb varchar(50);
begin
select to_char(sysdate,'yyyymm') into do_date from dual;
if do_date > '200902' and do_date < '200909' then
select 'flag','aaa' into flag,bbb from dual;
elsif do_date >= '200909' and do_date < '201003' then
select 'flag','bbb' from dual;
else
select 'flag','ccc' from dual;
end if;
end;
!
}
##########
do_test | grep -i flag |read xxx flag
echo ${flag}
{
i < <!
declare
do_date varchar(6);
flag varchar(50);
bbb varchar(50);
begin
select to_char(sysdate,'yyyymm') into do_date from dual;
if do_date > '200902' and do_date < '200909' then
select 'flag','aaa' into flag,bbb from dual;
elsif do_date >= '200909' and do_date < '201003' then
select 'flag','bbb' into flag,bbb from dual;
else
select 'flag','ccc' into flag,bbb from dual;
end if;
end;
!
}
##########
do_test | grep -i flag |read xxx flag
echo ${flag}
do_date varchar(6);
v_flag varchar2(20);
v_aaa varchar2(20);
begin
select to_char(sysdate,'yyyymm') into do_date from dual;
if do_date > '200902' and do_date < '200909' then
select 'flag','aaa' into v_flag,v_aaa from dual;
elsif do_date >= '200909' and do_date < '201003' then
select 'flag','bbb' into v_flag,v_aaa from dual;
else
select 'flag','ccc' into v_flag,v_aaa from dual;
end if;
end;在語句塊中 單獨 用select 后面一定得要 into 對應的變量