<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Pranav Bakare</title>
    <description>The latest articles on Forem by Pranav Bakare (@mrcaption49).</description>
    <link>https://forem.com/mrcaption49</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2009856%2Fd864a12f-560c-41c5-9b75-2370a8d9550c.jpeg</url>
      <title>Forem: Pranav Bakare</title>
      <link>https://forem.com/mrcaption49</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/mrcaption49"/>
    <language>en</language>
    <item>
      <title>[Boost]</title>
      <dc:creator>Pranav Bakare</dc:creator>
      <pubDate>Sun, 15 Mar 2026 03:06:01 +0000</pubDate>
      <link>https://forem.com/mrcaption49/-3b7f</link>
      <guid>https://forem.com/mrcaption49/-3b7f</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/devopsking" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F813395%2F8194ff66-8a69-45ea-a888-c4faa04ffd8c.jpg" alt="devopsking"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/devopsking/the-ultimate-terraform-tutorial-from-beginner-to-advanced-2024-guide-3n1o" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;The Ultimate Terraform Tutorial: From Beginner to Advanced (2025 Guide)&lt;/h2&gt;
      &lt;h3&gt;UWABOR KING COLLINS ・ Sep 30 '24&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#devops&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#cloudcomputing&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#terraform&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#tutorial&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>devops</category>
      <category>cloudcomputing</category>
      <category>terraform</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>mrcaption49 | Pranav Bakare</title>
      <dc:creator>Pranav Bakare</dc:creator>
      <pubDate>Wed, 25 Feb 2026 01:28:41 +0000</pubDate>
      <link>https://forem.com/mrcaption49/mrcaption49-pranav-bakare-36b5</link>
      <guid>https://forem.com/mrcaption49/mrcaption49-pranav-bakare-36b5</guid>
      <description>&lt;ul&gt;
&lt;li&gt;
4.6+ Years Oracle PL/SQL Developer With:
Enterprise-scale database systems (218M+ users – Vodafone Idea)
Airline domain product platform (Accelya – 200+ global carriers)
Advanced performance tuning (AWR, ASH, ADDM)
Bulk processing (BULK COLLECT, FORALL)
Advanced security (VPD, FGAC, DBMS_RLS)
CI/CD for Database (Liquibase + GitLab + Gradle)
ETL frameworks, SQL*Loader, External Tables
Scheduler automation (DBMS_SCHEDULER + Cron)
Materialized Views (Fast Refresh)
Partitioning &amp;amp; Archival Framework
PRAGMA usage &amp;amp; Autonomous Transactions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is your ~500-word professional summary&lt;/p&gt;

&lt;p&gt;Pranav Bakare is a results-driven Oracle PL/SQL Developer with over 4.6 years of hands-on experience in designing, developing, and optimizing enterprise-grade database systems. He possesses deep expertise in Oracle Database development, performance tuning, and high-volume transaction processing across telecom and airline industry domains. His professional journey spans large-scale production environments supporting millions of users, where performance, scalability, and data integrity are mission-critical.&lt;br&gt;
Currently working as a Software Engineer at Nexsys IT Consulting, contributing to Accelya’s airline cargo platform trusted by 200+ global carriers, Pranav plays a key role in engineering modular, high-performance PL/SQL solutions. He has designed and revamped over 40 parameterized PL/SQL packages, procedures, and functions using advanced concepts such as overloading, encapsulation, PRAGMA directives, and autonomous transactions. His work emphasizes maintainability, modularity, and execution efficiency in complex enterprise environments.&lt;br&gt;
He has strong expertise in performance engineering using Oracle’s diagnostic tools such as AWR (Automatic Workload Repository), ASH (Active Session History), and ADDM (Automatic Database Diagnostic Monitor). Through systematic SQL tuning, optimizer analysis, indexing strategies, and partitioning techniques, he has achieved measurable improvements including 30–40% faster query performance and significant storage optimization. His experience includes working extensively with BULK COLLECT, FORALL, Global Temporary Tables (GTTs), and pipelined table functions to optimize large-scale data processing and reduce context switching.&lt;br&gt;
Pranav has also implemented secure database frameworks using Oracle Virtual Private Database (VPD), DBMS_RLS for fine-grained access control (FGAC), and audit triggers leveraging PRAGMA AUTONOMOUS_TRANSACTION to ensure tamper-proof transaction logging. His contributions have strengthened data governance, compliance, and row-level security enforcement in enterprise applications.&lt;br&gt;
Beyond core PL/SQL development, he has engineered automated ETL pipelines using staging tables, MERGE statements, SQL*Loader (direct-path loading), External Tables, and UTL_FILE for efficient data import/export operations. He has also built metadata-driven archival frameworks using dynamic SQL (EXECUTE IMMEDIATE) and Oracle data dictionary views to automate schema-agnostic DDL/DML processes.&lt;br&gt;
A strong advocate of DevOps for databases, Pranav has architected multi-stage CI/CD pipelines using GitLab, Liquibase, and Gradle to enable version-controlled, automated database deployments across multiple environments including UAT, TRG, and PROD. His structured deployment strategy has resulted in zero post-production failures for extended periods.&lt;br&gt;
Earlier at Tata Consultancy Services, he supported one of India’s largest telecom platforms serving over 218 million users, where he engineered high-performance database solutions, automated job scheduling using DBMS_SCHEDULER and Cron, and reduced debugging time by 40% through a centralized exception-handling framework.&lt;br&gt;
In addition to database specialization, Pranav possesses full-stack capabilities in Python/Django, along with cloud exposure to AWS, GCP, Docker, and Kubernetes, allowing him to understand end-to-end application architecture. This hybrid expertise enables him to design database solutions aligned with modern distributed systems and scalable cloud-native environments.&lt;br&gt;
Overall, Pranav is positioned as a Senior Oracle PL/SQL Developer with strong expertise in performance optimization, database architecture, security implementation, CI/CD automation, and enterprise-scale system engineering.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Payment Integration Built with Django and PayPal | mrcaption49</title>
      <dc:creator>Pranav Bakare</dc:creator>
      <pubDate>Mon, 26 Jan 2026 06:52:42 +0000</pubDate>
      <link>https://forem.com/mrcaption49/payment-integration-built-with-django-and-paypal-434l</link>
      <guid>https://forem.com/mrcaption49/payment-integration-built-with-django-and-paypal-434l</guid>
      <description>&lt;h3&gt;
  
  
  &lt;strong&gt;A Secure Payment Integration Built with Django and PayPal&lt;/strong&gt;
