Please disable your adblock and script blockers to view this page

Search this blog

Saturday 11 August 2018

R Operators – Arithmetic Operators, Relational Operators, Logical Operators

 In programming, an operator is a symbol that is used to perform any specific mathematics or logical operation. In simple language, we can say that the operator is used to perform some operations and like other programming languages R has a set of various types of R operators that can be divided into the following categories.

 

  • Arithmetic Operator
  • Relational Operator
  • Logical Operator
  • Assignment Operator

Arithmetic Operators in R

Arithmetic operators are used for performing mathematical operations like addition, subtraction etc.

OperatorDescription
+Addition (To Add two variables in R)
-Subtraction (To Subtract one variable from another)
*Multiplication (To Multiply variables)
/Division (To divide the first variable with the second)
^Exponent (The first variable's value raised to the exponent of second value)
%%Modulus (Gives the remainder of the first variable's value with the second)

See an example here

> # An addition
> 5 + 10 
[1] 15
> 
> # A subtraction
> 10 - 5 
[1] 5
> 
> # A multiplication
> 5 * 15
[1] 75
> 
> # A division
> 12 / 2 
[1] 6
> 
> # Exponentiation
> 2^6
[1] 64
> 
> # Modulus
> 25%%4
[1] 1
>

Relational Operators in R

Relational Operators are used for comparing values and produce a boolean result.

OperatorDescription
>Greater than
<Less than
>=Greater than or equal to
<=Less than or equal to
==Equal to
!=Not equal to

See an example here

> # Greater than
> a <- 10
> b <-20
> print(b>a)
[1] TRUE
> 
> # Less than
> a <- 10
> b <-20
> print(b<a)
[1] FALSE
> 
> # Greater than or equal to
> a <- c(10,20,5)
> b <- c(20,10,5)
> print(b>=a)
[1] TRUE FALSE TRUE
> 
> # Less than or equal to
> a <- c(10,20,5)
> b <- c(20,10,5)
> print(b<=a)
[1] FALSE TRUE TRUE
> 
> # Equal to
> a <- 10
> b <-10
> print(b==a)
[1] TRUE
> 
> # Not equal to
> a <- 10
> b <-10
> print(b!=a)
[1] FALSE


Logical Operators in R

The logical operators are used to carry out boolean operations between variables. Number zero (0) is considered FALSE and all numbers greater than 0 are considered TRUE.

OperatorDescription
&Element wise logical AND (It checks each value of both vector and gives output TRUE if both values are TRUE)
|Element wise logical OR (It checks each value of both vector and gives output TRUE if any one value is TRUE)
!Logical NOT (It takes each value of vector and reverse it's logical value)
&&Logical AND (It checks only first value of both vector and gives output TRUE if both values are TRUE)
||Logical OR (It checks only first value of both vector and gives output TRUE if any of them are TRUE)

See an example here

> #Take two vectors
> a <- c(0,20,30,0,FALSE)
> b <- c(12,23,42,0,TRUE)
> 
> #Print Element wise logical AND
> print(a&b)
[1] FALSE  TRUE  TRUE FALSE FALSE
> 
> #Print Element wise logical OR
> print(a|b)
[1]  TRUE  TRUE  TRUE FALSE  TRUE
> 
> #Print Logical AND
> print(a&&b)
[1] FALSE
> 
> #Print Logical OR
> print(a||b)
[1] TRUE
> 
> #Print Logical NOT
> print(!a)
[1]  TRUE FALSE FALSE  TRUE  TRUE
> print(!b)
[1] FALSE FALSE FALSE  TRUE FALSE
>

Assignment Operators in R

Learn more about R assignment operators here

Cheers :) Happy Learning

Saturday 28 July 2018

R Variables and Constants - Variable Assignment, Search & Delete

Variables are the name given to a piece of data or information. Like many other programming languages, we use R variables to store data. R supports numeric, string, boolean and many other data types and we do not declare a variable with the data type, instead of that we assign a value to the variable and on basis of value R automatically sets the data type of variable.

A variable name consists of characters, numbers, and the special character (dot(.) and underscore(_) only) and can not start with any number.


See an example of variable naming in R programming

#Variables Naming in R Programming

#Valid Varibale Name
varone <- 20
print(varone)

#Valid Variable Name
.var_two <-30
print(.var_two)

#Invalid Variable Name
12months <- 12

#Invalid Variable Name (as dot is followed by number)
.1Var <- "Ashish"

The output on R Console



Variable Assignment in R

In R programming, the value of a variable can be assigned using the left arrow, right arrow or equal to the operator and the data type of a variable can be changed multiple times in a program that depends on its value.

# Assignment using  using left arrow
var1 <- 5
print(var1)

# Assignment using  using right arrow
"Ashish Awasthi" -> var2 
print(var2)

# Assignment using equal to operator
var3 = FALSE 
print(var3)



Data type of a Variable

This is how we can check the data type of any variable

# Declare Different types of Variables
var1 <- 5
print(var1)
"Ashish Awasthi" -> var2 
print(var2)
var3 = FALSE 
print(var3)

# Check class of var1
class(var1)

# Check class of var2
class(var2)

# Check class of var3
class(var3)



Searching Variable

We can find all variable available in the workspace using ls() function, and we can also use pattern in ls function to find the specific variable.

See an example here

#Declare some variables
var <- 10
var1 <- "Ashish Awasthi"
var2 <- 20.5
test_var <- TRUE

#Print all variables present in workspace
ls()

#Search specific variable
ls(pattern="test")

The output on R Console


Deleting a Variable

If you want to delete a variable that is no longer needed then there is rm() function, that removes variable from the workspace.

See an example

#Declare some variables
var <- 10
var1 <- "Ashish Awasthi"
var2 <- 20.5
test_var <- TRUE

#Delete a variable
rm(var2)

#Now print that variable
print(var2)

The output on R Console



Constants in R

As the name suggests constant means, an entity that value can not be changed. Constants can be numeric, character, boolean etc. All numbers are numeric constants, we can check it's using typeof() function.

#Numeric Constants
typeof(10)

#Character Constants
typeof("Ashish Awasthi")

#Buil-in Constants
print(pi)
typeof(pi)

print(LETTERS)
typeof(LETTERS)

print(letters)
typeof(letters)

print(month.name)
typeof(month.name)



Cheers :) Happy Learning

Monday 23 July 2018

R Data Types – Vectors, Matrices, Lists, Factors, Data Frames

 Like other programming languages, R supports many different data types. You must have seen that variables are used to store data in a program and a data type is assigned to a variable and that variable can hold only that type of data. In this post, we'll learn about R data types and R objects.

Basic data types in R programming are Numeric, Integer, Character, Logical and Complex and other than this R has some unique data types that are called R Objects.



Vectors in R

A Vector is basically a set of values of the same basic data type like numeric character etc. Vector in R is created using the c() function that represents a combination of elements.

See this example

# A Numeric Vector
numeric_vector <- c(10, 20, 30)

# A Character Vector
character_vector <- c("a", "b", "c")

# A Boolean Vector
boolean_vector <-c(TRUE,FALSE,TRUE)

The output on R Console is


Matrices in R

R supports Matrices and a Matrix is a collection of data values in 2 dimensions of the same basic data type, R creates a matrix of values using a matrix() function.

See this example

Here c(1,2,3,4,5,6,7,8,9) is a numeric vector
nrow is the number of rows in the matrix
ncol is the number of columns in the matrix


#Create a matrix using Vector
test_matrix<-matrix(c(1,2,3,4,5,6,7,8,9), nrow=3, ncol=3)
#Print matrix on console
print(test_matrix)

The output on R Console is


Arrays in R

Arrays are the same as any other programming language and in R, an array is the same as a matrix but it can have more than two dimensions. Array in R is created using the array() function and uses a vector as input and dim value to create arrays.

Here dim =c(2,2,4) means that 4 arrays will be created of 2x2.

#We have two vectors here
v1 <- c(1,2,3,7,8,9)
v2 <- c(4,5,6,10,11,12,13,14,15,16)

#Create array using vectors
test_array <- array(c(v1,v2),dim = c(2,2,4))

#print the array on the console
print(test_array)

The output on R Console is


Lists in R

A List is a set of values that can have different basic data types, In R List is created using the list() function.

#A list with different data types
#Declare a numeric vector
numeric_vector<-c(1,2,3)

#Create list 
test_list<- list("Ashish Awasthi", numeric_vector, 5.3)

#Print list
print(test_list)

The output on R Console


Factors in R

Factors are created using vectors as base and stores unique values as levels, In R Factor object is created using factor() function.


# Create a vector with duplicate values
emp_names <- c('James','Ram','James','Ashish','Ram','Ashish','James','Ram')

# Create a factor object using vector
factor_emp <- factor(emp_names)

# Print the factor object
print(factor_emp)

The output on R Console is



Data Frames in R

Data Frame is used for storing data in tables, and this tabular data can have multiple types of vectors like numeric, characters etc. Data Frame can be created using data.frame() function.

#A Character Vector
string_vector <-c("Ashish", "Awasthi","R")

#A Numeric Vector
numeric_vector <- c(10, 20, 30.5)

#A Boolean Vector
boolean_vector<- c(TRUE, FALSE, TRUE)

# Create the data frame using all 3 vectors
test_df <- 	data.frame(string_vector,numeric_vector,boolean_vector)

#Print result
print(test_df)

The output on R Console



Though this post gives an idea of using variables, In the next post, we'll learn more about using variables in R programming.

Cheers :) Happy Learning

