Saturday, June 21, 2025

ODI and Oracle SQL Questions & Answers - 6

What is Index Rebuild in Oracle?

Index Rebuild is the process of re-creating an index to improve performance, remove fragmentation, and reclaim space.

SQL:
ALTER INDEX index_name REBUILD;
ALTER INDEX index_name REBUILD ONLINE;
ALTER INDEX index_name REBUILD PARALLEL 4;

Used after heavy DML, fragmentation, or logical corruption.

What is a Partition in Oracle?

Partitioning divides a large table or index into smaller, manageable pieces.
Types: Range, List, Hash, Interval, Composite.

SQL Example:
CREATE TABLE sales (
  sale_id NUMBER,
  sale_date DATE,
  amount NUMBER
)
PARTITION BY RANGE (sale_date) (
  PARTITION p_2023 VALUES LESS THAN (TO_DATE('2024-01-01', 'YYYY-MM-DD')),
  PARTITION p_2024 VALUES LESS THAN (TO_DATE('2025-01-01', 'YYYY-MM-DD'))
);

What is Index and Why We Use It?

An index improves the speed of data retrieval operations.

Types: B-Tree, Bitmap, Unique, Composite, Function-Based.

SQL Example:
CREATE INDEX emp_idx ON employees(emp_id);

Strategy to Update 10 Million Records in Oracle

Use batching and commit periodically:

PL/SQL Example:
DECLARE
  l_rows NUMBER := 1;
BEGIN
  WHILE l_rows > 0 LOOP
    UPDATE your_table
    SET col1 = 'new_value'
    WHERE condition AND ROWNUM <= 50000;
    l_rows := SQL%ROWCOUNT;
    COMMIT;
  END LOOP;
END;

Alternative: Use Parallel DML or CTAS + RENAME for better performance.

How to Debug a Slow Query in Oracle

Steps:
1. Check execution plan: EXPLAIN PLAN FOR <your_query>;
2. View plan: SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);
3. Gather stats: EXEC DBMS_STATS.GATHER_TABLE_STATS('SCHEMA','TABLE');
4. Check blocking sessions: SELECT * FROM v$session WHERE blocking_session IS NOT NULL;
5. Use AWR: @$ORACLE_HOME/rdbms/admin/awrrpt.sql (if licensed)

What is Gather Stats in Oracle?

Gathering statistics helps the optimizer choose efficient plans.

SQL:
EXEC DBMS_STATS.GATHER_TABLE_STATS('SCHEMA_NAME', 'TABLE_NAME');
EXEC DBMS_STATS.GATHER_SCHEMA_STATS('SCHEMA_NAME');

Identify Bad Records in ODI (e.g., Junk Address Data)

Steps:
1. Load data to staging table.
2. Use REGEXP_LIKE or CASE to validate address column.
3. Route bad data to error table.

SQL Validation Example:
CASE
  WHEN NOT REGEXP_LIKE(ADDRESS, '^[A-Za-z0-9,\.-\s]{5,}$') THEN 'INVALID'
  ELSE 'VALID'
END

Query errors:
SELECT * FROM ERR_CUSTOMER;

Run Sub-Packages in Parallel in ODI

Yes, use 'Fork' in ODI Package to run sub-packages B and C in parallel.
Use 'Join' if you want to synchronize after both complete.

Load from One Source to Multiple Targets in ODI

Supported ways:
1. Multiple targets in same mapping.
2. Use SPLIT component to route conditionally.

3. Use different mappings for complex cases and run via a package. 

SQL | PL/SQL and ODI Interview Question - 5

 1. Have you worked on KMs? What are the KMs you have worked on?

 

   Yes, I have worked extensively with Knowledge Modules (KMs) in Oracle Data Integrator (ODI). The KMs I have worked on include:

   - IKM (Integration Knowledge Module): Used for data integration tasks such as loading data from source to target.

   - LKM (Loading Knowledge Module): Handles data loading tasks from the source system to the staging area.

   - RKM (Reverse Knowledge Module): Used for reverse-engineering data structures from source systems into ODI.

   - CKM (Check Knowledge Module): Used for data quality checks and validation during the integration process.

 

2. Which version of ODI are you currently working on?

 

   Currently, I am working with ODI 12c (12.2.1.4). This version provides enhanced features and improved performance for data integration tasks.

 

