Skip to main content

Posts

Showing posts from 2020

Get Count of saturdays and sundays between two dates ?

  Summary  In this post, you can learn how to get count of number of Saturdays and sundays in given date range using  Oracle  and  PLSQL .  Sometimes you want to return the number of week days between two dates (i.e., the number of days excluding the weekend).  The general strategy is to construct an expression that does the following: Take two dates that you want to get days in between and loop date range. In loop, get day from date. If day is Saturday (6) and Sunday (7) as per Julian Calendar then 1 and take weekend day count otherwise 0 and take weekday day count   Using PLSQL DECLARE     weekday_CNT          NUMBER   :=  0 ;      weekend_CNT          NUMBER   :=  0 ;      v_date               DATE...

PL/SQL - Function

Summary:          In this tutorial, we will introduce you to PL/SQL function. We will show you how to develop a PL/SQL function and call it from an anonymous block and   SELECT   statement. And we will also show you how to drop a function. Introducing to PL/SQL function:       A PL/SQL function is a named block that returns a value. A PL/SQL function is also known as a subroutine or a subprogram.   Creating a Function:       PL/SQL functions block creation using CREATE FUNCTION statement. The major difference between PL/SQL function or procedure is function return always value where as procedure may or may not return value. To create a PL/SQL function, you use the following syntax: CREATE  [ OR   REPLACE ]   FUNCTION   function_name   [ (       parameter_1   [ IN ]   [ OUT ]   data_type ,     ...

PL/SQL - Variables

Summary:    In this tutorial, you will learn about PL/SQL variables that help you manipulate data in PL/SQL programs.    In PL/SQL, a variable is a meaningful name of a temporary storage location that supports a particular data type in a program. Before using a variable, you need to declare it first in the declaration section of a  PL/SQL block . PL/SQL variables naming rules  Like other programming languages, a variable in PL/SQL must follow the naming rules as follows:  The variable name must be less than 31 characters. Try to make it as meaningful as possible within 31 characters.   The variable name must begin with an ASCII letter. It can be either lowercase or uppercase. Notice that PL/SQL is case-insensitive, which means   v_data   and   V_DATA   refer to the same variable.  Followed by the first character are any number, underscore (  _  ), and dollar sign (  $  ) c...