Comments and basic arithmetic operations in R programming

 This post is about performing arithmetic operations in R programming language and putting required comments in between of code.

In R we use #(hash) sign to write a single line comment and R does not support multiline comments.

Now we'll see how to perform basic arithmetic operations in R. It is quite simple like using the calculator as no code is required to add, subtract or multiply.
See the example given below and try the code in R GUI software.



#Add Operation
10+12

#Subtract Operation
12-10

#Multiplication
10*12

#Divison
20/10

# Exponentiation
3^3

# Modulo
25%%4

And see the output in R GUI



and you can see that comments are written in code using # sign.

Print Hello World in R

The first program of every programming language is printing "Hello World" on the screen so here we'll see how to write our first program in R.
Here we take a variable sayHello and use <- to assign the value to the variable and to print this variable on the console, use the print command as shown in the below code.

#Set value in a variable 
sayHello <- "Hello World in R Programming!"
#Put this command to print
print(sayHello)

And output in R console - It is printing "Hello World in R Programming"



So this post gives a basic idea about R programming, Now in the next post, we'll learn about variables and data types used in the R language.

Saturday 21 July 2018

R tutorial - Introduction to R Programming

This R tutorial is designed for beginners who know the basics of programming and want to learn R programming.

R is an open-source programming language utilized for machine learning, factual examination, designs portrayal and detailing. R is unreservedly accessible under GNU General Public License. To learn R programming you ought to have an essential comprehension of any programming language.