&lt;/h3&gt;

&lt;h2&gt;
  
  
  Django-based payment integration application
&lt;/h2&gt;

&lt;h2&gt;
  
  
  &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz3bzpq6qwohkcj0tidgw.png" alt=" " width="800" height="557"&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;This project is a Django-based payment integration application developed to demonstrate how online payments can be securely processed within a web application. The platform integrates PayPal as a payment gateway, enabling users to initiate and complete transactions through a smooth and reliable checkout flow.&lt;/li&gt;
&lt;li&gt;The application is built using Django’s Model–View–Template (MVT) architecture, ensuring a well-structured and maintainable backend. Payment-related logic is handled on the server side, maintaining security and data integrity throughout the transaction lifecycle.&lt;/li&gt;
&lt;li&gt;Users are redirected to PayPal’s secure payment interface to complete transactions, after which they are returned to the application with appropriate success or failure responses. This flow ensures a safe payment experience while following standard industry practices for third-party payment gateways.&lt;/li&gt;
&lt;li&gt;The project demonstrates proper handling of payment requests, transaction status validation, and response management. It also lays the foundation for future enhancements such as order history, payment logs, refunds, and user authentication.&lt;/li&gt;
&lt;li&gt;The application is deployed on Render, showcasing real-world deployment, environment configuration, and production readiness. Overall, this project represents a practical implementation of payment gateway integration using Django, combining backend security, third-party service integration, and scalable architecture.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;🔗 Live Demo: https://django-paypal49.onrender.com/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;10-Line Descriptive Summary&lt;/strong&gt;
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;This Django application demonstrates secure payment gateway integration using PayPal. It follows Django’s Model–View–Template architecture for clean and maintainable code. The platform enables users to initiate and complete online payments securely. PayPal handles the transaction process through a trusted external interface. Server-side logic ensures proper payment flow and response handling. The application maintains security and data integrity throughout transactions. The backend is structured for scalability and future enhancements. Deployment on Render highlights production-level configuration. The project reflects real-world payment integration practices. A strong example of Django-based payment processing.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>django</category>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Blogging Platform Built with Django | mrcaption49</title>
      <dc:creator>Pranav Bakare</dc:creator>
      <pubDate>Mon, 26 Jan 2026 06:50:01 +0000</pubDate>
      <link>https://forem.com/mrcaption49/blogging-platform-built-with-django-mrcaption49-550h</link>
      <guid>https://forem.com/mrcaption49/blogging-platform-built-with-django-mrcaption49-550h</guid>
      <description>&lt;h3&gt;
  
  
  &lt;strong&gt;A Clean and Scalable Blogging Platform Built with Django&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This project is a Django-based blogging platform designed to demonstrate core content management principles using a clean, scalable, and maintainable backend architecture. The application enables users to browse blog posts in a well-structured layout, navigate seamlessly between articles, and access each post through a dedicated detail page for an uninterrupted reading experience.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpbci8v7qba70dlh4pu6n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpbci8v7qba70dlh4pu6n.png" alt=" " width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Built using Django’s Model–View–Template (MVT) architecture, the application ensures a clear separation of concerns between data models, business logic, and presentation layers. This architectural approach improves code readability, simplifies maintenance, and allows the application to scale efficiently as new features are introduced.&lt;/p&gt;

&lt;p&gt;Blog posts are rendered using optimized Django templates that emphasize readability, consistency, and user experience. The structured layout ensures content is easy to consume, while clean template design supports reusable components and faster rendering.&lt;/p&gt;

&lt;p&gt;Each blog post opens on its own standalone page, providing focused content delivery and creating a strong foundation for future enhancements such as tagging systems, commenting features, search functionality, and user authentication. These extensibility options make the platform adaptable to evolving requirements.&lt;/p&gt;

&lt;p&gt;The application is deployed on Render, highlighting real-world deployment practices, environment configuration, and production readiness. Overall, this project reflects a practical implementation of a blogging system using Django, combining backend logic, structured content flow, and modern deployment techniques.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;🔗 Live Demo: https://djangoblog49.onrender.com/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;10-Line Descriptive Summary&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This Django blogging platform showcases a practical implementation of content management using a clean and scalable backend. It is built using Django’s Model–View–Template architecture to ensure maintainability and clarity. The application presents blog posts in a structured and readable layout. Users can navigate content smoothly across the platform. Each post opens on a dedicated detail page for focused reading. Django templates are optimized for consistency and user experience. Backend logic is designed to be clean and efficient. The platform supports easy extensibility for future features. Deployment on Render demonstrates production-level readiness. Overall, the project reflects real-world Django development practices.&lt;/p&gt;