3. Can you please elaborate about your current project a little more in detail? What exactly is it about? What are your roles and responsibilities?

 

   In my current project, we are working on integrating and transforming data from various operational systems into a centralized data warehouse for a retail client. The project involves:

   - Extracting data from diverse sources such as transactional databases, flat files, and APIs.

   - Transforming and cleansing the data to ensure consistency and accuracy.

   - Loading the processed data into the target data warehouse for analytical and reporting purposes.

  

   My roles and responsibilities include:

   - Designing and developing ETL processes using ODI.

   - Creating and configuring Knowledge Modules (KMs) for efficient data processing.

   - Monitoring and troubleshooting data integration workflows.

   - Ensuring data quality and consistency through validation checks.

   - Collaborating with business analysts and other stakeholders to understand data requirements.

 

4. Can you elaborate about one of the failures or troubleshooting issues you have recently faced? What exactly was the issue? How did you troubleshoot and resolve it?

 

   Recently, I encountered an issue where a data integration process failed due to a data type mismatch between the source and target systems. Specifically, a column defined as VARCHAR in the source was mapped to a DATE type in the target, causing data load failures.

  

   To troubleshoot and resolve the issue:

   - I reviewed the data integration mappings and identified the data type mismatch.

   - I corrected the mapping by changing the target column type to VARCHAR to match the source.

   - I ran a test load to verify that the issue was resolved.

   - Additionally, I updated the documentation to reflect the correct data types and conducted a review of other mappings to prevent similar issues in the future.

 

5. Can you explain how to handle complex data transformation in ETL mapping?

 

   Handling complex data transformations in ETL mapping involves several steps:

   - Identify Business Requirements: Understand the transformation rules and logic required based on business needs.

   - Design Mapping Logic: Break down the transformation process into manageable components, such as data cleansing, aggregation, and calculation.

   - Use ODI Mapping Tools: Leverage ODI's graphical mapping tools and expressions to implement complex transformations. Use ODI's Expression Editor to create custom transformations.

   - Apply Transformations in Stages: Use staging tables to apply transformations in stages if needed. This helps in managing and debugging complex transformations.

   - Test Thoroughly: Perform extensive testing to ensure that transformations are accurate and meet business requirements.

   - Optimize Performance: Monitor and optimize the performance of transformations by reviewing execution plans and optimizing SQL queries.

 

6. How are normal data transformations handled in ETL mapping?

 

   Normal data transformations are handled through a series of steps:

   - Data Extraction: Extract data from source systems using ODI's Knowledge Modules.

   - Data Mapping: Define mappings between source and target data structures. Apply basic transformations like filtering, sorting, and joining.

   - Data Transformation: Apply standard transformations such as data type conversions, calculations, and data enrichment using ODI's mapping editor.

   - Data Validation: Perform data validation to ensure accuracy and completeness.

   - Data Loading: Load the transformed data into the target system using ODI's Integration Knowledge Modules.

 

7. Can you explain the steps involved in creating a load plan in ODI? How can we schedule and manage the execution of a load plan?

 

   To create a load plan in ODI:

   - Define the Load Plan: Create a new load plan in ODI Studio and define the sequence of execution for various steps and tasks.

   - Add Scenarios: Add the scenarios (predefined executable objects) to the load plan. Scenarios can include mappings, packages, and other tasks.

   - Define Execution Order: Set the execution order and dependencies between scenarios to ensure the correct sequence of execution.

   - Set Conditions: Specify any conditions that must be met for scenarios to execute.

  

   To schedule and manage the execution of a load plan:

   - Use ODI Scheduler: Configure the scheduling options using ODI's built-in scheduler or integrate with an external scheduling tool (like Oracle Enterprise Scheduler).

   - Monitor Execution: Use ODI's Operator interface to monitor the execution of load plans, view logs, and check for errors.

   - Adjust as Needed: Modify the load plan as necessary based on performance and requirements. Update schedules and dependencies as needed.

 

8. I need to define the execution order and condition. How can I do it for that particular scenario?

 

   To define the execution order and conditions:

   - Open the Load Plan: Access the load plan you are working on in ODI Studio.

   - Add and Arrange Scenarios: Add the necessary scenarios to the load plan and arrange them in the desired order.

   - Set Execution Order: Use the "Execution Order" tab to define the order in which the scenarios should run.

   - Define Conditions: Use the "Conditions" tab to specify any conditions or constraints for executing scenarios. Conditions can include success, failure, or custom expressions based on runtime data.

   - Save and Validate: Save your changes and validate the load plan to ensure that all configurations are correct.

 

