Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1330
  • Last Modified:

Oracle Equivalent of Print in SQL Server

Hi,

I'm new to Oracle.Im now converting SQL stored procedure to Oracle stored procedure.As in my Sql Stored procedure, i have those print 'record inserted into xxx table' to show whether the records successfully inserted to different table.Is there anyway i can do the same in Oracle in order to track what has the stored procedures done?

Regards,
Sinwee
0
sinwee80
Asked:
sinwee80
  • 2
1 Solution
 
checooCommented:
dbms_output.put_line(YOUR variables)

you will need to SET SERVEROUTPUT ON before the above line will display the results in SQL Plus window
0
 
NievergeltCommented:
Actually, in a script, you need to use CALL, only in PL/SQL it works without.
Also, the function requires one parameter; you can use it like this:

CALL DBMS_OUTPUT.PUT_LINE('Value :' || TO_CHAR(value));
or
CALL DBMS_OUTPUT.PUT('Value: ');
CALL DBMS_OUTPUT.PUT_LINE(value);

DBMS_OUTPUT has a limit on how many characters you can output, so you will probably like to add the following statement after the SET SERVEROUTPUT :

CALL DBMS_OUTPUT.ENABLE(500000);
0
 
sinwee80Author Commented:
If i have a db program which execute this stored procedure, Can this dbms_output.put_line(YOUR variables)
captured in the vb program to log to a file?
0
 
NievergeltCommented:
You best look first at the documentation: http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96612/d_output.htm#998100

As you see there, DBMS_OUTPUT actually writes to a buffer.
With DBMS_OUTPUT.GET_LINE or DBMS_OUTPUT.GET_LINES you can retrieve the contents of that buffer in your program.

Alternatively, you could use supplied package UTL_FILE to write to a file:
http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96612/u_file.htm#998101
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now