Please disable your adblock and script blockers to view this page

Search this blog

Wednesday 21 March 2018

PL/SQL Conditions, IF-ELSE Conditional Statement


Like other programming languages, PL/SQL supports decision making statements, These statements are also called conditional statement

Basic Syntax of IF-ELSE is like this in PL/SQL

IF (Condition 1)

THEN

Statement to execute (if condition 1 is true)

ELSIF (Condition 2)

THEN 

Statement to execute (if condition 2 is true)

ELSE

Statement to execute (if condition 1& 2 both are false)

END IF;

For a better understanding of concept look at these examples

Friday 9 March 2018

PL/SQL Variables and Constants


A variable in any programming language is the name of space where values are stored and controlled by our code/program

  • We can not use reserve keyword as a variable name 
  • Variable length should not exceed 30 characters
  • The variable name consists of letters followed by other letters, dollar sign, underscore and numerals
  • The variable name should be clear and easy to understand

Here we'll learn how to declare and initialize variables in PL/SQL

The basic syntax for declaring a variable in PL/SQL is following

variable_name [CONSTANT] datatype [NOT NULL] [:= | DEFAULT initial_value] 

Here variable_name is the identifier of variable and datatype is a valid PL/SQL datatype. CONSTANT and DEFAULT are keywords used to define constants and set default values of variables

Wednesday 7 March 2018

PL/SQL Basic Syntax, Block Structure and Anonymous block


PL/SQL is highly structured language and it's program units are written in the block of code, In this tutorial, we'll learn about basic syntax and the block structure of PL/SQL

A piece of code that is organized in a properly defined sequence is called a Block. A PL/SQL Block consists of 3 parts

DECLARE
<<declaration >>
--Declare Variables,Constants, Cursors and all elements

BEGIN
<<executable statements>>
--SQL, PL/SQL Commands 

EXCEPTION
<<exception handling>>
--Code to handle the exception

END;