</description>
      <category>django</category>
      <category>webdev</category>
      <category>programming</category>
      <category>python</category>
    </item>
    <item>
      <title>A Simple Photo Album Built with Django | mrcaption4</title>
      <dc:creator>Pranav Bakare</dc:creator>
      <pubDate>Mon, 26 Jan 2026 06:39:52 +0000</pubDate>
      <link>https://forem.com/mrcaption49/a-simple-photo-album-built-with-django-mrcaption4-1go8</link>
      <guid>https://forem.com/mrcaption49/a-simple-photo-album-built-with-django-mrcaption4-1go8</guid>
      <description>&lt;h3&gt;
  
  
  &lt;strong&gt;A Simple Photo Album Built with Django&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Photo Album application using Django and Python&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7sawu08j1mkzmfdpujt6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7sawu08j1mkzmfdpujt6.png" alt=" " width="800" height="342"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Summary -&lt;/strong&gt;
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;This project is a Django-based Image Gallery Application designed to showcase real-world media handling and scalable web architecture. It enables users to upload images, add descriptions, and organize content using dynamic category management. The application supports category-based filtering, allowing users to view all images or narrow results efficiently. Each image is rendered on a dedicated detail page for focused viewing. Built using Django’s Model–View–Template (MVT) architecture, the project ensures clean code separation and maintainability. The user interface is developed with Bootstrap 5, delivering a responsive and consistent UI with minimal custom CSS. Django forms handle secure file uploads using multipart/form-data and CSRF protection. Images are managed using Django’s ImageField with Pillow for processing. For production readiness, the project integrates AWS S3 via django-storages and boto3 to provide scalable cloud-based media storage. Proper static and media file configuration supports both development and deployment environments. The system efficiently manages database relationships using foreign keys. Overall, this project demonstrates backend development expertise, cloud integration, and production-ready Django practices.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Project Explaination-&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;I built a category-based Photo Album application using Django and Python to explore real-world media handling and clean backend architecture. The application allows users to browse photos by category, view them in a gallery layout, and open each image on a dedicated detail page.&lt;/li&gt;
&lt;li&gt;The project follows Django’s Model–View–Template (MVT) pattern, ensuring clear separation of concerns and maintainable code. Categories improve navigation, while thumbnail previews keep the interface fast and visually clean.&lt;/li&gt;
&lt;li&gt;Each photo opens on its own page, creating a focused viewing experience and laying the foundation for future features like likes, views, or comments. The application is deployed on Render, demonstrating production-level configuration and public hosting.&lt;/li&gt;
&lt;li&gt;This project reflects practical Django development—combining structured backend logic, media handling, and real-world deployment into a clean, scalable web application.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;🔗 Live Demo: https://django-photoalbum-2025.onrender.com/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;10-Line Insightful Summary&lt;/strong&gt;
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;This Django Photo Album application demonstrates real-world media handling using a clean and structured backend. Photos are organized into categories for better navigation and filtering. The gallery layout ensures fast and intuitive browsing. Each image opens on a standalone detail page for focused viewing. The project follows Django’s MVT architecture for maintainability. Thumbnail previews enhance performance and UI clarity. Deployment on Render showcases production readiness. The application is simple, scalable, and extendable. It reflects strong Django fundamentals. A solid portfolio project with real-world relevance.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>django</category>
      <category>python</category>
      <category>programming</category>
      <category>data</category>
    </item>
    <item>
      <title>CICD YML file Learnings!</title>
      <dc:creator>Pranav Bakare</dc:creator>
      <pubDate>Sun, 28 Sep 2025 05:34:37 +0000</pubDate>
      <link>https://forem.com/mrcaption49/test-3a30</link>
      <guid>https://forem.com/mrcaption49/test-3a30</guid>
      <description>&lt;h3&gt;
  
  
  &lt;strong&gt;CICD YML file Learnings!&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In our project, we automated database deployments by integrating Liquibase with GitLab CI/CD. We structured the repository with environment-specific folders and a master changelog, ensuring version-controlled schema changes. The pipeline runs nightly with three stages — Pre-DB (backups, validations, SQL preview), DB (Liquibase update &amp;amp; tagging), and Post-DB (data fixes, stats gathering, recompiling invalid objects). Database credentials and JDBC drivers are securely managed through CI variables and artifacts. Each changeset includes rollback scripts and is previewed using liquibase updateSQL before execution, reducing production risks. Scheduled pipelines are configured with proper rules, and logs and previews are stored as artifacts for auditing. This approach minimized manual effort, improved reliability, and ensured consistent database deployments across environments.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Gitlab cicd pipeline Build automation&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In GitLab, a scheduled pipeline allows automated execution of jobs at specific times using cron expressions. The .gitlab-ci.yml file defines the pipeline’s structure, including stages, jobs, and the scripts to run. Each job can specify rules or only: [schedules] to control when it runs, ensuring scheduled jobs don’t trigger on pushes or merge requests. When a schedule is created in the GitLab UI, it targets a branch and defines the timing and optional variables. At the scheduled time, GitLab triggers a pipeline on the selected branch with CI_PIPELINE_SOURCE="schedule". The runner picks up jobs whose rules match the scheduled context and executes the defined scripts. Job logs and statuses are captured in GitLab for monitoring and debugging. Variables defined in the schedule are passed into the pipeline, allowing dynamic configuration. Using stages ensures jobs execute in the intended order even in complex pipelines. Overall, this integration provides a reliable, automated mechanism for running repetitive tasks without manual intervention. By combining .gitlab-ci.yml rules and GitLab schedules, teams can fully control what runs and when, maintaining flexibility and efficiency in CI/CD workflows.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Summary-&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Constructed and refined GitLab CI/CD pipelines (YAML-based) to automate execution of PL/SQL scripts and database changes, eliminating manual interventions.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Understanding GitLab Scheduled Pipelines and YAML Configuration</title>
      <dc:creator>Pranav Bakare</dc:creator>
      <pubDate>Sat, 27 Sep 2025 06:54:28 +0000</pubDate>
      <link>https://forem.com/mrcaption49/understanding-gitlab-scheduled-pipelines-and-yaml-configuration-4ch3</link>
      <guid>https://forem.com/mrcaption49/understanding-gitlab-scheduled-pipelines-and-yaml-configuration-4ch3</guid>
      <description>&lt;h3&gt;
  
  
  &lt;strong&gt;Understanding GitLab Scheduled Pipelines and YAML Configuration&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu66w0qsc2nar3asewql1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu66w0qsc2nar3asewql1.png" alt=" " width="800" height="528"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;In GitLab&lt;/strong&gt;,
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A scheduled pipeline allows automated execution of jobs at specific times using cron expressions. The .gitlab-ci.yml file defines the pipeline’s structure, including stages, jobs, and the scripts to run. Each job can specify rules or only: [schedules] to control when it runs, ensuring scheduled jobs don’t trigger on pushes or merge requests. When a schedule is created in the GitLab UI, it targets a branch and defines the timing and optional variables. &lt;/li&gt;
&lt;li&gt;At the scheduled time, GitLab triggers a pipeline on the selected branch with CI_PIPELINE_SOURCE="schedule". The runner picks up jobs whose rules match the scheduled context and executes the defined scripts. &lt;/li&gt;
&lt;li&gt;Job logs and statuses are captured in GitLab for monitoring and debugging. Variables defined in the schedule are passed into the pipeline, allowing dynamic configuration. Using stages ensures jobs execute in the intended order even in complex pipelines. &lt;/li&gt;
&lt;li&gt;Overall, this integration provides a reliable, automated mechanism for running repetitive tasks without manual intervention. By combining .gitlab-ci.yml rules and GitLab schedules, teams can fully control what runs and when, maintaining flexibility and efficiency in CI/CD workflows.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Here’s the basic and minimal .gitlab-ci.yml file structure you need to schedule your job every day at 11:11 AM from GitLab.&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;This is the simplest version (no workflow, no extra variables):
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;stages&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;run&lt;/span&gt;

