oracle sql查询,该怎么解决
oracle sql查询
我需要查询某张表的数据,根据另外一张表某几个字段的值来判断查询的表的内容
declare
sID varchar(10);
sEx varchar(10);
hEx varchar(10);
begin
select STCD,SXSW,HDSW into sID,sEx,hEx from st_stbprp_b where STNM='a‘and JDMC='b';
if hEx = '0' and sEx='0' then
select Z,P_Z,L_Z,TM from st_river_r where to_char(TM,'yyyy-mm-dd')='2013-08-01' and STCD = sID;
elsif sEx !='0' and hEx='0' then
select Z,TM from st_river_r where to_char(TM,'yyyy-mm-dd')='2013-08-01' and STCD = sID;
elsif sEx = '0' and hEx !='0' then
select P_Z,L_Z,TM from st_river_r where to_char(TM,'yyyy-mm-dd')='2013-08-01' and STCD = sID;
end if;
end;
老提示select 缺少into
新手求指教。。。谢谢啦。。。。
------解决方案--------------------
into sID
这俩之间缺少表名
------解决方案--------------------
" select Z,P_Z,L_Z,TM into 变量,变量,变量,变量 from st_river_r "
更正下
------解决方案--------------------
不好意思,是我看错了,楼主可以参考下楼上的
我需要查询某张表的数据,根据另外一张表某几个字段的值来判断查询的表的内容
declare
sID varchar(10);
sEx varchar(10);
hEx varchar(10);
begin
select STCD,SXSW,HDSW into sID,sEx,hEx from st_stbprp_b where STNM='a‘and JDMC='b';
if hEx = '0' and sEx='0' then
select Z,P_Z,L_Z,TM from st_river_r where to_char(TM,'yyyy-mm-dd')='2013-08-01' and STCD = sID;
elsif sEx !='0' and hEx='0' then
select Z,TM from st_river_r where to_char(TM,'yyyy-mm-dd')='2013-08-01' and STCD = sID;
elsif sEx = '0' and hEx !='0' then
select P_Z,L_Z,TM from st_river_r where to_char(TM,'yyyy-mm-dd')='2013-08-01' and STCD = sID;
end if;
end;
老提示select 缺少into
新手求指教。。。谢谢啦。。。。
------解决方案--------------------
into sID
这俩之间缺少表名
------解决方案--------------------
" select Z,P_Z,L_Z,TM into 变量,变量,变量,变量 from st_river_r "
更正下
------解决方案--------------------
不好意思,是我看错了,楼主可以参考下楼上的