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 583349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:46:59+00:00 2026-05-13T14:46:59+00:00

I currently have two fairly long select statements, identical apart from the fact that

  • 0

I currently have two fairly long select statements, identical apart from the fact that the first is looking to see if the row exists via count(*) and the second selecting the row into the rowtype variable based on an if statement. This is because the data is required for further manipulation

I know it is possible, but I am having a complete brainfreeze and google returns lots of information about select, and if/else but not branching based on select.

I’ve tried wrapping the select in an if statements and failed so I was wondering what else there is to try.

Update: Psuedo-example:

select count(*) into num_items where <very long operation>;
if (num_items = 1) then
  begin
  select * into row_item where <very long operation>;
  end;
else
  dbms_output.put_line('failure');
end if;

Also: On a slightly unrelated note, how do you get the dbms_output to flush immeadiately so you can see where the script is currently up to? At the moment it only prints once the script has ended.

Thanks.

  • 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-13T14:46:59+00:00Added an answer on May 13, 2026 at 2:46 pm

    I think the code you want is this:

    begin
      select * into row_item where <very long operation>;
    exception
      when too_many_rows then
        dbms_output.put_line('failure');
    end;
    

    dbms_output is only really any good for debugging while developing code, or for SQL scripts that you will run from SQL Plus or an IDE. You could use an autonomous transaction to write messages to a table; these can then be read by another session while the program is still running. See this question for more details.

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

Sidebar

Related Questions

I currently have a fairly long LINQ statement which pulls data from two tables:
I currently have two SQL commands. One retrieves a list of unique IDs from
I (currently) have two forms, one that needs to call the other. In other
Currently I have two tests that each individually test for a button_click within a
I currently have a fairly straight forward app, my first attempt at MVVM using
I am looking to optimize a fairly simple algorithm that is currently O(n 2
Brief: I'm fairly new to databases and currently have one with two tables for
This is a fairly basic question, I currently have two tables and in the
I currently have two different models: User and Project . The User model has
I currently have two Backbone models: user and project. I would like to have

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.