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

  • SEARCH
  • Home
  • 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 5936843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:27:19+00:00 2026-05-22T15:27:19+00:00

Whenever a query in PL/SQL is written where only one row is expected, there

  • 0

Whenever a query in PL/SQL is written where only one row is expected, there are two ways it is often done:

  1. Use an implicit SELECT INTO, and check for TOO_MANY_ROWS and NO_DATA_FOUND exceptions.
  2. Use an explicit cursor and just fetch the first row from the cursor.

Though both the approaches yield the same result, what are the pros and cons of these approaches?

  • 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-22T15:27:20+00:00Added an answer on May 22, 2026 at 3:27 pm

    When a select statement is expected to return exactly one row then a “SELECT INTO” is the better approach. Yes, many developers prefer to use a cursor and fetch only one row because it saves them the “bother” of dealing with NO_DATA_FOUND – i.e. they sweep the problem under the carpet and leave the user with a mysterious bug. I blogged about this bad practice* recently.

    (* a bad practice that is often sadly enshrined in project PL/SQL standards!)

    As for counting and then querying, that just doubles the work so is to be avoided too.

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

Sidebar

Related Questions

Whenever I try to create more than one table in actionscript, only the first
I've a terrible memory. Whenever I do a CONNECT BY query in Oracle -
Whenever I design a database, I always wonder if there is a best way
Whenever I restore a backup of my database in SQL Server I am presented
Whenever I use the signal/slot editor dialog box, I have to choose from the
My application constructs a Linq To Sql query and then populates a model which
I have some C# code that dynamically generates an SQL query and executes it
I've got the following bit of code as part of a SQL Query: INSERT
I am having problem with named query parameter. My query is as follow: <sql-query
I am trying to execute an SQL query on an Adaptive Server Anywhere database.

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.