Oracle调试过程中,怎么实时的看输出语句

Oracle调试过程中,怎么实时的看输出语句,第1张

Oracle调试过程中,怎么实时的看输出语句
右键,test(测试),然后F9,单步调试,可以在左下角的变量那输入你要查看的变量名称,值就是变量的内容。可以鼠标直接点击变量名,也可以看到变量的值。

select '('||substr(&telephone,1,3)||') '||substr(&telephone,4,3)||'-'||substr(&telephone,7) into telephone from dual
这样就可以把原来的变量转成这个格式了,或者你可以放进另外一个变量,或者直接 output('('||substr(&telephone,1,3)||') '||substr(&telephone,4,3)||'-'||substr(&telephone,7))

select TK,max(decode(subitem,'S1',value,null)) S1,max(decode(subitem,'S2',v1,null)) S2,
from 表名。
如果你的subitem非常多,你可以用程序读取这列的数据,然后动态拼装以上的SQL语句。
decode(subitem,'S1',value,null) 的意思是:如果subitem字段的值为S1,则输出对应的value的值,否则为null

oracle的if语句采用decode函数。

DECODE(value,if1,then1,if2,then2,if3,then3,,else)

表示如果value 等于if1时,DECODE函数的结果返回then1,,如果不等于任何一个if值,则返回else

示例:

比如,有个if语句如下
if(a==1){//如果a等于1,返回2,否则返回3
   return 2;
}else{
   return 3;
}
翻译成DECODE如下
DECODE(a,1,2,3)

以test表中数据为例:

其中90分及以上为优秀,70分-89分为良好,60-69分为及格,60分以下为不及格,可用如下语句给出等级制成绩:

select name,
       score,
       case
         when score >= 90 then
          '优秀'
         when score between 70 and 89 then
          '良好'
         when score between 60 and 69 then
          '及格'
         when score < 60 then
          '不及格'
       end 等级
  from test;

查询结果:

reate or replace procedure get_content_river(cxrq in varchar2,--查询日期
fsr in varchar2,--发送人自动发送写自动发送
content out varchar2,
bz out varchar2,--0为失败1为成功
msg out varchar2) is
v_zm varchar2(50);
v_xzqy varchar2(20);
v_xzbm varchar2(20);
n_jjsw number(10,3);
n_bzsw number(10,3);
v_type varchar2(2);
cursor cur_st_river_r(cxsj varchar2)is
select
from st_river_r
where substr(to_char(st_river_rymdhm,'yyyy-mm-dd'),1,10) = cxsj;
rec_st_river_r st_river_r%rowtype;
begin
msg:='';
content:='';
bz := '1';
v_type := '1';--默认为人工
open cur_st_river_r(cxrq);
loop
fetch cur_st_river_r into rec_st_river_r;
exit when cur_st_river_r%notfound;
--取得警戒水位\保证水位
begin
select cshctalwtlv,cshctgnwtlv into n_jjsw,n_bzsw from CSHCT where cshctennmcd = rec_st_river_rennmcd;
exception
when others then
n_jjsw :=0;
n_bzsw :=0;
end;
--判断
if n_jjsw <= rec_st_river_rzr then
--取得站名
begin
select prnmsrennm into v_zm from prnmsr where prnmsrennmcd = rec_st_river_rennmcd;
exception
when others then
v_zm :='无';
end;
--行政区域编码
begin
select DSENDSCD into v_xzbm from dsen where dsenennmcd = rec_st_river_rennmcd;
exception
when others then
v_xzbm :='无';
end;
--取得行政区域名称
begin
select DSCDNMDSNM into v_xzqy from dscdnm where dscdnmdscd = v_xzbm;
exception
when others then
v_xzqy := '无';
end;
content:= content||'报警站名称:'||v_zm||';'||'行政区名称:'||v_xzqy||';'||'当前水位:'||to_char(rec_st_river_rzr)||';'
||'警戒水位:'||n_jjsw||';'||'保证水位:'||n_bzsw||';';

end if;
end loop;
if fsr = '自动发送' then
v_type := '2';
end if;
if length(content)> 0 then
--插入短信记录表 message
insert into message(
ID,
CONTENT,
SENDDATE,
REPLY,
PERSON,
TYPE,
CONTENTTYPE)
values
(
seq_messagenextval,
content,
sysdate,
'2',
fsr,
v_type,
'2'
);
end if;
close cur_st_river_r;
exception
when others then
if cur_st_river_r%isopen then
close cur_st_river_r;
bz := 0;
end if;
content := '-1';
msg := SQLERRM;


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/13365751.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-07-22
下一篇 2023-07-22

发表评论

登录后才能评论

评论列表(0条)

保存