查看oracle PL / SQL中变量的值

时间:2021-11-10 12:58:33

I'm running a PL/SQL block that is supposed to be calling a stored procedure who's output parameters are supposed to be populating variables in the PL/SQL block.

我正在运行一个PL / SQL块,它应该调用一个存储过程,它的输出参数应该填充PL / SQL块中的变量。

The procedure compiles, and the PL/SQL block runs successfully. But I'd like to check the values of the variables populated by the procedure. Is there a way to output these values?

该过程编译,PL / SQL块成功运行。但我想检查过程填充的变量的值。有没有办法输出这些值?

I'm using Free TOAD if that helps.

如果有帮助,我正在使用Free TOAD。

Thanks,

4 个解决方案

#1


3  

You have a few options:

你有几个选择:

  • Log with DBMS_OUTPUT
  • 使用DBMS_OUTPUT进行日志记录

  • Log to a file using UTL_FILE
  • 使用UTL_FILE登录到文件

  • Use the Oracle debugger DBMS_DEBUG
  • 使用Oracle调试器DBMS_DEBUG

My preference is to log to a file using a fairly simple custom logging package. In my custom logging package I have a configurable flag to switch between file logging and DBMS_OUTPUT logging.

我的偏好是使用一个相当简单的自定义日志包来登录文件。在我的自定义日志记录包中,我有一个可配置的标志,用于在文件日志记录和DBMS_OUTPUT日志记录之间切换。

The Oracle debugging API's are quite good but you definitely need a good debugging client. Oracle SQL Developer has fairly good support for it.

Oracle调试API非常好,但你肯定需要一个好的调试客户端。 Oracle SQL Developer对它有相当好的支持。

There is also a log4plsql logger but I haven't used it.

还有一个log4plsql记录器,但我没有使用它。

#2


2  

dbms_output.put_line(varHere);

#3


0  

A fourth option (the one I usually default to) also exists.....logging debugging messages to a database table. This gives you the advantage of being able to sort, query, filter your debug messages as required.

第四个选项(我通常默认使用的选项)也存在.....将调试消息记录到数据库表中。这使您能够根据需要对调试消息进行排序,查询和过滤。

As darreljnz mentioned above, log4plsql also probably supports logging to the database. I find that 1) dbms_output has too many limitations 2) logging to a file requires too much setup, and a database restart if the utl_file_dir parameter is not already set 3) using dbms_debug without the help of a GUI is very cumbersome (but I've done it)

正如上面提到的darreljnz,log4plsql也可能支持记录到数据库。我发现1)dbms_output有太多的限制2)记录到文件需要太多设置,如果没有设置utl_file_dir参数则重新启动数据库3)使用dbms_debug而没有GUI的帮助是非常麻烦的(但我'做完了)

#4


0  

If you can download a copy of Oracle jDeveloper jDeveloper Home page or Oracle Visual Studio add in VS Plugin. Both are free, and allow you to debug (set breakpoint, inspect variables, ...) in PL/SQL on the db. You also need a "debug" privledge on the DB to do this. But, if you have dba rights you can grant that.

如果您可以下载Oracle jDeveloper jDeveloper主页或Oracle Visual Studio的副本,请添加VS插件。两者都是免费的,并允许您在db上的PL / SQL中调试(设置断点,检查变量,...)。您还需要在DB上执行“调试”权限才能执行此操作。但是,如果你有dba权利,你可以批准。

#1


3  

You have a few options:

你有几个选择:

  • Log with DBMS_OUTPUT
  • 使用DBMS_OUTPUT进行日志记录

  • Log to a file using UTL_FILE
  • 使用UTL_FILE登录到文件

  • Use the Oracle debugger DBMS_DEBUG
  • 使用Oracle调试器DBMS_DEBUG

My preference is to log to a file using a fairly simple custom logging package. In my custom logging package I have a configurable flag to switch between file logging and DBMS_OUTPUT logging.

我的偏好是使用一个相当简单的自定义日志包来登录文件。在我的自定义日志记录包中,我有一个可配置的标志,用于在文件日志记录和DBMS_OUTPUT日志记录之间切换。

The Oracle debugging API's are quite good but you definitely need a good debugging client. Oracle SQL Developer has fairly good support for it.

Oracle调试API非常好,但你肯定需要一个好的调试客户端。 Oracle SQL Developer对它有相当好的支持。

There is also a log4plsql logger but I haven't used it.

还有一个log4plsql记录器,但我没有使用它。

#2


2  

dbms_output.put_line(varHere);

#3


0  

A fourth option (the one I usually default to) also exists.....logging debugging messages to a database table. This gives you the advantage of being able to sort, query, filter your debug messages as required.

第四个选项(我通常默认使用的选项)也存在.....将调试消息记录到数据库表中。这使您能够根据需要对调试消息进行排序,查询和过滤。

As darreljnz mentioned above, log4plsql also probably supports logging to the database. I find that 1) dbms_output has too many limitations 2) logging to a file requires too much setup, and a database restart if the utl_file_dir parameter is not already set 3) using dbms_debug without the help of a GUI is very cumbersome (but I've done it)

正如上面提到的darreljnz,log4plsql也可能支持记录到数据库。我发现1)dbms_output有太多的限制2)记录到文件需要太多设置,如果没有设置utl_file_dir参数则重新启动数据库3)使用dbms_debug而没有GUI的帮助是非常麻烦的(但我'做完了)

#4


0  

If you can download a copy of Oracle jDeveloper jDeveloper Home page or Oracle Visual Studio add in VS Plugin. Both are free, and allow you to debug (set breakpoint, inspect variables, ...) in PL/SQL on the db. You also need a "debug" privledge on the DB to do this. But, if you have dba rights you can grant that.

如果您可以下载Oracle jDeveloper jDeveloper主页或Oracle Visual Studio的副本,请添加VS插件。两者都是免费的,并允许您在db上的PL / SQL中调试(设置断点,检查变量,...)。您还需要在DB上执行“调试”权限才能执行此操作。但是,如果你有dba权利,你可以批准。