EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials DBMS Tutorial dbms_output.put_line
 

dbms_output.put_line

Updated April 1, 2023

dbms_output.put_line

 

 

Definition of dbms_output.put_line

• It works in the oracle database package to write data or information for flat files.
• It is a procedure to direct PL/SQL database output in a screen.
• The put_line is function includes in the dbms_output package of the oracle database to contain information.
• It is a database function that works for removing extra space before and after lines.
• It enables the package of the dbms_output and uses the put_line function to send a message using triggers, stored procedures.
• It is a database procedure to display as well as debug information in PL/SQL program.
• It is the oracle package function to insert information and display it on the screen using a buffer.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

What is dbms_output.put_line?

• It is oracle database packages uses to contain information and display the required message in the code.

• The put_line is the most useful function to enable the package for the write data in the program.

• It is an oracle database function used in the package for writing and displaying information on the output screen.

• The put_line function uses a maximum of 32,767 bytes lines. If you want to extend line size then the database package shows ORA-20000 and ORU-10027 errors.

• It uses an unlimited size of buffer but the database uses 20000 bytes size of the buffer.

• Syntax is shown below.

BEGIN
DBMS_OUTPUT.PUT_LINE('write data or message here…');
END;

Description:

  • The function works with the oracle package.
  • The BEGIN and END blocks use to contain functions.
  • The BEGIN is part of a block uses at the start of the database program.
  • The END which is part of a block uses at the end of the database program.

How does dbms_output.put_line work?

Simple function with block.

  • Use BEGIN and END blocks for the dbms_output.put_line function.
  • Use database function with its data.
BEGIN dbms_output.put_line('learn database tutorial'); END;

Basic dbms_output.put_line working procedure in the database.

  • Set the “SERVEROUTPUT” function at the starting point.
SET SERVEROUTPUT ON;
  • Use BEGIN and END blocks function.
BEGIN
Write database function with a message.
END;
  • Use single function with its data.
dbms_output.put_line('learn database tutorial');
  • Use dbms_output.put_line function with the message.
SET SERVEROUTPUT ON ;
BEGIN dbms_output.put_line ('learn database tutorial');
END ;

• Multiple dbms_output.put_line working procedure in the database.

  • Use BEGIN and END blocks for the function.
BEGIN [Write database function with message;] END;
  • Use multiple functions with their data.
dbms_output.put_line ('learn database tutorial');
  • Use dbms_output.put_line function with the message.
dbms_output.put_line('learn database tutorial');
dbms_output.put_line ('learn programming tutorial');
dbms_output.put_line ('learn web developer tutorial');
dbms_output.put_line ('learn machine learning tutorial');
  • Program for dbms_output.put_line in the database.

Declare the objects of the variable and function.

DECLARE

o Create variables in the SQL program.

line_arr dbms_output.chararr;
number_line number;

o Use BEGIN keyword for the starting point of the dbms_output package.

o Enable dbms_output package.

o Use function with the message.

dbms_output.put_line ('learn database tutorial');
dbms_output.put_line ('learn programming tutorial');
  • Use for loop for dbms_output.put_line function.
number_line := 2;
dbms_output.get_lines(line_arr, number_line);
FOR b IN 1. .number_line LOOP
dbms_output.put_line (line_arr(b));
END LOOP;
  • Use the “END” keyword at the point of the dbms_output package.
  • Combine working procedure of the dbms_output.put_line function.
DECLARE
line_arr dbms_output.chararr;
number_line number;
BEGIN
DBMS_OUTPUT .ENABLE;
dbms_output.put_line ('learn database tutorial');
dbms_output.put_line ('learn programming tutorial');
number_line := 2;
dbms_output.get_lines(line_arr, number_line);
FOR b IN 1. .number_line LOOP
dbms_output.put_line (line_arr(b));
END LOOP;
END;

Examples

Example #1

The simple dbms_output.put_line function example and output.

BEGIN
dbms_output.put_line('learn database tutorial');
END;

Output:

dbms_output.put_line - 1

Description:

  • The begin and end block is necessary for the function.
  • This function uses in the SQL database.
  • This program uses as a command in the interface.

Example #2

The basics dbms_output.put_line function example and output.

SET SERVEROUTPUT ON;
BEGIN
dbms_output.put_line('learn database tutorial');
END;

Output:

dbms_output.put_line-2

Description:

  • The “begin and end” block necessary for the function.
  • Sometimes database interface does not run the function.
  • You need to set the serveroutput function or use the “set serveroutput on” function.

Example #3

The multiple dbms_output.put_line functions example and output

BEGIN
dbms_output.put_line('learn database tutorial');
dbms_output.put_line ('learn programming tutorial');
dbms_output.put_line ('learn web developer tutorial');
dbms_output.put_line ('learn machine learning tutorial');
END ;

Output:

dbms_output.put_line - 3

Description

  • The dbms_output.put_line uses multiple times in a single block.
  • You can use this function for different messages and data of the program.

Example #4

The basics dbms_output.put_line functions with loop example and output.

DECLARE
line_arr dbms_output.chararr;
number_line number;
BEGIN
DBMS_OUTPUT .ENABLE;
dbms_output.put_line ('learn database tutorial');
dbms_output.put_line ('learn programming tutorial');
number_line := 2;
dbms_output.get_lines(line_arr, number_line);
FOR b IN 1. .number_line LOOP
dbms_output.put_line (line_arr(b));
END LOOP;
END;

Output:

c

Description

  • This function uses several times in a single block.
  • This function displays using for loop and variable.
  • The “declare” statement uses to create a different variable with its data types.
  • This loop displays multiple put_line function messages.

Example #5

The simple functions with stored procedure example and output.

Write the following code for the summation of the two numbers.

CREATE OR REPLACE PROCEDURE addition_number
(number1 NUMBER, number2 NUMBER) AS
summations NUMBER;
BEGIN
summations = number1 +number2;
dbms_output.put_line ('The summation of two numbers is ' || summations);
END;
o After database coding, you can write or enter the required numbers.
CALL addition_number (6, 8);

Output:

4

Description

  • The database creates variables and methods.
  • This method uses to enter the required value of the data.
  • The variable uses to operate programs and execute data.
  • The block contains function and its operations.
  • The declared statement uses to create a different variable with its data types.
  • This loop displays multiple put_line function messages.

Conclusion

The dbms_output.put_line function helps to handle and maintain programs and operations. It is a functional procedure of a database package to operate a complicated database. It creates a user-friendly application to handle data and execute programs. It uses a lightweight, elegant and attractive user-friendly application.

Recommended Articles

We hope that this EDUCBA information on “dbms_output.put_line” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

  1. DBMS Transaction Processing
  2. States of Transaction in DBMS
  3. DBMS Components
  4. DBMS_LOB

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

🚀 Limited Time Offer! - ENROLL NOW