9. Can you explain the concept of a snapshot fact table in a data warehouse? How does it differ from a factless fact table?

 

   A snapshot fact table in a data warehouse captures the state of data at specific points in time. It is used to track changes over time and allows for historical analysis. Snapshot fact tables typically contain:

   - Measures or metrics (e.g., sales figures).

   - Date or time dimensions to indicate when the snapshot was taken.

   - Additional dimensions related to the context of the snapshot (e.g., customer, product).

 

   A factless fact table, on the other hand, does not contain any measures or metrics. Instead, it primarily captures the relationship between different dimensions and is used to track events or transactions. For example:

   - A factless fact table could track student attendance (with dimensions like student, class, and date) without any numeric measures.

 

   In summary, snapshot fact tables are used for capturing and analyzing historical data with measures, while factless fact tables are used for recording the occurrence of events or relationships without measures.

 

ODI Interview Questions with Answers (Live Interview) - 4

1. Can you please tell me about yourself and your experience and all?

 

   I have been working as a PL/SQL Developer and ODI Specialist for the past 4 years. My experience includes developing and maintaining complex PL/SQL procedures, functions, and packages, as well as designing and implementing ETL processes using Oracle Data Integrator (ODI). I've worked on various projects that involve data migration, integration, and transformation, where I have utilized my skills in SQL, PL/SQL, and ODI to ensure data accuracy and efficiency. Additionally, I have been involved in performance tuning and optimization to enhance the speed and efficiency of data processing.

 

2. In which project are you working? Is it based on ETL, ODI, or PL/SQL?

 

   Currently, I am working on a project focused on data integration for a large retail client. The project involves ETL processes using ODI to integrate data from various sources into a central data warehouse. My role includes developing ODI mappings, creating PL/SQL procedures for data transformation, and ensuring that the data integration processes are robust and efficient.

 

3. Can you please explain the difference between ETL and ELT with an example?

 

   ETL (Extract, Transform, Load) and ELT (Extract, Load, Transform) are two data processing approaches:

 

   - ETL: Data is extracted from the source, transformed in a staging area, and then loaded into the target data warehouse. For example, if we extract sales data from different systems, transform it (e.g., converting date formats, aggregating data), and then load it into a data warehouse, that's ETL.

 

   - ELT: Data is extracted and loaded into the target data warehouse first, and then transformed within the data warehouse. For instance, if we load raw sales data directly into a data warehouse and perform transformations such as cleaning and aggregation using SQL queries or data processing tools in the warehouse, that's ELT.

 

4. Can you rate yourself in SQL and PL/SQL out of 10?

 

   I would rate myself 8/10 in SQL and PL/SQL. I have extensive experience in writing complex queries, optimizing performance, and developing PL/SQL procedures, functions, and packages. I continuously seek to improve my skills and stay updated with best practices.

 

5. Do you have any experience in DBA-related tools?

 

   Yes, I have experience working with Oracle Enterprise Manager for database monitoring and management. I am familiar with tasks such as database backup and recovery, performance tuning, and user management. Additionally, I have used tools like SQL*Plus and Toad for database development and administration.

 

6. Can you please explain Oracle Architecture?

 

   Oracle Database architecture consists of the following main components:

 

   - Instance: Consists of the Oracle background processes and memory structures (SGA - System Global Area and PGA - Program Global Area) that manage database operations.

   - Database: The physical files that store data, including datafiles, redo log files, and control files.

   - Tablespaces: Logical storage units that group datafiles and manage data storage.

   - Datafiles: Physical files on disk that store database data.

   - Redo Log Files: Files that record all changes made to the database to ensure data recovery.

   - Control Files: Files that store metadata about the database structure and state.

 

7. How does the UPDATE command work internally?

 

   The UPDATE command modifies existing records in a table. Internally, Oracle performs the following steps:

 

   - Row Identification: Locates the rows to be updated based on the WHERE clause.

   - Locking: Places a lock on the identified rows to prevent concurrent modifications.

   - Modification: Updates the row data with the new values specified.

   - Logging: Records the changes in redo log files to ensure recoverability.

   - Commit: If the transaction is committed, changes are made permanent; otherwise, they are rolled back.

 