The centre of R is an interpreted programming language that is the reason it doesn't require any compiler to run the code. R permits joining with the methodology written in the C, C++, .Net, Python or FORTRAN languages for effectiveness.



R was developed by Ross Ihaka and Robert Gentleman in Auckland in 1993 and supported by a group of programmers. R is the most used programming language for data analysis and statistical purposes. Like other programming languages, R supports conditional statements, looping, recursion and numerous different highlights like information representation, data visualization.

R supports number-crunching, object-oriented programming, procedural programming with functions, and has an extensive arrangement of administrators for taking care of Arrays and grids.

To start learning R programming, first of all, get R GUI Software that compiles and runs the R language.

Tuesday 10 July 2018

Styling HTML elements using CSS

In this post, we'll learn about styling HTML elements using CSS code, CSS stands for Cascading Style Sheet. It is used for changing the look of HTML components on the page and is very important for designing a beautiful user interface. After this tutorial, you'll be able to learn the basics about CSS and can use it in any type of web application or technology to beautify components.



CSS can be used in HTML pages in 3 ways, Here we'll see how to style HTML elements.

Inline CSS

Inline CSS is used to decorate a single HTML element and makes use of style attributes. See this example of styling HTML paragraph tag using inline CSS

<!DOCTYPE html>
<html>
<body>