&lt;span class="na"&gt;scheduled_job&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;run&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo "Scheduled job running at $(date)"&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo "Put your script logic here"&lt;/span&gt;
  &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Run only when the pipeline is triggered by a schedule&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;$CI_PIPELINE_SOURCE&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;"schedule"'&lt;/span&gt;
      &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;always&lt;/span&gt;
    &lt;span class="c1"&gt;# Prevent job from running on push/merge&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;never&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Steps to Schedule in GitLab:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to Project → CI/CD → Schedules.&lt;/li&gt;
&lt;li&gt;Click New schedule.&lt;/li&gt;
&lt;li&gt;Enter:&lt;/li&gt;
&lt;li&gt;Interval pattern: 11 11 * * *&lt;/li&gt;
&lt;li&gt;Target branch: the branch where the above .gitlab-ci.yml exists (e.g., main)&lt;/li&gt;
&lt;li&gt;Timezone: your local timezone&lt;/li&gt;
&lt;li&gt;Click Save.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now this job will run every day at 11:11 AM and execute the commands you placed in script:&lt;/p&gt;

</description>
      <category>cicd</category>
      <category>tutorial</category>
      <category>automation</category>
      <category>devops</category>
    </item>
    <item>
      <title>Finding All Child Tables Referencing a Parent Table in Oracle</title>
      <dc:creator>Pranav Bakare</dc:creator>
      <pubDate>Thu, 25 Sep 2025 11:36:00 +0000</pubDate>
      <link>https://forem.com/mrcaption49/finding-all-child-tables-referencing-a-parent-table-in-oracle-2mmd</link>
      <guid>https://forem.com/mrcaption49/finding-all-child-tables-referencing-a-parent-table-in-oracle-2mmd</guid>
      <description>&lt;h3&gt;
  
  
  &lt;strong&gt;Child Tables Referencing a Parent Table in Oracle&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;In Oracle databases, understanding foreign key relationships is essential before altering or dropping a parent table. Using the views ALL_CONSTRAINTS and ALL_CONS_COLUMNS, you can identify which child tables reference a specific parent table and the exact columns involved. &lt;/li&gt;
&lt;li&gt;A simple SQL query filtering constraint_type = 'R' (foreign keys) provides this mapping clearly. The output shows child tables, child columns, parent tables, and their constraints. This quick analysis helps avoid errors and ensures safe schema changes.&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;When working with relational databases, it’s often necessary to understand how tables are related through foreign keys. For example, if you want to drop or modify a parent table, you’ll need to know which child tables reference it.&lt;/li&gt;
&lt;li&gt;In Oracle, you can discover these relationships using the data dictionary views ALL_CONSTRAINTS and ALL_CONS_COLUMNS
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;table_name&lt;/span&gt;      &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;child_table&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;constraint_name&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;child_constraint&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column_name&lt;/span&gt;     &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;child_column&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;c_pk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;table_name&lt;/span&gt;   &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;parent_table&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;c_pk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;constraint_name&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;parent_constraint&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;c_pk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column_name&lt;/span&gt;  &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;parent_column&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;all_cons_columns&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;
&lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;all_constraints&lt;/span&gt; &lt;span class="k"&gt;c&lt;/span&gt; 
     &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;owner&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;owner&lt;/span&gt;
    &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;constraint_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;constraint_name&lt;/span&gt;
&lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;all_cons_columns&lt;/span&gt; &lt;span class="n"&gt;c_pk&lt;/span&gt; 
     &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="k"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;r_owner&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;c_pk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;owner&lt;/span&gt;
    &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="k"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;r_constraint_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;c_pk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;constraint_name&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="k"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;constraint_type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'R'&lt;/span&gt;  &lt;span class="c1"&gt;-- 'R' = Foreign Key&lt;/span&gt;
  &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;c_pk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;table_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;UPPER&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'MST_IRR'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>database</category>
      <category>sql</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Test VS CODE Snippet - CodeSnap</title>
      <dc:creator>Pranav Bakare</dc:creator>
      <pubDate>Sat, 20 Sep 2025 06:47:05 +0000</pubDate>
      <link>https://forem.com/mrcaption49/test-10mi</link>
      <guid>https://forem.com/mrcaption49/test-10mi</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7o3errbyi5gi9cp80v1s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7o3errbyi5gi9cp80v1s.png" alt=" " width="800" height="1818"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Automating Partition Cleanup in Oracle with PL/SQL and DBMS Scheduler</title>
      <dc:creator>Pranav Bakare</dc:creator>
      <pubDate>Sat, 20 Sep 2025 06:39:57 +0000</pubDate>
      <link>https://forem.com/mrcaption49/automating-partition-cleanup-in-oracle-with-plsql-and-dbms-scheduler-nao</link>
      <guid>https://forem.com/mrcaption49/automating-partition-cleanup-in-oracle-with-plsql-and-dbms-scheduler-nao</guid>
      <description>&lt;h3&gt;
  
  
  &lt;strong&gt;Automating Partition Cleanup in Oracle with PL/SQL and DBMS Scheduler&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The procedure begins by reading from the configuration table CMN_DROP_PARTITION, which defines which partitioned tables need cleanup, how many partitions should be retained, and which partitions must be excluded. &lt;/li&gt;
&lt;li&gt;For each active table entry, it retrieves the table owner, table name, and retention count. Next, it queries the Oracle data dictionary views (dba_tab_partitions) to fetch all available partitions for that table in ascending order by position. Once the partitions are listed, it checks the configured exclusion partition so that it is never dropped, even if it falls outside the retention period. &lt;/li&gt;
&lt;li&gt;It then calculates how many partitions must be kept, ensuring the most recent ones (based on partition position) remain untouched. The procedure identifies the older partitions that are beyond the retention limit and marks them as candidates for dropping. Using dynamic SQL, it generates and executes ALTER TABLE DROP PARTITION statements for each of these outdated partitions. &lt;/li&gt;
&lt;li&gt;Error handling is usually included to skip over issues like locked partitions or dependencies. Finally, this process ensures partition cleanup is automated, data-driven, and consistent, improving database performance and storage efficiency without manual intervention.&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;The solution automates partition maintenance in Oracle by combining a PL/SQL procedure, a configuration table, and a scheduled job. The procedure CMN_DROP_PARTITIONS_PR dynamically identifies and drops partitions older than the retention rules defined in CMN_DROP_PARTITION. &lt;/li&gt;
&lt;li&gt;The configuration table controls how many partitions to keep, which partitions to exclude, and which tables are active for cleanup, making the logic fully data-driven. A DBMS Scheduler job then executes the procedure every Monday at 3 AM, ensuring cleanup happens consistently without manual effort. &lt;/li&gt;
&lt;li&gt;Together, these components deliver a reliable, automated, and flexible way to keep partitioned tables lean and manageable.&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;Managing partitioned tables efficiently is crucial in large-scale databases, especially when dealing with high-volume transactional or logging data. &lt;/li&gt;
&lt;li&gt;If older partitions are not purged regularly, the database grows uncontrollably, impacting performance, storage, and maintenance overhead. &lt;/li&gt;
&lt;li&gt;To address this challenge, we implemented an automated partition cleanup mechanism in Oracle. The solution involves three components working together: &lt;/li&gt;
&lt;li&gt;(1) a PL/SQL procedure that drops old partitions beyond a configurable retention period, &lt;/li&gt;
&lt;li&gt;(2) a configuration table that defines retention rules and exceptions per table, and &lt;/li&gt;
&lt;li&gt;(3) a DBMS Scheduler job that triggers the cleanup procedure at regular intervals without manual intervention. This approach ensures that database housekeeping is automated, safe, and consistent, reducing operational effort while keeping only the required data available.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;1. The Cleanup Procedure —&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;At the core of this solution is the PL/SQL procedure CMN_DROP_PARTITIONS_PR. &lt;/li&gt;
&lt;li&gt;It scans all partitioned tables configured for cleanup, checks how many partitions should be retained, and automatically issues ALTER TABLE DROP PARTITION commands for older partitions. &lt;/li&gt;
&lt;li&gt;Any errors are logged but don’t interrupt the overall execution, ensuring that one bad partition doesn’t stop the cleanup process.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;OR&lt;/span&gt; &lt;span class="k"&gt;REPLACE&lt;/span&gt; &lt;span class="k"&gt;PROCEDURE&lt;/span&gt; &lt;span class="n"&gt;CMN_OWNR&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CMN_DROP_PARTITIONS_PR&lt;/span&gt; &lt;span class="k"&gt;IS&lt;/span&gt;
    &lt;span class="n"&gt;v_Dropstr_Sql&lt;/span&gt; &lt;span class="n"&gt;varchar2&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;BEGIN&lt;/span&gt;
    &lt;span class="k"&gt;FOR&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;table_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                   &lt;span class="n"&gt;partition_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                   &lt;span class="n"&gt;partition_position&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                   &lt;span class="n"&gt;RANK&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="n"&gt;OVER&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;PARTITION&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;table_name&lt;/span&gt; &lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;partition_position&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;rnk&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                   &lt;span class="n"&gt;cdp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;no_of_part_to_retn&lt;/span&gt; &lt;span class="n"&gt;retn_prt_days&lt;/span&gt;
            &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;user_tab_partitions&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cmn_drop_partition&lt;/span&gt; &lt;span class="n"&gt;cdp&lt;/span&gt;
            &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;cdp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;table_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;table_name&lt;/span&gt;
              &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;cdp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exclude_partition&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;partition_name&lt;/span&gt;
              &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;cdp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;active&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Y'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;rnk&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;retn_prt_days&lt;/span&gt;
        &lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;rnk&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;LOOP&lt;/span&gt;
        &lt;span class="k"&gt;BEGIN&lt;/span&gt;
            &lt;span class="n"&gt;v_Dropstr_Sql&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'ALTER TABLE '&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;table_name&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s1"&gt;' DROP PARTITION '&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;partition_name&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s1"&gt;' UPDATE INDEXES'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="k"&gt;EXECUTE&lt;/span&gt; &lt;span class="k"&gt;IMMEDIATE&lt;/span&gt; &lt;span class="n"&gt;v_Dropstr_Sql&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;v_Dropstr_Sql&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;EXCEPTION&lt;/span&gt; &lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="n"&gt;OTHERS&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
            &lt;span class="n"&gt;ngcs_util&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;db_err_log_pr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'CMN'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'CMN_DROP_PARTITIONS_PR'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;table_name&lt;/span&gt;&lt;span class="o"&gt;||&lt;/span&gt;&lt;span class="s1"&gt;':'&lt;/span&gt;&lt;span class="o"&gt;||&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;partition_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;SQLERRM&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;END&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;END&lt;/span&gt; &lt;span class="n"&gt;LOOP&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;ngcs_util&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;db_err_log_pr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'CMN'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'CMN_DROP_PARTITIONS_PR'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'Drop Partition'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'CMN PARTITIONS DROP JOB GOT COMPLETED SUCCESSFULLY AT:'&lt;/span&gt;&lt;span class="o"&gt;||&lt;/span&gt;&lt;span class="n"&gt;systimestamp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;EXCEPTION&lt;/span&gt; &lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="n"&gt;OTHERS&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
    &lt;span class="n"&gt;ngcs_util&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;db_err_log_pr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'CMN'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'CMN_DROP_PARTITIONS_PR'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'Main EXCP'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;SQLERRM&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;END&lt;/span&gt; &lt;span class="n"&gt;CMN_DROP_PARTITIONS_PR&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;2. Configuration Table —&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The cleanup rules are defined in the CMN_DROP_PARTITION table. For each table, we can specify how many partitions to retain, which partitions to exclude from deletion, and whether the rule is active. &lt;/li&gt;