8. Do you have procedure tuning experience?

 

   Yes, I have experience in tuning PL/SQL procedures. This involves analyzing execution plans, optimizing SQL queries within procedures, using appropriate indexes, and minimizing context switches between SQL and PL/SQL. I also use tools like Oracle’s SQL Trace and TKPROF to identify and resolve performance bottlenecks.

 

9. What is the main use of Synonyms? Have you created Synonyms in your previous projects?

 

   Synonyms provide a way to create an alias for database objects, making it easier to reference objects without specifying the schema name. They are useful for simplifying SQL statements and managing object references across different schemas. Yes, I have created synonyms in previous projects to simplify access to frequently used tables and views and to support cross-schema access.

 

10. We have two tables with a parent and child relationship. Is it possible to remove any records from the parent table if we have records in the child table for the parent key?

 

    No, it is not possible to delete records from the parent table if there are dependent records in the child table unless you have defined a cascading delete rule on the foreign key constraint. Without cascading delete, Oracle will enforce referential integrity and prevent the deletion to avoid orphaned records.

 

11. What is the error if we delete data from the parent table?

 

    If you attempt to delete a record from the parent table while there are related records in the child table, you will encounter a "ORA-02292: integrity constraint (constraint_name) violated - child record found" error. This error indicates that the delete operation is being blocked due to the presence of dependent child records.

 

12. Have you worked on SQL Loader and XML table `ult_file` package?

 

    Yes, I have experience with SQL Loader for loading data from flat files into Oracle tables. SQL Loader allows for efficient bulk data loading with various options for data transformation and error handling. I have also worked with XML data using the `ult_file` package to handle XML files and integrate them into the database.

 

13. Let’s consider a scenario. If there are 6 interfaces running sequentially and one of the interfaces failed (2nd or 3rd) run, how will you rectify this error?

 

    To rectify the error, I would:

 

    - Review Logs: Check the logs of the failed interface to identify the root cause of the failure.

    - Fix Issue: Address the specific issue (e.g., data errors, connection issues, etc.) that caused the failure.

    - Re-run Failed Interface: Manually or automatically re-run the failed interface after resolving the issue.

    - Validate: Ensure that the interface completed successfully and validate the data.

    - Monitor: Monitor subsequent interfaces to ensure that they run without issues.

 

14. What are the different types of DB objects you have created in your project?

 

    In my projects, I have created various database objects including:

 

    - Tables: For storing structured data.

    - Views: For simplifying complex queries and restricting access.

    - Indexes: For improving query performance.

    - Sequences: For generating unique identifiers.

    - Synonyms: For aliasing database objects.

    - Procedures: For encapsulating business logic.

    - Functions: For reusable code that returns a value.

    - Packages: For grouping related procedures and functions.

    - Triggers: For automatically performing actions in response to changes in the database.

 

15. What is the difference between a procedure, function, and package?

 

    - Procedure: A stored PL/SQL block that performs an action but does not return a value. It can modify database state and accept parameters.

    - Function: A stored PL/SQL block that returns a value. It is typically used for computations and can be used in SQL statements.

    - Package: A collection of related procedures, functions, variables, and cursors grouped together. Packages help organize code and provide encapsulation and modularity.

 

16. Is it possible to use SYSDATE in CHECK constraints?

 

    No, it is not possible to use SYSDATE in CHECK constraints. CHECK constraints evaluate conditions on row values, but SYSDATE is a dynamic value that changes with each query execution, which makes it unsuitable for static constraints.

 

17. Updating the same record by two users, what will happen?

 

    When two users attempt to update the same record simultaneously, Oracle handles this with row-level locking. One user will acquire a lock on the record and the other will have to wait until the first transaction is committed or rolled back. If the first user commits their changes, the second user’s update will be applied. If the first user rolls back, the second user's update will proceed without conflicts.

 

18. Did you work on the creation of jobs?

 

    Yes, I have worked on creating and managing jobs using Oracle's DBMS_SCHEDULER package and DBMS_JOB package. I have scheduled various tasks such as data loads, backups, and maintenance procedures to run at specific intervals or based on specific conditions.

 

