在匿名块内显示选择结果

编程入门 行业动态 更新时间:2024-10-24 22:27:15
本文介绍了在匿名块内显示选择结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试调试过程中的SELECT,并且尝试使用匿名块来对此进行调试.我希望该SQL Developer仅返回最后一个SELECT语句,但出现错误:

I'm trying to debug a SELECT inside a procedure, and I'm trying to this using a anonymous block. I would like that SQL Developer simply return the last SELECT statement, but I get the error:

ORA-06550: line 21, column 5: PLS-00428: an INTO clause is expected in this SELECT statement

在该过程中,我有一个用于该选择的INTO,但是是否有一种简单的方法可以简单地获取用于调试的最后一个SELECT语句的结果?我使用匿名块和变量,以使代码与过程中的内容尽可能相似,从而不必更改代码

Inside the procedure, I have an INTO for that select, but is there a simple way that I can simply get the results for the last SELECT statement for my debugging? I'm using anonymous block and variables so that the code is as similar as possible from what's actually inside the procedure, so that I don't have to change the code

set serveroutput on format wrapped; DECLARE p_cd_doc_type number; p_dc_doc_code varchar2(200); p_dt_base date; p_qt_days number; p_vl_mov_total number; p_qt_transac number; v_dt_max date; v_dt_min date; begin p_dt_base := sysdate; p_qt_days := 1; v_dt_max := trunc(p_dt_base) + 1; v_dt_min := v_dt_max - p_qt_days; p_vl_mov_total := 0; DBMS_OUTPUT.PUT_LINE('v_dt_max = ' || v_dt_max); DBMS_OUTPUT.PUT_LINE('v_dt_min = ' || v_dt_min); select * from tb_cad_cliente a join tb_trn_transacao b on a.cd_cliente = b.cd_cliente where a.cd_doc_type = p_cd_doc_type and a.dc_doc_code = p_dc_doc_code and b.dt_row between v_dt_min and v_dt_max and b.cd_status = 3; end;

推荐答案

您可以尝试使用此方法轻松打印结果:

You can try with this, to print your result easily:

declare your_variable varchar2(19); BEGIN DBMS_OUTPUT.PUT_LINE('init..'); FOR x IN (SELECT your_column FROM you_table where rownum<2 order by 1) LOOP DBMS_OUTPUT.PUT_LINE(x.your_column); END LOOP; END;

更多推荐

在匿名块内显示选择结果

本文发布于:2023-10-18 13:20:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1504337.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!