&lt;li&gt;This makes the procedure flexible and data-driven.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;CMN_DROP_PARTITION&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;table_name&lt;/span&gt;         &lt;span class="n"&gt;VARCHAR2&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="n"&gt;exclude_partition&lt;/span&gt;  &lt;span class="n"&gt;VARCHAR2&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="n"&gt;table_owner&lt;/span&gt;        &lt;span class="n"&gt;VARCHAR2&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="n"&gt;no_of_part_to_retn&lt;/span&gt; &lt;span class="n"&gt;NUMBER&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="n"&gt;active&lt;/span&gt;             &lt;span class="n"&gt;VARCHAR2&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="n"&gt;created_date&lt;/span&gt;       &lt;span class="nb"&gt;TIMESTAMP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="n"&gt;created_by&lt;/span&gt;         &lt;span class="n"&gt;VARCHAR2&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="n"&gt;modified_date&lt;/span&gt;      &lt;span class="nb"&gt;TIMESTAMP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="n"&gt;modified_by&lt;/span&gt;        &lt;span class="n"&gt;VARCHAR2&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;


&lt;span class="c1"&gt;-- Sample entries&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;CMN_DROP_PARTITION&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;table_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;exclude_partition&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
&lt;span class="n"&gt;active&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;table_owner&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;no_of_part_to_retn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;created_date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;created_by&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'CMN_UPLD_DATA'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'P_PREDEC24'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'Y'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'CMN_OWNR'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;31&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;SYSDATE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'ACCELYA-IT'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;CMN_DROP_PARTITION&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;table_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;exclude_partition&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
&lt;span class="n"&gt;active&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;table_owner&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;no_of_part_to_retn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;created_date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;created_by&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'CMN_LOG_REQ_RESP'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'P_PRE24'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'Y'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'CMN_OWNR'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;SYSDATE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'ACCELYA-IT'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;COMMIT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;In this example:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For CMN_UPLD_DATA, the last 31 partitions are retained, but partition P_PREDEC24 is excluded from deletion.&lt;/li&gt;
&lt;li&gt;For CMN_LOG_REQ_RESP, the last 7 partitions are retained, excluding P_PRE24.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;3. Scheduling with DBMS Scheduler —&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Finally, the procedure is scheduled using Oracle’s DBMS Scheduler. &lt;/li&gt;
&lt;li&gt;We created a job that runs the cleanup process every Monday at 3 AM, ensuring weekly housekeeping without manual effort.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;BEGIN&lt;/span&gt;
  &lt;span class="n"&gt;DBMS_SCHEDULER&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;create_job&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;job_name&lt;/span&gt;        &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'CMN_DROP_PARTITION_JOB'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;job_type&lt;/span&gt;        &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'PLSQL_BLOCK'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;job_action&lt;/span&gt;      &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'cmn_drop_partitions_pr;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;start_date&lt;/span&gt;      &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;systimestamp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;repeat_interval&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'FREQ=WEEKLY; BYDAY=MON; BYHOUR=03; BYMINUTE=00; BYSECOND=0'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;end_date&lt;/span&gt;        &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;enabled&lt;/span&gt;         &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;TRUE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;comments&lt;/span&gt;        &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'JOB To drop older partition from CMN tables'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;END&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This job guarantees the cleanup procedure runs at a fixed schedule, keeping the database lean and partitions under control.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Summary —&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;With this implementation, we achieved a robust and automated partition cleanup strategy. The procedure ensures that only the latest required partitions are kept, the configuration table provides flexibility and control without code changes, and the DBMS Scheduler job automates execution at off-peak hours. Together, these three components create a reliable maintenance framework that improves performance, reduces storage costs, and minimizes manual intervention in partition management.&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>data</category>
      <category>datascience</category>
      <category>database</category>
    </item>
    <item>
      <title>Partitioning</title>
      <dc:creator>Pranav Bakare</dc:creator>
      <pubDate>Fri, 19 Sep 2025 16:33:39 +0000</pubDate>
      <link>https://forem.com/mrcaption49/partitioning-586n</link>
      <guid>https://forem.com/mrcaption49/partitioning-586n</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/mrcaption49/automating-old-partition-cleanup-in-oracle-with-plsql-2hhh" class="crayons-story__hidden-navigation-link"&gt;Automating Old Partition Cleanup in Oracle with PL/SQL&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/mrcaption49" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2009856%2Fd864a12f-560c-41c5-9b75-2370a8d9550c.jpeg" alt="mrcaption49 profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/mrcaption49" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Pranav Bakare
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Pranav Bakare
                
              
              &lt;div id="story-author-preview-content-2853582" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/mrcaption49" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2009856%2Fd864a12f-560c-41c5-9b75-2370a8d9550c.jpeg" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Pranav Bakare&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/mrcaption49/automating-old-partition-cleanup-in-oracle-with-plsql-2hhh" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Sep 18 '25&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/mrcaption49/automating-old-partition-cleanup-in-oracle-with-plsql-2hhh" id="article-link-2853582"&gt;
          Automating Old Partition Cleanup in Oracle with PL/SQL
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/automation"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;automation&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/database"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;database&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/sql"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;sql&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/mrcaption49/automating-old-partition-cleanup-in-oracle-with-plsql-2hhh" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/exploding-head-daceb38d627e6ae9b730f36a1e390fca556a4289d5a41abb2c35068ad3e2c4b5.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/multi-unicorn-b44d6f8c23cdd00964192bedc38af3e82463978aa611b4365bd33a0f1f4f3e97.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;6&lt;span class="hidden s:inline"&gt; reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/mrcaption49/automating-old-partition-cleanup-in-oracle-with-plsql-2hhh#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              Comments


              &lt;span class="hidden s:inline"&gt;Add Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            3 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
      <category>automation</category>
      <category>database</category>
      <category>sql</category>
    </item>
    <item>
      <title>Automating Old Partition Cleanup in Oracle with PL/SQL</title>
      <dc:creator>Pranav Bakare</dc:creator>
      <pubDate>Thu, 18 Sep 2025 12:03:30 +0000</pubDate>
      <link>https://forem.com/mrcaption49/automating-old-partition-cleanup-in-oracle-with-plsql-2hhh</link>
      <guid>https://forem.com/mrcaption49/automating-old-partition-cleanup-in-oracle-with-plsql-2hhh</guid>
      <description>&lt;h3&gt;
  
  
  &lt;strong&gt;Automating Old Partition Cleanup in Oracle with PL/SQL&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn19z1e2ixhl5fkpyg56s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn19z1e2ixhl5fkpyg56s.png" alt=" " width="800" height="927"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;ul&gt;