19. What is polymorphism in Oracle PL/SQL?

 

    Polymorphism in PL/SQL refers to the ability to define multiple procedures or functions with the same name but different parameter lists (overloading). It allows for more flexible and modular code. For example, you can have a procedure `calculate` that handles different types of calculations based on the number and type of parameters passed.

 

Here are the answers to the additional interview questions:

 

20. What are the different types of collection methods you have used in your previous projects?

 

    In my previous projects, I have used the following types of PL/SQL collections:

 

    - Associative Arrays (Index-by Tables): These are useful when you need to use a unique key (like a string) to access elements. They are often used for lookups or to hold data where the key is not a sequential number.

    - Nested Tables: These are useful when you need to store a set of elements of the same type and you want to be able to dynamically resize the collection. They are often used in situations where the number of elements is variable.

    - VARRAYs (Variable-size Arrays): These are used when you need a fixed-size collection that can grow up to a specified limit. They are less flexible compared to nested tables but useful when you know the maximum number of elements beforehand.

 

21. What is the difference between static cursor and dynamic cursor?

 

    - Static Cursor: A static cursor is associated with a result set that is fixed when the cursor is opened. It does not reflect changes made to the underlying data after the cursor is opened. Static cursors are generally used when you want a consistent view of the data, regardless of subsequent changes. In PL/SQL, a static cursor is defined with a `REF CURSOR` that is not intended to be updated dynamically.

 

    - Dynamic Cursor: A dynamic cursor reflects changes made to the data in the database while the cursor is open. If the underlying data changes (e.g., new rows are inserted, or existing rows are updated or deleted), the dynamic cursor will see these changes. This type of cursor is useful for queries where you need to see real-time updates to the data.

 

22. We have two databases DEV and SYS, and the same table exists in both databases. We want to load the data dynamically, so whenever you pass the table name it should load to the DEV table.

 

    You can achieve this using a combination of dynamic SQL and database links. Here’s an example approach:

 

    - Create a Database Link: Set up a database link in DEV to connect to the SYS database.

 

      ```sql

      CREATE DATABASE LINK sys_link

      CONNECT TO sys IDENTIFIED BY password

      USING 'sys_db';

      ```

 

    - Use Dynamic SQL: Write a PL/SQL procedure that dynamically constructs and executes an SQL statement to load data from SYS to DEV.

 

      ```sql

      CREATE OR REPLACE PROCEDURE LoadData(p_table_name IN VARCHAR2) IS

      BEGIN

          EXECUTE IMMEDIATE

              'INSERT INTO dev.' || p_table_name ||

              ' SELECT * FROM ' || p_table_name || '@sys_link';

      END;

      ```

 

      In this procedure, `p_table_name` is the name of the table you want to load, and `@sys_link` specifies the database link to SYS.

 

23. If we have Procedure B in Procedure A, and Procedure B is calling Procedure C. If we get an error, how to find out that error? Is there any methodology we have?

 

    To find out the error when Procedure B calls Procedure C within Procedure A, follow these steps:

 

    - Exception Handling: Implement exception handling in Procedure A, Procedure B, and Procedure C to capture and log errors.

 

      ```sql

      BEGIN

          -- Call Procedure B

          Procedure_B;

      EXCEPTION

          WHEN OTHERS THEN

              -- Log the error

              DBMS_OUTPUT.PUT_LINE('Error in Procedure A: ' || SQLERRM);

              RAISE; -- Optionally re-raise the error

      END;

      ```

 

    - Error Logging: Use error logging tables or packages to capture error details. For example, create a table to store error information and insert error details into this table from the exception handling sections.

 

    - Stack Trace: In PL/SQL, you can use `DBMS_UTILITY.FORMAT_ERROR_BACKTRACE` to get a stack trace of where the error occurred.

 

      ```sql

      BEGIN

          -- Call Procedure B

          Procedure_B;

      EXCEPTION

          WHEN OTHERS THEN

              DBMS_OUTPUT.PUT_LINE('Error: ' || SQLERRM);

              DBMS_OUTPUT.PUT_LINE('Backtrace: ' || DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);

      END;

      ```

 