<p style="color:red;font-size:20px;font-weight:bold;">This is a Red bold Paragraph</p>
<p style="color:darkgreen;font-size:15px;font-style:italic;">This is a green italic Paragraph</p>

</body>
</html>

Try this in our HTML Editor

Internal CSS

Internal CSS is used to decorate elements in a single HTML page. It is defined between <style> - </style> tag in <head> section. See this example of using internal CSS in an HTML page

<!DOCTYPE html>
<html>
<body>

<style>
p{
color:red;
font-size:20px;
font-weight:bold;
border: 1px solid blue;
padding: 50px;
background-color:yellow;
}
</style>

<p>This is a Red bold Paragraph with a border and background color</p>

</body>
</html>

Try this in our HTML Editor

External CSS

External CSS is used to decorate many HTML pages, Like for designing a website's template we use external CSS, In this, we create a file with .css extension and this file contains CSS code for all page elements.

A CSS file looks like this - style.css

p{
color:red;
font-size:20px;
font-weight:bold;
border: 1px solid blue;
padding: 50px;
background-color:yellow;
}
h1{
color:blue;
}

And this is how it is attached to the HTML page

<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="style.css">
</head>
<body>

<p>This is a Red bold Paragraph with a border and background color</p>
<h1>This is the H1 heading</h1>
</body>
</html>

After this information, you'll be able to understand the basics of CSS and get an idea of using styles with any other framework.

Cheers :) Happy Learning

Wednesday 4 July 2018

Skinning ADF Dialog box inside popup component

 In this post, we'll see how to change the look n feel of popup component by skinning the ADF dialog box using CSS code in ADF Application. Skinning plays important role in designing a better user interface, You can read more about ADF Skinning here.

Default ADF dialog component inside popup looks like this



And here I'll show you how to customize the look of dialog box using ADF Skin (CSS Code), I hope you all know about creating ADF Skin file. After creating the Skin file put the CSS script mentioned below in that file.

See ADF Skin code used to customize ADF dialog box.

/**Change background color and border color of dialog**/
af|dialog {
    background-color: White;
    border-color: #4267b2;
}

/**Change dialog header style**/
af|dialog::header, af|dialog::header-end, af|dialog::header-start, af|dialog::title {
    color: #FFFFFF;
    text-align: center;
    background-color: #45619d;
    background-image: none;
    font-family: Arial;
    padding: 3px;
}

/**Change dialog button styler**/
af|dialog af|button {
    background-color: #4267b2;
    text-align: center;
    vertical-align: middle;
    color: White;
    background-image: none;
    border: #4267b2 1.5px solid;
    width: 60px;
}

af|dialog af|button::link {
    background-color: #4267b2;
    text-align: center;
    vertical-align: middle;
    color: White;
    background-image: none;
    border: #4267b2 1.5px solid;
    font-family: Arial;
}

/**Set hover event properties for dialog button**/
af|dialog af|button:hover {
    background-color: red;
    text-align: center;
    vertical-align: middle;
    color: White;
    background-image: none;
    border: #528cff 1.5px solid;
    width: 60px;
}

af|dialog af|button::link:hover {
    background-color: #528cff;
    text-align: center;
    vertical-align: middle;
    color: White;
    background-image: none;
    border: #528cff 1.5px solid;
    font-family: Arial;
}

/**Change default close icon of dialog**/
af|dialog::close-icon-style {
    background: none;
    background-image: url("../../lblue_cross_16.png");
    height: 17px;
}

af|dialog::close-icon-style:hover {
    background: none;
    background-image: url("../../red_cross_16.png");
    height: 17px;
}

And after skinning, ADF dialog box looks like this



Cheers :) Happy Learning

Friday 29 June 2018

HTML Tags and their usage

 

List of Basic HTML Tags

Here a list of HTML tags with their significant use is given. Read this and try in our online HTML editor. Learning Basic HTML helps in the development of Web Applications.





