Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 875927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:21:09+00:00 2026-05-15T11:21:09+00:00

Friends, This Ask Tom thread which I found via another SO question, mentions Table

  • 0

Friends,

This Ask Tom thread which I found via another SO question, mentions Table and Transactional API’s and I’m trying to understand the difference between them.

A Table API (TAPI) is where there is no access to the underlying tables and there are “getters” & “setters” to obtain information.

For example to select an address I would:

   the_address := get_address(address_id);

Instead of:

   select the_address
   from some_table
   where identifier = address_id

And then to change the address I would invoke another TAPI which takes care of the change:

   ...
   change_address(address_id, new_address);
   ...

A Transactional API (XAPI) is again where there is no direct access to modify the information in the table but I can select from it? (this is where my understanding is kind of hazy)

To select an address I would:

   select the_address
   from some_table
   where identifier = address_id

and then to change it I would call

   ...
   change_address(address_id, new_address);
   ...

So the only difference I can see between a TAPI and a XAPI is the method in which a record is retrieved from the database, i.e. a Select Versus a PL/SQL call?

Is that it? or have I missed the point entirely?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T11:21:09+00:00Added an answer on May 15, 2026 at 11:21 am

    Let’s start with the Table API. This is the practice of mediating access to tables through a PL/SQL API. So, we have a package per table, which should be generated from the data dictionary. The package presents a standard set of procedures for issuing DML against the table and some functions for retrieving data.

    By comparison a Transactional API represents a Unit Of Work. It doesn’t expose any information about the underlying database objects at all. Transactional APIs offer better encapsulation, and a cleaner interface.

    The contrast is like this. Consider these business rules for creating a new Department:

    1. The new Department must have a Name and Location
    2. The new Department must have a manager, who must be an existing Employee
    3. Other existing Employees may be transferred to the new Department
    4. New employees may be assigned to the new Department
    5. The new Department must have at least two Employees assigned (including the manager)

    Using Table APIs the transaction might look something like this:

    DECLARE
        dno pls_integer;
        emp_count pls_integer;
    BEGIN
        dept_utils.insert_one_rec(:new_name, :new_loc, dno);
        emp_utils.update_one_rec(:new_mgr_no ,p_job=>'MGR’ ,p_deptno=>dno);
        emp_utils.update_multi_recs(:transfer_emp_array, p_deptno=>dno);
        FOR idx IN :new_hires_array.FIRST..:new_hires_array.LAST LOOP
            :new_hires_array(idx).deptno := dno;
        END LOOP;
        emp_utils.insert_multi_recs(:new_hires_array);
        emp_count := emp_utils.get_count(p_deptno=>dno); 
        IF emp_count < 2 THEN
            raise_application_error(-20000, ‘Not enough employees’);
        END IF;
    END;
    /
    

    Whereas with a Transactional API it is much simpler:

    DECLARE
        dno subtype_pkg.deptno;
    BEGIN
        dept_txns.create_new_dept(:new_name
                                    , :new_loc
                                    , :new_mgr_no
                                    , :transfer_emps_array
                                    , :new_hires_array
                                    , dno);
    END;
    /
    

    So why the difference in retrieving data? Because the Transactional API approach discourages generic get() functions in order to avoid the mindless use of inefficient SELECT statements.

    For example, if you just want the salary and commission for an Employee, querying this …

    select sal, comm
    into l_sal, l_comm
    from emp
    where empno = p_eno;
    

    … is better than executing this …

    l_emprec := emp_utils.get_whole_row(p_eno);
    

    …especially if the Employee record has LOB columns.

    It is also more efficient than:

    l_sal := emp_utils.get_sal(p_eno);
    l_comm := emp_utils.get_comm(p_eno);
    

    … if each of those getters executes a separate SELECT statement. Which is not unknown: it’s a bad OO practice that leads to horrible database performance.

    The proponents of Table APIs argue for them on the basis that they shield the developer from needing to think about SQL. The people who deprecate them dislike Table APIs for the very same reason. Even the best Table APIs tend to encourage RBAR processing. If we write our own SQL each time we’re more likely to choose a set-based approach.

    Using Transactional APis doesn’t necessarily rule out the use of get_resultset() functions. There is still a lot of value in a querying API. But it’s more likely to be built out of views and functions implementing joins than SELECTs on individual tables.

    Incidentally, I think building Transactional APIs on top of Table APIs is not a good idea: we still have siloed SQL statements instead of carefully written joins.

    As an illustration, here are two different implementations of a transactional API to update the salary of every Employee in a Region (Region being a large scale section of the organisation; Departments are assigned to Regions).

    The first version has no pure SQL just Table API calls, I don’t think this is a straw man: it uses the sort of functionality I have seen in Table API packages (although some use dynamic SQL rather than named SET_XXX() procedures).

    create or replace procedure adjust_sal_by_region
        (p_region in dept.region%type
               , p_sal_adjustment in number )
    as
        emps_rc sys_refcursor;
        emp_rec emp%rowtype;
        depts_rc sys_refcursor;
        dept_rec dept%rowtype;
    begin
        depts_rc := dept_utils.get_depts_by_region(p_region);
    
        << depts >>
        loop
            fetch depts_rc into dept_rec;
            exit when depts_rc%notfound;
            emps_rc := emp_utils.get_emps_by_dept(dept_rec.deptno);
    
            << emps >>
            loop
                fetch emps_rc into emp_rec;
                exit when emps_rc%notfound;
                emp_rec.sal := emp_rec.sal * p_sal_adjustment;
                emp_utils.set_sal(emp_rec.empno, emp_rec.sal);
            end loop emps;
    
        end loop depts;
    
    end adjust_sal_by_region;
    /
    

    The equivalent implementation in SQL:

    create or replace procedure adjust_sal_by_region
        (p_region in dept.region%type
               , p_sal_adjustment in number )
    as
    begin
        update emp e
        set e.sal = e.sal * p_sal_adjustment
        where e.deptno in ( select d.deptno 
                            from dept d
                            where d.region = p_region );
    end adjust_sal_by_region;
    /
    

    This is much nicer than the nested cursor loops and single row update of the previous version. This is because in SQL it is a cinch to write the join we need to select Employees by Region. It is a lot harder using a Table API, because Region is not a key of Employees.

    To be fair, if we have a Table API which supports dynamic SQL, things are better but still not ideal:

    create or replace procedure adjust_sal_by_region
        (p_region in dept.region%type
               , p_sal_adjustment in number )
    as
        emps_rc sys_refcursor;
        emp_rec emp%rowtype;
    begin
        emps_rc := emp_utils.get_all_emps(
                        p_where_clause=>'deptno in ( select d.deptno 
                            from dept d where d.region = '||p_region||' )' );
    
        << emps >>
        loop
            fetch emps_rc into emp_rec;
            exit when emps_rc%notfound;
            emp_rec.sal := emp_rec.sal * p_sal_adjustment;
            emp_utils.set_sal(emp_rec.empno, emp_rec.sal);
        end loop emps;
    
    end adjust_sal_by_region;
    /
    

    last word

    Having said all that, there are scenarios where Table APIs can be useful, situations when we only want to interact with single tables in fairly standard ways. An obvious case might be producing or consuming data feeds from other systems e.g. ETL.

    If you want to investigate the use of Table APIs, the best place to start is Steven Feuerstein’s Quest CodeGen Utility (formerly QNXO). This is about as good as TAPI generators get, and it’s free.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.