24. Do you have exposure to Materialized Views?

 

    Yes, I have worked with Materialized Views. Materialized Views are used to improve query performance by precomputing and storing the results of a query. They are particularly useful for reporting and data warehousing scenarios. I have created and managed Materialized Views to handle large volumes of data and refresh them periodically or on-demand to ensure data accuracy.

 

25. We have one procedure where we have called another procedure. If we change the name of the calling procedure, will the main procedure still work?

 

    No, if you change the name of the calling procedure, the main procedure will not work unless you also update the references to the calling procedure. Procedure names must be consistent across all references, so you need to update all invocations of the procedure to reflect the new name.

 

26. We have one procedure where after BEGIN we have a DELETE command, then an UPDATE command, then we called another procedure and then a ROLLBACK command. Will it work or not?

 

    Yes, the ROLLBACK command will undo all changes made in the transaction, including the DELETE and UPDATE operations. When you issue a ROLLBACK, any changes made to the database during the transaction (including calls to other procedures that perform data modifications) are reverted. The state of the database will be as it was before the BEGIN statement.

 

27. What is the use of PRAGMA SERIALLY_REUSABLE?

 

    `PRAGMA SERIALLY_REUSABLE` is a compiler directive in PL/SQL used to mark a package as "serially reusable." This means the package is designed to be instantiated once per session and then reused multiple times, which can help improve performance. It signals that the package does not maintain session-specific state and is optimized for cases where the package is instantiated and used multiple times within a single session.

 

28. Suppose I want to stop the transaction during the month-end. How to do that?

 

    To stop a transaction during month-end or any specific period, you can:

 

    - Use Application Logic: Implement application-level logic to check for the month-end condition and halt transactions or certain operations if the condition is met.

 

    - Database Triggers: Implement database triggers to prevent data modifications during specific periods, such as the end of the month. For example, a BEFORE INSERT or BEFORE UPDATE trigger can be used to check the current date and raise an exception if it falls within the restricted period.

 

    - Scheduled Jobs: Schedule database jobs to check for transactions or halt certain operations during the month-end. For example, you can use Oracle Scheduler to manage tasks that should be stopped or modified at month-end.

 

    - Manual Intervention: If automatic methods are not feasible, manual intervention by database administrators or application support teams can also be used to stop transactions during critical periods.

Friday, June 20, 2025

PL/SQL Questions and Answers - 3

 

Difference between BULK COLLECT and FORALL


BULK COLLECT:
- Retrieves multiple rows from a query into a PL/SQL collection in one go.
- Improves performance by reducing context switches between SQL and PL/SQL engines.
Example:
SELECT empno BULK COLLECT INTO v_ids FROM emp;

FORALL:
- Executes DML statements for all elements in a collection.
- Also reduces context switching and improves performance.
Example:
FORALL i IN 1..v_ids.COUNT
  DELETE FROM emp WHERE empno = v_ids(i);

 

PL/SQL Data Types in Oracle


1. Scalar Types: NUMBER, VARCHAR2, DATE, BOOLEAN, etc.
2. Composite Types: RECORD, TABLE, VARRAY, Nested Tables
3. Reference Types: REF CURSOR
4. LOB Types: BLOB, CLOB, NCLOB, BFILE
5. User-defined Types: OBJECT types, Custom RECORDs

 

What is a Collection in Oracle


A collection is a composite data type for storing multiple values like arrays.
Types:
- Associative Arrays (Index-by tables)
- Nested Tables
- VARRAYs

Uses: BULK COLLECT, FORALL, parameter passing, temporary storage.

 

Types of Memory in Oracle Database


1. System Global Area (SGA): Shared memory (Buffer Cache, Shared Pool, Redo Log Buffer, etc.)
2. Program Global Area (PGA): Private memory for each session (sorting, hash joins, etc.)
3. User Global Area (UGA): Session memory, stored in PGA or SGA based on connection mode.
4. Software Code Area: Stores Oracle server code in memory.

 

Types of Views in Oracle


1. Simple View - One table, no joins or groups
2. Complex View - Joins, aggregates, functions
3. Inline View - Subquery in FROM clause
4. Materialized View - Stores physical data
5. Read-Only View - Prevents DML
6. Updatable View - Allows DML under conditions
7. Object View - Based on object types

 

Types of Refresh in Materialized View