&lt;li&gt;This PL/SQL block is designed to automate partition maintenance for all tables owned by the schema CMN_OWNR. It loops through each table partition (skipping ones with INIT in their name), extracts the partition boundary date from the high_value column, and checks if it is on or before 1st June 2025. &lt;/li&gt;
&lt;li&gt;If the condition is met, it tries to drop the partition along with updating indexes; however, if the partition cannot be dropped due to being the last one (ORA-14758), it instead truncates the partition to remove data while keeping structure intact. &lt;/li&gt;
&lt;li&gt;This ensures that only old partitions are purged while preserving the latest required ones. In short, it’s a safe cleanup mechanism for managing historical data in partitioned tables.&lt;/li&gt;
&lt;/ul&gt;






&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;DECLARE&lt;/span&gt;
  &lt;span class="n"&gt;v_date&lt;/span&gt; &lt;span class="nb"&gt;DATE&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;v_sql&lt;/span&gt;  &lt;span class="n"&gt;VARCHAR2&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;BEGIN&lt;/span&gt;
  &lt;span class="k"&gt;FOR&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;table_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                   &lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;partition_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                   &lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;high_value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                   &lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;partition_position&lt;/span&gt;
              &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;dba_tab_partitions&lt;/span&gt; &lt;span class="n"&gt;dp&lt;/span&gt;
             &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;table_owner&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'CMN_OWNR'&lt;/span&gt;
               &lt;span class="k"&gt;and&lt;/span&gt; &lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;partition_name&lt;/span&gt; &lt;span class="k"&gt;not&lt;/span&gt; &lt;span class="k"&gt;like&lt;/span&gt; &lt;span class="s1"&gt;'%INIT%'&lt;/span&gt;
            &lt;span class="c1"&gt;--AND table_name = 'CMN_LOG'&lt;/span&gt;
             &lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;table_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;partition_position&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;LOOP&lt;/span&gt;
    &lt;span class="n"&gt;v_date&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;TO_DATE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;substr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;high_value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s1"&gt;'RRRR-MM-DD'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;IF&lt;/span&gt; &lt;span class="n"&gt;v_date&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;to_date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'01-JUN-2025'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'dd-mon-yyyy'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
      &lt;span class="n"&gt;v_sql&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'ALTER TABLE CMN_OWNR.'&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;table_name&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
               &lt;span class="s1"&gt;' DROP PARTITION '&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;partition_name&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s1"&gt;' UPDATE INDEXES'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;BEGIN&lt;/span&gt;
        &lt;span class="k"&gt;EXECUTE&lt;/span&gt; &lt;span class="k"&gt;IMMEDIATE&lt;/span&gt; &lt;span class="n"&gt;v_sql&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="n"&gt;EXCEPTION&lt;/span&gt;
        &lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="n"&gt;OTHERS&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
          &lt;span class="n"&gt;IF&lt;/span&gt; &lt;span class="k"&gt;SQLCODE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;14758&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
            &lt;span class="n"&gt;v_sql&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'ALTER TABLE CMN_OWNR.'&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;table_name&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
                     &lt;span class="s1"&gt;' TRUNCATE PARTITION '&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;partition_name&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
                     &lt;span class="s1"&gt;' UPDATE INDEXES'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="k"&gt;EXECUTE&lt;/span&gt; &lt;span class="k"&gt;IMMEDIATE&lt;/span&gt; &lt;span class="n"&gt;v_sql&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
          &lt;span class="k"&gt;ELSE&lt;/span&gt;
            &lt;span class="n"&gt;dbms_output&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;put_line&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SQLERRM&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="n"&gt;dbms_output&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;put_line&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v_sql&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
          &lt;span class="k"&gt;END&lt;/span&gt; &lt;span class="n"&gt;IF&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;END&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;END&lt;/span&gt; &lt;span class="n"&gt;IF&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;END&lt;/span&gt; &lt;span class="n"&gt;LOOP&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;EXCEPTION&lt;/span&gt;
  &lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="n"&gt;OTHERS&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
    &lt;span class="n"&gt;dbms_output&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;put_line&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SQLERRM&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;END&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;🔎 Step-by-step explanation&lt;/strong&gt;
