Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

PL/SQL & T-SQL (Oracle and SQL Server) Module 16

Across both engines: porting and concurrency interview questions

Interview questions on “Across both engines: porting and concurrency”: warm-ups, then what each harder question tests and how a good answer starts.

8 questions: 3 warm-ups and 5 with model answers · Levels: Fresher to staff

Warm-up questions

Short questions with short answers, each answered in full.

  1. Fresher to mid

    How does a PL/SQL EXCEPTION section map to T-SQL?

    The statements move into BEGIN TRY ... END TRY and the handlers into one BEGIN CATCH ... END CATCH block that follows it. PL/SQL picks a handler by exception name; T-SQL has a single CATCH block that reads ERROR_NUMBER(), ERROR_MESSAGE() and the other error functions, the counterparts of SQLCODE and SQLERRM, and branches on the number, 8134 for example where PL/SQL had WHEN ZERO_DIVIDE, with a last branch for WHEN OTHERS. An application error raised with RAISE_APPLICATION_ERROR and a number from -20000 to -20999 becomes THROW with a number of 50,000 or more, and a RAISE that re-raises inside a handler becomes THROW; with no arguments.

    From the lesson Porting code between PL/SQL and T-SQL

  2. Fresher to mid

    Where does a PL/SQL package variable go in a T-SQL port?

    A package variable keeps its value for the whole session and across calls, and T-SQL has neither packages nor variables that outlive a batch. Small values that belong to one session, such as a counter or the current user's id, move to SESSION_CONTEXT: sp_set_session_context stores a key with a value of up to 8,000 bytes, 1 MB in all, and SESSION_CONTEXT reads it in later batches of the same session. Values that must last beyond the session, or that several sessions share, move to a table. Package constants become literals, functions or rows of a settings table.

    From the lesson Porting code between PL/SQL and T-SQL

  3. Fresher to mid

    Why can a report wait for a writer on SQL Server but not on Oracle?

    The engines serve readers in different ways. Oracle answers each query from the data committed when the query began: when a row has been changed and not committed, it rebuilds the old version from undo data, so a reader takes no lock and a writer's lock never stops it; only SELECT ... FOR UPDATE asks for the row lock. SQL Server's default, READ COMMITTED with READ_COMMITTED_SNAPSHOT off, takes a shared lock on each row it reads, and a shared lock waits for a writer's exclusive lock until the writer's transaction ends, or until SET LOCK_TIMEOUT ends the statement with error 1222. Turning READ_COMMITTED_SNAPSHOT on makes SQL Server readers use row versions, and they stop waiting.

    From the lesson Oracle vs SQL Server: reads, locks and deadlocks

Questions with model answers

What each question tests, the first step of a good answer and the follow-ups to expect.

  1. Mid to senior

    A PL/SQL billing package of 12 procedures is being ported to T-SQL. Design its parity tests: which cases you write, how you compare the results of the two engines, and which differences, if any, you would accept.

    What it tests
    Turning the semantic and error differences between the engines into concrete test cases, and comparing results across engines with a canonical fingerprint rather than by eye.
    First step
    List the rules that can change results without an error, empty strings, NULLs, case, spaces, division, dates, errors and package state, and write at least one case per rule that each procedure touches and that would fail if the port broke it. Then fix one canonical form for the results of the reference queries.
    Follow-ups

    From the lesson Porting code between PL/SQL and T-SQL

    Model answer, Pro. Model answers open with any pass; prices are in the notice on this page.

    Opening the model answers with your pass…

    Model answers open with any MySmartCoPilot pass.

    • Pro pass · 1 week₹79$2.99
    • 30 days₹179$5.99
    • 1 year₹1,699$45

    One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.

    It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  2. Mid to staff

    SSMA converted a PL/SQL schema of 40 objects to T-SQL, its report shows no conversion errors, and the team wants to switch the callers next week. What can a clean conversion still hide, and how would you find it before the switch?

    What it tests
    Knowing that a conversion without errors can still change results and transaction behaviour, and planning checks that find those changes before callers depend on them.
    First step
    A clean report means every object became valid T-SQL, not that it behaves the same. Start from the behaviours that change silently and where they live in the code: string and NULL handling, ordering, dates, division, error handlers, transaction boundaries and package state.
    Follow-ups

    From the lesson Porting code between PL/SQL and T-SQL

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  3. Mid to senior

    A transfer procedure ported from PL/SQL to T-SQL kept its old deadlock handler: catch the error, pause, run the failed UPDATE again, commit. Since the port, a few customers a week receive credits that nobody debited. Explain what changed and redesign the handler so that it is correct on both engines.

    What it tests
    Knowing what ORA-00060 and error 1205 each roll back, and redesigning a retry so that it is correct on both engines.
    First step
    Compare what each error leaves behind. ORA-00060 undoes only the statement that detected the deadlock, so on Oracle the debit was still in the open transaction when the credit ran again. Error 1205 rolls back the victim's whole transaction, so on SQL Server the debit is gone and the repeated credit runs alone.
    Follow-ups

    From the lesson Oracle vs SQL Server: reads, locks and deadlocks

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  4. Mid to staff

    An Oracle batch runs at SERIALIZABLE and retries on ORA-08177. Its port to SQL Server sets SERIALIZABLE too. It never fails now, but order entry waits for minutes while the batch runs. Explain why, and choose the SQL Server setup that keeps the batch's Oracle behaviour.

    What it tests
    Knowing that Oracle's SERIALIZABLE works with versions and SQL Server's with locks, and choosing the SQL Server level that keeps the batch's behaviour, with its prerequisite, its error and its cost.
    First step
    The two levels share a name, not a mechanism. Oracle's SERIALIZABLE reads versions and locks nothing it reads, so order entry never waited. SQL Server's holds shared and key-range locks to the end of the transaction, so every order that touches a row or range the batch read waits for the batch.
    Follow-ups

    From the lesson Oracle vs SQL Server: reads, locks and deadlocks

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 4 minutes
  5. Mid to senior

    Three queries make up a month-end report: the ledger total, the total per account and the number of postings. On Oracle it runs in SET TRANSACTION READ ONLY and the numbers always agree. On SQL Server with READ_COMMITTED_SNAPSHOT on, they sometimes disagree by one posting. Explain why, and port the report.

    What it tests
    Telling statement-level from transaction-level read consistency, and porting a read-only Oracle transaction to the SQL Server setting that keeps one view for all three queries.
    First step
    RCSI gives each statement the data committed when that statement began. A posting committed between the first and the third query is in one number and not in another. Oracle's READ ONLY transaction gave all three queries the view of its own start.
    Follow-ups

    From the lesson Oracle vs SQL Server: reads, locks and deadlocks

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes

All PL/SQL & T-SQL (Oracle and SQL Server) interview questions · The PL/SQL & T-SQL (Oracle and SQL Server) track

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.