1. FAST - Uses materialized view log for incremental refresh
2. COMPLETE - Refreshes entire data
3. FORCE - Tries FAST, then COMPLETE if not possible
4. ON DEMAND - Manually refresh via DBMS_MVIEW.REFRESH
5. SCHEDULED - Refreshes periodically (e.g., hourly, daily)

 

Incremental Update Without MERGE


Step 1: Update existing rows
UPDATE target SET col = (SELECT col FROM source WHERE key = target.key)
WHERE EXISTS (SELECT 1 FROM source WHERE key = target.key);

Step 2: Insert new rows
INSERT INTO target SELECT * FROM source
WHERE NOT EXISTS (SELECT 1 FROM target WHERE key = source.key);

Optional Step 3: Delete missing rows
DELETE FROM target WHERE NOT EXISTS (SELECT 1 FROM source WHERE key = target.key);

ODI & Oracle: Interview Questions and Concepts - 2

 

What is a Work Repository in ODI?

ODI Work Repository stores project-specific metadata. Types:
1. Development Work Repository – Full design and execution
2. Execution Work Repository – Execution only, no design capabilities

Where can we use variables in ODI?

Variables can be used in Mappings, Procedures, Packages, Scenarios, Load Plans, and Knowledge Modules. They help in dynamic filtering, parameter passing, and conditional execution.

Can we connect Physical Schema directly in mapping?

No, mappings connect through Logical Schema. Logical Schemas resolve to Physical Schemas using Contexts.

In CDC, how does ODI know that a new record is inserted?

ODI uses Journalizing via Change Data Capture (CDC). It tracks changes in a journal table (e.g., J$TABLENAME) using triggers or LogMiner, and uses IUD_FLAG to distinguish insert, update, delete.

We want to process only update data from source to target using incremental update

Use CDC with IUD_FLAG = 'U' to process updates only. Alternatively, filter records using LAST_UPDATED_DATE > #LAST_RUN_DATE and update the variable after each run.

Force Editionable View

FORCE EDITIONABLE VIEW allows you to create a view in Oracle even if underlying objects don’t exist yet. It's useful in Edition-Based Redefinition (EBR) environments.
Syntax: CREATE OR REPLACE FORCE EDITIONABLE VIEW view_name AS SELECT ... FROM ...;

SQL Interview Questions - 1

Q.1: What is NVL function?

Answer: NVL function is used to replace null value with another value.

NVL(exp1,exp2)

Q.2: What is the Cartesian product?

Answer: A Cartesian product is the result of joining every row in one table with every row in another table. This occurs when there is no WHERE clause to restrict rows. (Cross Join)

Q.3: Delete the all duplicate records from below table data-

T1:

C1

1

2

2

3

3

3

4

4

4

4

 

Answer: delete from T1 where rowid not in (select min(rowid) from T1 group by C1);

Q.4: What is LIST_AGG() function?

Answer:

Syntax: LIST_AGG(exp1 ,’[delimiter]’) WITHIN GROUP (order_by_clause) [OVER query_partition_clause]

Example: select country, LISTAGG(first_name, ', ') within group (order by first_name) as Name_List from customer group by country order by country;

Definition 1: LISTAGG() function is used to transform the data from multiple rows into single list of values separated by a specified delimiter.

 

Definition 2: LISTAGG function is used to aggregate a set of string values within a group into a single string by appending the string-expression values based on the order that's specified in the 'WITHIN GROUP' clause. As a single-set aggregate function, LISTAGG operates on all rows and returns a single output row.

Q.5: What is the use of LEAD() and LAG() function?

Answer: Oracle LEAD() is an analytic function that allows you to access the following row from the current row without using a self-join.

Syntax:

LEAD(expression [, offset ] [, default ])

OVER (

       [ query_partition_clause ]

       order_by_clause

)

 

Oracle LAG() is an analytic function that allows you to access the row at a given offset prior to the current row without using a self-join.

Syntax:

LAG(expression [, offset ] [, default ])

OVER (

            [ query_partition_clause ]

            order_by_clause

)

Q.6: How to store PDF file in Database table?

Answer: To store a PDF file in a database table, you typically use a BLOB (Binary Large Object) column, which is designed to hold binary data like images, documents, or multimedia files.

ODI Interview Question and Answers 29 September 2025

  Q: What is the basic difference between ETL and ELT approach? A: ETL extracts and transforms data outside the DB before loading, while E...