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

The Archive Base Latest Questions

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

I’m working on a project my boss gave me. I don’t have much experience

  • 0

I’m working on a project my boss gave me. I don’t have much experience but I have to learn it. It’s regarding Oracle DB 11g and I’m using SQLPlus and PL/SQL as the query language.

Basically for each query statement, I will need the script to interpret the results and output true/false to the file.

For example,

select id from sample_table where id=3;

/**code needed that will do something like:**/
/**if(id=3), write to file TRUE, else, write to file FALSE**/

select salary from sample2 where id=5;

/**similar code needed as above**/

select employee from sample3 where id=6;

/** another TRUE or FALSE output to the file **/

I have tried using DBMS_OUTPUT.PUT_LINE but have no idea on how to analyse directly the output from the query statements. Will greatly appreciate any help!

  • 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-22T17:27:28+00:00Added an answer on May 22, 2026 at 5:27 pm

    If you are selecting from different tables I would use the following – alternatively a cursor could be used if the same query was being used with only a parameter (like id) varying in which case you could use cursor parameters.

    DECLARE
       v_count    PLS_INTEGER;
    BEGIN
        SELECT COUNT(*)
        INTO v_count 
        FROM sample_table 
        WHERE id=3;
    
        CASE v_count
            WHEN 0 THEN dbms_output.put_line('FALSE');
            ELSE dbms_output.put_line('TRUE');
        END CASE;
    
    END;
    

    It is important to use COUNT(*) not count on a field as COUNT(*) still returns 0 if no records exist.

    Edit to add: The cursor equivalent is

    DECLARE
        v_count    PLS_INTEGER;
    
        CURSOR count_cur(cp_id  sample_table.id%TYPE)
        IS
            SELECT COUNT(*)
            FROM sample_table
            WHERE id = cp_id;
    BEGIN
        OPEN count_cur(3);
        FETCH count_cur INTO v_count;
        CLOSE count_cur;
    
        CASE v_count
            WHEN 0 THEN dbms_output.put_line('FALSE');
            ELSE dbms_output.put_line('TRUE');
        END CASE;
    
    END;
    

    There are also tests available on cursors such as cursor%FOUND or cursor%NOTFOUND that can be accessed once a cursor is opened. Although if all you are doing is testing whether a record exists that can be more verbose.

    Also bear in mind if you are doing a SELECT INTO statement that unless you are doing COUNT(*) which is guaranteed to always return a record it is good form to catch the possible too many or no rows exceptions.

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

Sidebar

Related Questions

I don't have much knowledge about the IPv6 protocol, so sorry if the question
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
I have thousands of HTML files to process using Groovy/Java and I need to
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.