sqlplus:在存储过程中显示select语句的结果 [英] sqlplus: display result of select statement in stored procedure

查看:145
本文介绍了sqlplus:在存储过程中显示select语句的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个复杂的sql语句,我想将此语句的输出打印到sqlplus命令行.我尝试了以下操作,但未显示任何输出或错误.我想显示此select语句的输出.谢谢.

I have a complex sql statement, I want to print the output of this statement to the sqlplus command line. I tried the following but no output or errors were displayed. I want to display the output of this select statement. Thanks.

CREATE OR REPLACE PROCEDURE test1 AS
BEGIN
SELECT sname from student
END;

推荐答案

用于执行过程的u应该编写
exec test1
for executing procedure u should write
exec test1


您说的是复杂的sql语句,但上面的共享SQL看起来很简单.

关于上述查询执行,您正在创建一个保存SELECT查询的SP.如果要运行该选择查询并获取数据,请执行SP或直接运行SQL.

即:
You say complex sql statement but above shared SQL looks straight forward.

About above query execution, you are creating a SP that holds a SELECT query. If you want to run that select query and get data, either execute SP or run the SQL directly.

i.e.:
SELECT sname from student




OR

exec test1;


感谢您的答复.我没有发布实际的SQL查询,因为我的问题不是查询的复杂性,而是有关如何显示输出的信息.我也知道如何执行sql proc.

原来,我需要选择INTO变量并使用DBMS_OUTPUT.PUTLINE,最重要的部分是将serveroutput设置为on"

谢谢
Thanks for your replies. I did not post the actual SQL query because my problem is not the complexity of the query, it is about how to display output. I also know how to exec a sql proc.

It turned out that I needed to select INTO some variable and the use DBMS_OUTPUT.PUTLINE, the most important part was "set serveroutput on"

Thanks any way


这篇关于sqlplus:在存储过程中显示select语句的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