Skip to main content

PL/SQL Data Types

PL/SQL Data Types in Oracle encompass scalar types (VARCHAR2, NUMBER), composite types (RECORD, TABLE), and reference types (REF CURSOR). These types define the structure and constraints of data stored in variables and database columns, ensuring integrity and efficient manipulation. They support operations like arithmetic calculations, string manipulation, and handling of complex data structures, enabling robust database applications in Oracle environments.




 



NUMBER:

Used for storing numeric data. It can be specified with precision and scale.

my_number NUMBER := 10;

 

VARCHAR2/CHAR

Used for storing character strings. VARCHAR2 is variable-length, while CHAR is fixed-length.

my_string VARCHAR2(50) := 'Hello, world!';

 

DATE/TIMESTAMP

Used for storing date and time data.

my_date DATE := TO_DATE('2024-04-20', 'YYYY-MM-DD');

 

BOOLEAN

Used for storing Boolean values (TRUE/FALSE).

is_valid BOOLEAN := TRUE;

 

BINARY_INTEGER/PLS_INTEGER

Used for integer values. PLS_INTEGER is more efficient in terms of memory usage.

my_integer BINARY_INTEGER := 42;

 

RECORD

Also known as a row type, it is used to define a structure that can hold multiple fields of different data types.

TYPE employee_record IS RECORD (

  emp_id NUMBER,

  emp_name VARCHAR2(100),

  emp_salary NUMBER

);

 

TABLE

There are three types:

        Associative Arrays (INDEX BY TABLE): Indexed by integers or strings.

        Nested Tables: Unordered collection of elements indexed by integers.

        VARRAY (Variable Size Arrays): Fixed-size array.

TYPE employee_table IS TABLE OF employee_record;

 

CLOB

Used to store large amounts of character data.

my_clob CLOB;

 

BLOB

Used to store large amounts of binary data.

my_blob BLOB;

 

OBJECT

Allows you to define your own data types with attributes and methods.

CREATE TYPE address_type AS OBJECT (

  street VARCHAR2(100),

  city VARCHAR2(50),

  state VARCHAR2(50)

);

 

REF CURSOR

Used to reference a result set returned by a SQL query.

my_cursor SYS_REFCURSOR;

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Comments

Popular posts from this blog

TechUplift: Elevating Your Expertise in Every Click

  Unlock the potential of data with SQL Fundamental: Master querying, managing, and manipulating databases effortlessly. Empower your database mastery with PL/SQL: Unleash the full potential of Oracle databases through advanced programming and optimization. Unlock the Potential of Programming for Innovation and Efficiency.  Transform raw data into actionable insights effortlessly. Empower Your Data Strategy with Power Dataware: Unleash the Potential of Data for Strategic Insights and Decision Making.

Python Topics

Learning Python can be an exciting and rewarding journey, especially given its versatility and widespread use in various fields like web development, data science, automation, and more. Here's a structured guide to help you learn Python effectively, covering essential topics from beginner to advanced levels. Beginner Level Introduction to Python Installation and setup Python syntax and interactive shell Writing and running your first Python script Basic Concepts Variables and data types (integers, floats, strings, booleans) Basic arithmetic operations String operation Comments and documentation Control Structures Conditional statements ( if ,  elif ,  else ) Loops ( for ,  while ) Data Structures Lists Tuples Dictionaries Sets Functions Defining and calling functions Function arguments and return values Lambda functions Built-in functions Modules and Packages Importing modules Standard library overview (e.g.,  math ,  datetime ,  random ) Installing and using external packages

DAX Functions

These are just some of the many DAX functions available in Power BI. Each  function serves a specific purpose and can be used to perform a wide range of calculations and transformations on your data. Aggregation Functions: SUM : Calculates the sum of values. AVERAGE : Calculates the arithmetic mean of values. MIN : Returns the smallest value in a column. MAX : Returns the largest value in a column. COUNT : Counts the number of rows in a table or column. COUNTA : Counts the number of non-blank values in a column. DISTINCTCOUNT : Counts the number of unique values in a column. Logical Functions: IF : Returns one value if a condition is true and another value if it's false. AND : Returns TRUE if all the conditions are true, otherwise FALSE. OR : Returns TRUE if any of the conditions are true, otherwise FALSE. NOT : Returns the opposite of a logical value. Text Functions: CONCATENATE : Concatenates strings together. LEFT : Returns the leftmost characters from a text string. RIGHT : Ret