EDUCBA

EDUCBA

MENUMENU
  • Explore
    • Lifetime Membership
    • All in One Bundles
    • 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
  • Login
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.

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

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
ADVERTISEMENT
All in One Excel VBA Bundle
500+ Hours of HD Videos
15 Learning Paths
120+ Courses
Verifiable Certificate of Completion
Lifetime Access
ADVERTISEMENT
Financial Analyst Masters Training Program
2000+ Hours of HD Videos
43 Learning Paths
550+ Courses
Verifiable Certificate of Completion
Lifetime Access
ADVERTISEMENT
All in One Data Science Bundle
2000+ Hour of HD Videos
80 Learning Paths
400+ Courses
Verifiable Certificate of Completion
Lifetime Access
ADVERTISEMENT
All in One Software Development Bundle
5000+ Hours of HD Videos
149 Learning Paths
1050+ Courses
Verifiable Certificate of Completion
Lifetime Access
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Database Management
  • Machine Learning
  • All Tutorials
Certification Courses
  • All Courses
  • Data Science Course - All in One Bundle
  • Machine Learning Course
  • Hadoop Certification Training
  • Cloud Computing Training Course
  • R Programming Course
  • AWS Training Course
  • SAS Training Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2023 - 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

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

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

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

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

🚀 Extended Cyber Monday Price Drop! All in One Universal Bundle (3700+ Courses) @ 🎁 90% OFF - Ends in ENROLL NOW