&lt;/h3&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;1. Loop through all partitions&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;FOR&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
   &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;table_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;partition_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;high_value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;partition_position&lt;/span&gt;
   &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;dba_tab_partitions&lt;/span&gt; &lt;span class="n"&gt;dp&lt;/span&gt;
   &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;table_owner&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'CMN_OWNR'&lt;/span&gt;
     &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;partition_name&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;LIKE&lt;/span&gt; &lt;span class="s1"&gt;'%INIT%'&lt;/span&gt;
   &lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;table_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;partition_position&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;LOOP&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Finds all partitions of all tables owned by CMN_OWNR.&lt;/li&gt;
&lt;li&gt;Skips partitions whose name contains INIT.&lt;/li&gt;
&lt;li&gt;Loops through each partition in order.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;2. Extract partition boundary date&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;v_date&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;TO_DATE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SUBSTR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;high_value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s1"&gt;'RRRR-MM-DD'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;dba_tab_partitions.high_value is a text expression like:&lt;/li&gt;
&lt;li&gt;TO_DATE(' 2025-06-01 00:00:00','SYYYY-MM-DD HH24:MI:SS', ...)&lt;/li&gt;
&lt;li&gt;SUBSTR(...,12,10) picks 2025-06-01.&lt;/li&gt;
&lt;li&gt;TO_DATE(...,'RRRR-MM-DD') converts that to an Oracle DATE → 01-JUN-2025.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;3. Check if partition is old&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;IF&lt;/span&gt; &lt;span class="n"&gt;v_date&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;TO_DATE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'01-JUN-2025'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'DD-MON-YYYY'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If the partition’s upper boundary date is before or equal to 01-JUN-2025, it’s considered old → purge it.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;4. Try to drop the partition&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;v_sql&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'ALTER TABLE CMN_OWNR.'&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;table_name&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
         &lt;span class="s1"&gt;' DROP PARTITION '&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;partition_name&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; 
&lt;span class="s1"&gt;' UPDATE INDEXES'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;EXECUTE&lt;/span&gt; &lt;span class="k"&gt;IMMEDIATE&lt;/span&gt; &lt;span class="n"&gt;v_sql&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Builds dynamic SQL to drop the old partition.&lt;/li&gt;
&lt;li&gt;UPDATE INDEXES ensures local/global indexes remain usable.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;5. Handle errors&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;EXCEPTION&lt;/span&gt;
  &lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="n"&gt;OTHERS&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
    &lt;span class="n"&gt;IF&lt;/span&gt; &lt;span class="k"&gt;SQLCODE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;14758&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
      &lt;span class="n"&gt;v_sql&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'ALTER TABLE CMN_OWNR.'&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;table_name&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
               &lt;span class="s1"&gt;' TRUNCATE PARTITION '&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;partition_name&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
               &lt;span class="s1"&gt;' UPDATE INDEXES'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;EXECUTE&lt;/span&gt; &lt;span class="k"&gt;IMMEDIATE&lt;/span&gt; &lt;span class="n"&gt;v_sql&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;ELSE&lt;/span&gt;
      &lt;span class="n"&gt;dbms_output&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;put_line&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SQLERRM&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="n"&gt;dbms_output&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;put_line&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v_sql&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;END&lt;/span&gt; &lt;span class="n"&gt;IF&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If DROP fails with ORA-14758 (cannot drop the last partition in a range), it falls back to:&lt;/li&gt;
&lt;li&gt;ALTER TABLE ... TRUNCATE PARTITION ...&lt;/li&gt;
&lt;li&gt;→ keeps the partition structure but deletes its data.&lt;/li&gt;
&lt;li&gt;Any other error is logged with dbms_output.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;6. Global error handling&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;EXCEPTION&lt;/span&gt;
  &lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="n"&gt;OTHERS&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
    &lt;span class="n"&gt;dbms_output&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;put_line&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SQLERRM&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;END&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If the whole block fails for some reason, the error is printed.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Summary —&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This PL/SQL script automatically manages old partitions in Oracle tables owned by CMN_OWNR. It checks each partition’s HIGH_VALUE date and, if it is on or before 01-JUN-2025, it attempts to drop the partition. If dropping is not allowed (SQL error -14758), it instead truncates the partition while updating indexes. This helps keep partitioned tables lean by cleaning up historical data without manual intervention.&lt;/p&gt;

</description>
      <category>automation</category>
      <category>database</category>
      <category>sql</category>
    </item>
  </channel>
</rss>
