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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:05:30+00:00 2026-05-29T23:05:30+00:00

Can I do something like the following in PLSQL? if (some_query) then dbms_output.put_line(‘Your query

  • 0

Can I do something like the following in PLSQL?

if (some_query) then
    dbms_output.put_line('Your query returned at least 1 row.');
else
    dbms_output.put_line('Your query returned no rows.');
end if;

My use case is I want to check if a value already exists in my database. If the value already exists then I will do something different than if the value doesn’t exist at all.

  • 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-29T23:05:32+00:00Added an answer on May 29, 2026 at 11:05 pm

    If you a checking for existence of a record, then you can select COUNT(*) from the source table based on the key as it will always return a value you can check:

    SQL> set serverout on
    SQL> DECLARE
      2      v_check NUMBER;
      3  BEGIN
      4      SELECT COUNT(*)
      5      INTO v_check
      6      FROM DUAL
      7      WHERE DUMMY = 'X'
      8      AND ROWNUM = 1;
      9
     10      if (v_check = 0) then
     11          dbms_output.put_line('Your query returned no rows.');
     12      else
     13          dbms_output.put_line('Your query returned at least 1 row.');
     14      end if;
     15  END;
     16  /
    Your query returned at least 1 row.
    
    PL/SQL procedure successfully completed.
    
    SQL>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to do something like the following but can't seem to get
Is there a way I can do something like the following using the standard
Coming from the land of Perl, I can do something like the following to
How can something like the following be done in a PHP script? code{ $result1
In VB.Net you can do something like the following without any issues... just ignore
How can I achieve something like the following? public interface IGenericRepository { int id
I know I can do something like the following code to dynamically create a
In Java I can do something like the following: TreeMap<Double, String> myMap = new
I am wondering how I can implement something like the following: test(){ cat>file<<'EOF' abc
In MVC I can do something like the following to serialise an object with

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.