{"id":609,"date":"2026-07-15T04:43:16","date_gmt":"2026-07-15T04:43:16","guid":{"rendered":"https:\/\/mitalgoswami.in\/?p=609"},"modified":"2026-07-23T05:57:42","modified_gmt":"2026-07-23T05:57:42","slug":"pl-sql-block-in-oracle","status":"publish","type":"post","link":"https:\/\/mitalgoswami.in\/?p=609","title":{"rendered":"PL\/SQL Block in Oracle"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A <strong>PL\/SQL Block<\/strong> is the basic unit of a PL\/SQL program in Oracle. It is a group of SQL and PL\/SQL statements that are executed together as a single unit.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Structure of a PL\/SQL Block<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>DECLARE\n   -- Variable declarations (Optional)\n\nBEGIN\n   -- Executable statements (Mandatory)\n\nEXCEPTION\n   -- Error handling statements (Optional)\n\nEND;\n\/<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Components of a PL\/SQL Block<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>DECLARE Section (Optional)<\/strong>\n<ul class=\"wp-block-list\">\n<li>Used to declare variables, constants, cursors, and user-defined exceptions.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>BEGIN Section (Mandatory)<\/strong>\n<ul class=\"wp-block-list\">\n<li>Contains executable SQL and PL\/SQL statements.<\/li>\n\n\n\n<li>Every PL\/SQL block must have a <code>BEGIN...END<\/code> section.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>EXCEPTION Section (Optional)<\/strong>\n<ul class=\"wp-block-list\">\n<li>Handles runtime errors (exceptions) that occur during execution.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>END<\/strong>\n<ul class=\"wp-block-list\">\n<li>Marks the end of the PL\/SQL block.<\/li>\n\n\n\n<li><code>\/<\/code> is used in SQL*Plus or SQL Developer to execute the block.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Example 1: Simple PL\/SQL Block<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>BEGIN\n   DBMS_OUTPUT.PUT_LINE('Hello, Oracle!');\nEND;\n\/<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Hello, Oracle!<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Example 2: PL\/SQL Block with Variables<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>DECLARE\n   v_name VARCHAR2(30) := 'John';\n   v_age NUMBER := 25;\nBEGIN\n   DBMS_OUTPUT.PUT_LINE('Name : ' || v_name);\n   DBMS_OUTPUT.PUT_LINE('Age  : ' || v_age);\nEND;\n\/<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Name : John\nAge  : 25<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Example 3: PL\/SQL Block Using SQL Statement<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Assume the following table:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>EMPLOYEE\n------------------------\nEMP_ID\nEMP_NAME\nSALARY<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>DECLARE\n   v_name EMPLOYEE.EMP_NAME%TYPE;\nBEGIN\n   SELECT EMP_NAME\n   INTO v_name\n   FROM EMPLOYEE\n   WHERE EMP_ID = 101;\n\n   DBMS_OUTPUT.PUT_LINE('Employee Name: ' || v_name);\nEND;\n\/<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Example 4: PL\/SQL Block with Exception Handling<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>DECLARE\n   v_num NUMBER := 10;\n   v_result NUMBER;\nBEGIN\n   v_result := v_num \/ 0;\n\n   DBMS_OUTPUT.PUT_LINE(v_result);\n\nEXCEPTION\n   WHEN ZERO_DIVIDE THEN\n      DBMS_OUTPUT.PUT_LINE('Error: Cannot divide by zero.');\nEND;\n\/<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Error: Cannot divide by zero.<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Example 5: PL\/SQL Block Using IF Statement<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>DECLARE\n   v_marks NUMBER := 78;\nBEGIN\n   IF v_marks &gt;= 35 THEN\n      DBMS_OUTPUT.PUT_LINE('Pass');\n   ELSE\n      DBMS_OUTPUT.PUT_LINE('Fail');\n   END IF;\nEND;\n\/<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Pass<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Types of PL\/SQL Blocks<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Anonymous Block<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Does not have a name.<\/li>\n\n\n\n<li>Executed only once.<\/li>\n\n\n\n<li>Cannot be stored in the database.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>BEGIN\n   DBMS_OUTPUT.PUT_LINE('Anonymous Block');\nEND;\n\/<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">2. Named Block<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Has a name.<\/li>\n\n\n\n<li>Stored in the Oracle database.<\/li>\n\n\n\n<li>Can be executed multiple times.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Examples:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Procedures<\/li>\n\n\n\n<li>Functions<\/li>\n\n\n\n<li>Packages<\/li>\n\n\n\n<li>Triggers<\/li>\n<\/ul>\n\n\n\n<h1 class=\"wp-block-heading\"><code>%TYPE<\/code> Attribute in Oracle PL\/SQL<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong><code>%TYPE<\/code><\/strong> attribute in PL\/SQL is used to declare a variable with the <strong>same data type as a table column or another variable<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This helps keep your code consistent. If the data type of the table column changes, the PL\/SQL variable automatically uses the updated type.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Syntax<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>variable_name table_name.column_name%TYPE;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">or<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>variable_name another_variable%TYPE;<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Example 1: Using a Table Column<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Suppose you have the following <code>EMPLOYEE<\/code> table:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>EMP_ID<\/th><th>EMP_NAME<\/th><th>SALARY<\/th><\/tr><\/thead><tbody><tr><td>101<\/td><td>Amit<\/td><td>25000<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Declare variables:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DECLARE\n   v_empid EMPLOYEE.EMP_ID%TYPE;\n   v_name  EMPLOYEE.EMP_NAME%TYPE;\n   v_sal   EMPLOYEE.SALARY%TYPE;\nBEGIN\n   v_empid := 101;\n   v_name := 'Amit';\n   v_sal := 25000;\n\n   DBMS_OUTPUT.PUT_LINE('ID : ' || v_empid);\n   DBMS_OUTPUT.PUT_LINE('Name : ' || v_name);\n   DBMS_OUTPUT.PUT_LINE('Salary : ' || v_sal);\nEND;\n\/<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ID : 101\nName : Amit\nSalary : 25000<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Example 2: Fetching Data from a Table<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>DECLARE\n   v_name EMPLOYEE.EMP_NAME%TYPE;\nBEGIN\n   SELECT EMP_NAME\n   INTO v_name\n   FROM EMPLOYEE\n   WHERE EMP_ID = 101;\n\n   DBMS_OUTPUT.PUT_LINE('Employee Name: ' || v_name);\nEND;\n\/<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Example 3: Using <code>%TYPE<\/code> with Another Variable<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>DECLARE\n   v_salary NUMBER(8,2);\n   v_bonus  v_salary%TYPE;\nBEGIN\n   v_salary := 30000;\n   v_bonus := 5000;\n\n   DBMS_OUTPUT.PUT_LINE('Salary : ' || v_salary);\n   DBMS_OUTPUT.PUT_LINE('Bonus : ' || v_bonus);\nEND;\n\/<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">Advantages of <code>%TYPE<\/code><\/h1>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Automatically uses the same data type as a table column.<\/li>\n\n\n\n<li>No need to specify the data type manually.<\/li>\n\n\n\n<li>Reduces maintenance when table definitions change.<\/li>\n\n\n\n<li>Prevents data type mismatch errors.<\/li>\n\n\n\n<li>Makes code easier to read and maintain.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\"><code>%TYPE<\/code> vs Manual Data Type<\/h1>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Manual Declaration<\/th><th><code>%TYPE<\/code> Declaration<\/th><\/tr><\/thead><tbody><tr><td><code>v_name VARCHAR2(50);<\/code><\/td><td><code>v_name EMPLOYEE.EMP_NAME%TYPE;<\/code><\/td><\/tr><tr><td>Must be changed manually if the column type changes<\/td><td>Automatically adapts to the column&#8217;s data type<\/td><\/tr><tr><td>More maintenance<\/td><td>Easier maintenance<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">Interview\/Exam Questions<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q1. What is <code>%TYPE<\/code> in PL\/SQL?<\/strong><br><strong>Answer:<\/strong> <code>%TYPE<\/code> is an attribute used to declare a variable with the same data type as a database column or another variable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q2. Why is <code>%TYPE<\/code> used?<\/strong><br><strong>Answer:<\/strong> It avoids manually specifying data types and automatically reflects changes made to the referenced column or variable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q3. Can <code>%TYPE<\/code> be used with another variable?<\/strong><br><strong>Answer:<\/strong> Yes. Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DECLARE\n   a NUMBER;\n   b a%TYPE;\nBEGIN\n   b := 100;\nEND;\n\/<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> <code>%TYPE<\/code> copies only the <strong>data type<\/strong> of the referenced column or variable. It does <strong>not<\/strong> copy constraints such as <code>NOT NULL<\/code> or <code>PRIMARY KEY<\/code>.<\/p>\n<\/blockquote>\n\n\n\n<h1 class=\"wp-block-heading\"><code>%ROWTYPE<\/code> Attribute in Oracle PL\/SQL<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong><code>%ROWTYPE<\/code><\/strong> attribute in PL\/SQL is used to declare a <strong>record variable<\/strong> that has the <strong>same structure (all columns)<\/strong> as a table or a cursor.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Instead of declaring one variable for each column, <code>%ROWTYPE<\/code> creates a single record containing all the columns of the table.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Syntax<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>record_name table_name%ROWTYPE;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">or<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>record_name cursor_name%ROWTYPE;<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Example 1: Using <code>%ROWTYPE<\/code> with a Table<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Suppose the <code>EMPLOYEE<\/code> table contains:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>EMP_ID<\/th><th>EMP_NAME<\/th><th>SALARY<\/th><th>DEPARTMENT<\/th><\/tr><\/thead><tbody><tr><td>101<\/td><td>Amit<\/td><td>25000<\/td><td>IT<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>DECLARE\n   emp_rec EMPLOYEE%ROWTYPE;\nBEGIN\n   SELECT *\n   INTO emp_rec\n   FROM EMPLOYEE\n   WHERE EMP_ID = 101;\n\n   DBMS_OUTPUT.PUT_LINE('ID        : ' || emp_rec.EMP_ID);\n   DBMS_OUTPUT.PUT_LINE('Name      : ' || emp_rec.EMP_NAME);\n   DBMS_OUTPUT.PUT_LINE('Salary    : ' || emp_rec.SALARY);\n   DBMS_OUTPUT.PUT_LINE('Department: ' || emp_rec.DEPARTMENT);\nEND;\n\/<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ID        : 101\nName      : Amit\nSalary    : 25000\nDepartment: IT<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Example 2: Inserting Values Using <code>%ROWTYPE<\/code><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>DECLARE\n   emp_rec EMPLOYEE%ROWTYPE;\nBEGIN\n   emp_rec.EMP_ID := 102;\n   emp_rec.EMP_NAME := 'Rahul';\n   emp_rec.SALARY := 30000;\n   emp_rec.DEPARTMENT := 'HR';\n\n   INSERT INTO EMPLOYEE\n   VALUES (emp_rec.EMP_ID,\n           emp_rec.EMP_NAME,\n           emp_rec.SALARY,\n           emp_rec.DEPARTMENT);\n\n   COMMIT;\nEND;\n\/<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Example 3: Using <code>%ROWTYPE<\/code> with a Cursor<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>DECLARE\n   CURSOR c_emp IS\n      SELECT EMP_ID, EMP_NAME, SALARY\n      FROM EMPLOYEE;\n\n   emp_rec c_emp%ROWTYPE;\nBEGIN\n   OPEN c_emp;\n\n   FETCH c_emp INTO emp_rec;\n\n   DBMS_OUTPUT.PUT_LINE(emp_rec.EMP_NAME);\n\n   CLOSE c_emp;\nEND;\n\/<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">Advantages of <code>%ROWTYPE<\/code><\/h1>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Declares all table columns with a single statement.<\/li>\n\n\n\n<li>Automatically reflects changes in the table structure.<\/li>\n\n\n\n<li>Reduces coding effort.<\/li>\n\n\n\n<li>Prevents data type mismatch errors.<\/li>\n\n\n\n<li>Makes programs easier to maintain.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">Difference Between <code>%TYPE<\/code> and <code>%ROWTYPE<\/code><\/h1>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><code>%TYPE<\/code><\/th><th><code>%ROWTYPE<\/code><\/th><\/tr><\/thead><tbody><tr><td>Declares a variable with the same data type as a single column or variable.<\/td><td>Declares a record with the same structure as an entire table or cursor.<\/td><\/tr><tr><td>Used for one column.<\/td><td>Used for all columns.<\/td><\/tr><tr><td>Example: <code>v_name EMPLOYEE.EMP_NAME%TYPE;<\/code><\/td><td>Example: <code>emp_rec EMPLOYEE%ROWTYPE;<\/code><\/td><\/tr><tr><td>Access directly: <code>v_name<\/code><\/td><td>Access fields using dot notation: <code>emp_rec.EMP_NAME<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Interview\/Exam Questions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q1. What is <code>%ROWTYPE<\/code>?<\/strong><br><strong>Answer:<\/strong> <code>%ROWTYPE<\/code> is a PL\/SQL attribute that declares a record variable with the same structure as a table or cursor.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q2. What is the advantage of <code>%ROWTYPE<\/code>?<\/strong><br><strong>Answer:<\/strong> It automatically includes all columns of a table or cursor, reducing code and automatically adapting to table structure changes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q3. How do you access a field in a <code>%ROWTYPE<\/code> record?<\/strong><br><strong>Answer:<\/strong> Use <strong>dot notation<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DBMS_OUTPUT.PUT_LINE(emp_rec.EMP_NAME);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Quick Memory Tip<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>%TYPE<\/code> \u2192 One column \u2192 One variable<\/strong><\/li>\n\n\n\n<li><strong><code>%ROWTYPE<\/code> \u2192 Whole row \u2192 One record with multiple fields<\/strong><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>A PL\/SQL Block is the basic unit of a PL\/SQL program in Oracle. It is a group of SQL and PL\/SQL statements that are executed together as a single unit. Structure of a PL\/SQL Block Components of a PL\/SQL Block Example 1: Simple PL\/SQL Block Output: Example 2: PL\/SQL Block with Variables Output: Example 3: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30],"tags":[],"class_list":["post-609","post","type-post","status-publish","format-standard","hentry","category-oracle"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.10 - aioseo.com -->\n\t<meta name=\"description\" content=\"A PL\/SQL Block is the basic unit of a PL\/SQL program in Oracle. It is a group of SQL and PL\/SQL statements that are executed together as a single unit. Structure of a PL\/SQL Block DECLARE -- Variable declarations (Optional) BEGIN -- Executable statements (Mandatory) EXCEPTION -- Error handling statements (Optional) END; \/ Components of\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"admin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/mitalgoswami.in\/?p=609\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.10\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Mital&#039;s Blog - My  Blog\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"PL\/SQL Block in Oracle - Mital&#039;s Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"A PL\/SQL Block is the basic unit of a PL\/SQL program in Oracle. It is a group of SQL and PL\/SQL statements that are executed together as a single unit. Structure of a PL\/SQL Block DECLARE -- Variable declarations (Optional) BEGIN -- Executable statements (Mandatory) EXCEPTION -- Error handling statements (Optional) END; \/ Components of\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/mitalgoswami.in\/?p=609\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2026-07-15T04:43:16+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2026-07-23T05:57:42+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"PL\/SQL Block in Oracle - Mital&#039;s Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"A PL\/SQL Block is the basic unit of a PL\/SQL program in Oracle. It is a group of SQL and PL\/SQL statements that are executed together as a single unit. Structure of a PL\/SQL Block DECLARE -- Variable declarations (Optional) BEGIN -- Executable statements (Mandatory) EXCEPTION -- Error handling statements (Optional) END; \/ Components of\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/mitalgoswami.in\\\/?p=609#blogposting\",\"name\":\"PL\\\/SQL Block in Oracle - Mital's Blog\",\"headline\":\"PL\\\/SQL Block in Oracle\",\"author\":{\"@id\":\"https:\\\/\\\/mitalgoswami.in\\\/?author=1#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/mitalgoswami.in\\\/#organization\"},\"datePublished\":\"2026-07-15T04:43:16+00:00\",\"dateModified\":\"2026-07-23T05:57:42+00:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/mitalgoswami.in\\\/?p=609#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/mitalgoswami.in\\\/?p=609#webpage\"},\"articleSection\":\"oracle\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/mitalgoswami.in\\\/?p=609#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mitalgoswami.in#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/mitalgoswami.in\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mitalgoswami.in\\\/?cat=30#listItem\",\"name\":\"oracle\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mitalgoswami.in\\\/?cat=30#listItem\",\"position\":2,\"name\":\"oracle\",\"item\":\"https:\\\/\\\/mitalgoswami.in\\\/?cat=30\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mitalgoswami.in\\\/?p=609#listItem\",\"name\":\"PL\\\/SQL Block in Oracle\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mitalgoswami.in#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mitalgoswami.in\\\/?p=609#listItem\",\"position\":3,\"name\":\"PL\\\/SQL Block in Oracle\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mitalgoswami.in\\\/?cat=30#listItem\",\"name\":\"oracle\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/mitalgoswami.in\\\/#organization\",\"name\":\"Mital's Blog\",\"description\":\"My  Blog\",\"url\":\"https:\\\/\\\/mitalgoswami.in\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/mitalgoswami.in\\\/?author=1#author\",\"url\":\"https:\\\/\\\/mitalgoswami.in\\\/?author=1\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/mitalgoswami.in\\\/?p=609#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a575ce1a3c064ed3befd825918c1c0457a92281570ba3e96c008e1c0af08ddc5?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"admin\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/mitalgoswami.in\\\/?p=609#webpage\",\"url\":\"https:\\\/\\\/mitalgoswami.in\\\/?p=609\",\"name\":\"PL\\\/SQL Block in Oracle - Mital's Blog\",\"description\":\"A PL\\\/SQL Block is the basic unit of a PL\\\/SQL program in Oracle. It is a group of SQL and PL\\\/SQL statements that are executed together as a single unit. Structure of a PL\\\/SQL Block DECLARE -- Variable declarations (Optional) BEGIN -- Executable statements (Mandatory) EXCEPTION -- Error handling statements (Optional) END; \\\/ Components of\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/mitalgoswami.in\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/mitalgoswami.in\\\/?p=609#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/mitalgoswami.in\\\/?author=1#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/mitalgoswami.in\\\/?author=1#author\"},\"datePublished\":\"2026-07-15T04:43:16+00:00\",\"dateModified\":\"2026-07-23T05:57:42+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/mitalgoswami.in\\\/#website\",\"url\":\"https:\\\/\\\/mitalgoswami.in\\\/\",\"name\":\"Mital's Blog\",\"description\":\"My  Blog\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/mitalgoswami.in\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"PL\/SQL Block in Oracle - Mital's Blog","description":"A PL\/SQL Block is the basic unit of a PL\/SQL program in Oracle. It is a group of SQL and PL\/SQL statements that are executed together as a single unit. Structure of a PL\/SQL Block DECLARE -- Variable declarations (Optional) BEGIN -- Executable statements (Mandatory) EXCEPTION -- Error handling statements (Optional) END; \/ Components of","canonical_url":"https:\/\/mitalgoswami.in\/?p=609","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/mitalgoswami.in\/?p=609#blogposting","name":"PL\/SQL Block in Oracle - Mital's Blog","headline":"PL\/SQL Block in Oracle","author":{"@id":"https:\/\/mitalgoswami.in\/?author=1#author"},"publisher":{"@id":"https:\/\/mitalgoswami.in\/#organization"},"datePublished":"2026-07-15T04:43:16+00:00","dateModified":"2026-07-23T05:57:42+00:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/mitalgoswami.in\/?p=609#webpage"},"isPartOf":{"@id":"https:\/\/mitalgoswami.in\/?p=609#webpage"},"articleSection":"oracle"},{"@type":"BreadcrumbList","@id":"https:\/\/mitalgoswami.in\/?p=609#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/mitalgoswami.in#listItem","position":1,"name":"Home","item":"https:\/\/mitalgoswami.in","nextItem":{"@type":"ListItem","@id":"https:\/\/mitalgoswami.in\/?cat=30#listItem","name":"oracle"}},{"@type":"ListItem","@id":"https:\/\/mitalgoswami.in\/?cat=30#listItem","position":2,"name":"oracle","item":"https:\/\/mitalgoswami.in\/?cat=30","nextItem":{"@type":"ListItem","@id":"https:\/\/mitalgoswami.in\/?p=609#listItem","name":"PL\/SQL Block in Oracle"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mitalgoswami.in#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/mitalgoswami.in\/?p=609#listItem","position":3,"name":"PL\/SQL Block in Oracle","previousItem":{"@type":"ListItem","@id":"https:\/\/mitalgoswami.in\/?cat=30#listItem","name":"oracle"}}]},{"@type":"Organization","@id":"https:\/\/mitalgoswami.in\/#organization","name":"Mital's Blog","description":"My  Blog","url":"https:\/\/mitalgoswami.in\/"},{"@type":"Person","@id":"https:\/\/mitalgoswami.in\/?author=1#author","url":"https:\/\/mitalgoswami.in\/?author=1","name":"admin","image":{"@type":"ImageObject","@id":"https:\/\/mitalgoswami.in\/?p=609#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/a575ce1a3c064ed3befd825918c1c0457a92281570ba3e96c008e1c0af08ddc5?s=96&d=mm&r=g","width":96,"height":96,"caption":"admin"}},{"@type":"WebPage","@id":"https:\/\/mitalgoswami.in\/?p=609#webpage","url":"https:\/\/mitalgoswami.in\/?p=609","name":"PL\/SQL Block in Oracle - Mital's Blog","description":"A PL\/SQL Block is the basic unit of a PL\/SQL program in Oracle. It is a group of SQL and PL\/SQL statements that are executed together as a single unit. Structure of a PL\/SQL Block DECLARE -- Variable declarations (Optional) BEGIN -- Executable statements (Mandatory) EXCEPTION -- Error handling statements (Optional) END; \/ Components of","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/mitalgoswami.in\/#website"},"breadcrumb":{"@id":"https:\/\/mitalgoswami.in\/?p=609#breadcrumblist"},"author":{"@id":"https:\/\/mitalgoswami.in\/?author=1#author"},"creator":{"@id":"https:\/\/mitalgoswami.in\/?author=1#author"},"datePublished":"2026-07-15T04:43:16+00:00","dateModified":"2026-07-23T05:57:42+00:00"},{"@type":"WebSite","@id":"https:\/\/mitalgoswami.in\/#website","url":"https:\/\/mitalgoswami.in\/","name":"Mital's Blog","description":"My  Blog","inLanguage":"en-US","publisher":{"@id":"https:\/\/mitalgoswami.in\/#organization"}}]},"og:locale":"en_US","og:site_name":"Mital's Blog - My  Blog","og:type":"article","og:title":"PL\/SQL Block in Oracle - Mital's Blog","og:description":"A PL\/SQL Block is the basic unit of a PL\/SQL program in Oracle. It is a group of SQL and PL\/SQL statements that are executed together as a single unit. Structure of a PL\/SQL Block DECLARE -- Variable declarations (Optional) BEGIN -- Executable statements (Mandatory) EXCEPTION -- Error handling statements (Optional) END; \/ Components of","og:url":"https:\/\/mitalgoswami.in\/?p=609","article:published_time":"2026-07-15T04:43:16+00:00","article:modified_time":"2026-07-23T05:57:42+00:00","twitter:card":"summary_large_image","twitter:title":"PL\/SQL Block in Oracle - Mital's Blog","twitter:description":"A PL\/SQL Block is the basic unit of a PL\/SQL program in Oracle. It is a group of SQL and PL\/SQL statements that are executed together as a single unit. Structure of a PL\/SQL Block DECLARE -- Variable declarations (Optional) BEGIN -- Executable statements (Mandatory) EXCEPTION -- Error handling statements (Optional) END; \/ Components of"},"aioseo_meta_data":{"post_id":"609","title":"#post_title #separator_sa #site_title","description":"#post_excerpt","keywords":null,"keyphrases":{"focus":{"keyphrase":"","score":0,"analysis":{"keyphraseInTitle":{"score":0,"maxScore":9,"error":1}}},"additional":[]},"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"BlogPosting","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":null,"frequency":"default","local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":{"faqs":[],"keyPoints":[],"schemas":[],"titles":[],"descriptions":[],"socialPosts":{"email":{"subject":"","preview":"","content":""},"linkedin":[],"twitter":[],"facebook":[],"instagram":[]}},"created":"2026-07-15 04:43:17","updated":"2026-07-24 04:46:51","seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/mitalgoswami.in\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/mitalgoswami.in\/?cat=30\" title=\"oracle\">oracle<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tPL\/SQL Block in Oracle\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/mitalgoswami.in"},{"label":"oracle","link":"https:\/\/mitalgoswami.in\/?cat=30"},{"label":"PL\/SQL Block in Oracle","link":"https:\/\/mitalgoswami.in\/?p=609"}],"_links":{"self":[{"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=\/wp\/v2\/posts\/609","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=609"}],"version-history":[{"count":2,"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=\/wp\/v2\/posts\/609\/revisions"}],"predecessor-version":[{"id":612,"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=\/wp\/v2\/posts\/609\/revisions\/612"}],"wp:attachment":[{"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=609"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=609"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=609"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}