PL/SQL program to print a string and number |PL/SQL|


PL/SQL

  • PL/SQL is a block structured language that can have multiple blocks in it
  • Pl/SQL stands for "Procedural Language extension of SQL" that is used in Oracle.
  • PL/SQL includes procedural language elements like conditions and loops. It allows declaration of constants and variables, procedures and functions, types and variables of those types and triggers.


code:

DECLARE
name varchar(50):='Hello world';
reg_no varchar(20):='24';
BEGIN
dbms_output.put_line('Name: '||name);
dbms_output.put_line('Registered number: '||reg_no);
END;
/


Code Explanation:

  • dbms_output.put_line(): It is used for printing the output to the console screen.
  • The DBMS_OUTPUT is a built-in package that enables you to display output, debugging information.
  • The put_line is the most useful function to enable the package for the write data in the program. 
  • Here the first line turns on serveroutputthe SERVEROUTPUT setting controls whether SQL*Plus prints the output generated by the DBMS_OUTPUT package.
Declaration section contains a variable which is declared by the programmer. The variable is ‘message’ and the data type is varchar. 
  • The Execution section starts with the BEGIN keyword and we have given the variable declared in the Declaration section set as the parameter to the output statement.
  • Finally, we now write the END keyword to terminate the block of the Execution section.

Comments

Popular posts from this blog

Use of Backslash "\n" in C language

COHESION AND COUPLING material

Coding and Testing in software engineering