Tag NameTag CodePurpose
Start TagClose Tag
HTML<html></html>Starting & ending tag of page,
HEAD<head></head>Formatting information, and
content is not visible
BODY<body></body>Contains the visible information
HEADING<h1>,<h2>,<h3>,<h4>,<h5>,<h6></h1>,</h2>,</h3>,</h4>,</h5>,</h6>Largest to smallest heading
Bold Text<b>,<strong></b>,</strong>For bold text
Paragraph<p></p>For writing text in paragraphs
Line Break<br>Not neededInsert a line break
LIST<ol></ol>For Ordered List
LIST<ul></ul>For Unordered List
List Item<li></li>For component of list
IMAGE<img src="source">Not needed, </img>For inserting image in webpage
LINK<a href="url of page"></a>For Hyperlink
CENTER<center><center>For center alignment
TT<tt></tt>Typewriter like text
BLOCKQUOTE<blockquote></blockquote>Intends from both side
HR<hr></hr>Horizontal Rule
TABLE<table></table>Specifies the beginning and end of
a table
TABLE ROW<tr></tr>Specifies the beginning and end of
a table row
TABLE DATA<td></td>Specifies the beginning and end of
a table cell
TABLE HEAD<th></th>A normal cell with text that is bold
and centered
TABLE BORDER<table border="1"></table>Specifies the border for table
ITALIC<i></i>For italic text
LESS THAN&lt;Not neededFor < sign
GREATER THAN&gt;Not neededFor > sign
SUBSCRIPT<sub></sub>For subscript
SUPERSCRIPT<sup></sup>For superscript
JAVASCRIPT<script type="javascript"></script>For using javascript

Cheers :) Happy Learning

Thursday 28 June 2018

HTML Tutorial - A Quick Overview for beginners

After this HTML Tutorial, you'll learn about basics of HTML and it's tag. It'll help you in developing and customizing applications and Web sites that make use of HTML. With our online HTML editor, you can run HTML code directly from your browser.

What is HTML-

  • HTML stands for Hyper Text Markup Language
  • An HTML file is a text file containing small markup tags
  • The markup tags tell the Web browser how to display the page
  • An HTML file must have an .htm or .html file extension
  • An HTML file can be created using a simple text editor as Notepad

HTML Tags-

  • The HTML tags are used to markup HTML elements
  • The HTML tags are surrounded by the two characters
  • The surrounding characters are called angle brackets
  • HTML tags normally come in pairs
  • The first tag in a pair is the start tag, the second tag is the end tag
  • The text between the start and end tags is the element content
  • HTML tags are not case sensitive
Simply open Online HTML Editor in the new tab Tab and copy HTML code from this page and just paste in the editor, then click on "Run Button" at top of the editor and see your result in the right panel. 



Headings in HTML


<html>
<body>
<h1>HTML Largest Heading</h1>
<h2>HTML Second Largest Heading</h2>
<h3>HTML Third Largest Heading</h3>
<h4>HTML Fourth Largest Heading</h4>
<h5>HTML Fifth Largest Heading</h5>
<h6>HTML Smallest Heading</h6>
</body>
</html>


Paragraphs in HTML


<html>
<body>
<p>This is example of paragraph, first paragraph</p>
<p>HTML tutorial, Second paragraph</p>
</body>
</html>


Links in HTML


<html>
<body>
<a href="http://www.awasthiashish.com">Ashish Awasthi's Blog</a>
<br />
<a href="http://www.facebook.com">Link to facebook</p>
</body>
</html>


Ordered List in HTML


<html>
<body>
<ol>
<li>Computers</li>
<li>Software</li>
<li>Laptop</li>
<li>Mobile</li>
</ol>
</body>
</html>


Unordered List in HTML


<html>
<body>
<ul>
<li>Computers</li>
<li>Software</li>
<li>Laptop</li>
<li>Mobile</li>
</ul>
</body>
</html>


Moving text using MARQUEE tag in HTML


<html>
<body>
<marquee>HTML Tutorial - This is moving text</marquee>
</body>
</html>


Images in HTML


<html>
<body>

<img src="http://www.awasthiashish.com/wp-content/uploads/2018/06/logo.png"
alt="Ashish Awasthi's Blog" width="200" height="200">

</body>
</html>


Text in HTML


<html>
<head>
<title>Title</title>
</head>
<body>

<b>Bold Text</b>
<br>
<i>Italic Text</i>
<br>
<u>Underline Text</i>

</body>
</html>

Test your HTML skills with W3School's Quiz 
  Cheers :) Happy Learning

Tuesday 8 May 2018

Change Style of ADF TreeTable, Column, Data Cell, Selected Row using ADF Skin

Hello Everyone

In this tutorial, We'll learn to change look n feel of ADF tree table component using Oracle ADF Skin
Here I am using Departments and Employees table HR Schema to prepare the model and created tree Table using view link between Departments and Employees View Object

Monday 16 April 2018

Increase Icon size of af:panelSpringBoard using ADF Skin


ADF Faces af:panelSpringBoard component shows af:showDetailItem in a fancy view using icons as the notation of showDetailItem

From Oracle Docs

The panelSpringboard control can be used to display a group of contents that belongs to a showDetailItem. An icon strip with icons representing the showDetailItem children along with the item's contents are displayed when in strip mode, and a grid of icons with no contents shown is displayed in grid mode. When the user selects an icon while the panelSpringboard is in strip mode, the panelSpringboard discloses the associated showDetailItem. When the user selects an icon while the panelSpringboard is in grid mode, this automatically causes the panelSpringboard to display in strip mode. Typically you would put one or more showDetailItem components inside of the panelSpringboard but you may also alternatively place a facetRef, group, iterator, or switcher inside of the panelSpringboard as long as these wrappers provide showDetailItem components as a result of their execution

I have added a panel springboard on the page and by default, it looks like this


Monday 9 April 2018

PL/SQL Function


PL/SQL Function is same as PL/SQL Procedure, The only difference is that function must return a value and a procedure may or may not return a value

Saturday 7 April 2018

PL/SQL Procedure


Previously I have posted about PL/SQL Block structure , A piece of code that is organized in a properly defined sequence is called a block

PL/SQL provides two types of blocks

Function- A PL/SQL block that performs a task or set of tasks and returns a value

Procedure- A PL/SQL block that performs a task or set of tasks and may or may not return a value


Monday 2 April 2018

PL/SQL Exceptions


An error that occurs during execution of the program is called exception, Like other programming languages, PL/SQL offers a way to catch these exceptions and handle them.

There are two types of exceptions in PL/SQL


  1. System-Defined Exceptions 
  2. User-Defined Exceptions 

Friday 23 March 2018

PL/SQL For Loop


PL/SQL FOR loop is used when we need to execute set of statements for the specific number of times and loop operates between the start and end counter values. The counter is always incremented by one and once the counter reaches to end integer value, the loop terminates

The syntax of PL/SQL FOR Loop is like this

FOR counter_variable IN start value.. end value LOOP

statements to execute 

END LOOP;

PL/SQL While Loop


PL/SQL WHILE loop is used to execute statements as long as given condition is true and the condition is checked at the beginning of each iteration

The syntax of PL/SQL While loop is like this

WHILE condition

statements to execute

END LOOP;

PL/SQL Basic Exit Loop


In PL/SQL Basic Loop all statements inside the block are executed at least once before loop termination, Basic loop encloses statement between LOOP and END LOOP and there must be an EXIT or EXIT-WHEN condition to terminate the loop

The syntax of Basic Exit loop is like this

LOOP

statements to execute

EXIT; or EXIT-WHEN

END LOOP;

See these examples for better understanding

PL/SQL Loops , Iterative Statement in PL/SQL


Loops are used to repeat execution of a statement or a set of statements multiple times on base of a condition or expression
EXIT and EXIT-WHEN keywords are used to terminate the loop

EXIT- terminates the loop unconditionally and passes control to the next statement after the loop
EXIT-WHEN- terminates the loop when EXIT-WHEN clause is checked and if returns true then the loop is terminated and control is passed to next statement after the loop

The basic syntax of Loop in PL/SQL is like this

LOOP

Set of statements

END LOOP;


Thursday 22 March 2018

PL/SQL CASE Statement, Decision Making Statement in PL/SQL


Like real life in programming sometimes we need to execute some code on a specific condition, PL/SQL CASE statement allows us to execute a sequence of instructions based on a selector (A variable, function, expression etc)
and if selector value is equal to value or expression in WHEN clause then corresponding THEN clause will execute and process the statements

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;