Sign Up

Sign Up to our social questions and Answers 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 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

Sorry, you do not have permission to add post.

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.

Oraask Logo Oraask Logo
Sign InSign Up

Oraask

  • Write
    • Add A New Post
    • Ask A Question

Oraask Navigation

Search
Ask A Question

Mobile menu

Close
  • Categories
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Dev Tools
    • Online Compiler
    • Base64 Converter
  • Wiki
    • SQL Tutorials
    • Java Tutorials
    • Python Tutorials
    • JavaScript Tutorials
Home/ Questions/Q 3856
Next
Answered

Oraask Latest Questions

Question
albert
  • 0
  • 0
albertExplorer
Asked: August 1, 20162016-08-01T18:13:11+03:00 2016-08-01T18:13:11+03:00In: PL/SQL

Can i use select statement inside if statement ? (if (select) > 0 then) ?

  • 0
  • 0

hello can I use select inside if statement like :

begin
if (select count(*) from employees) >= 15 then
do something;
end if;
end;

 

note : I want to delete rows from table where above condition evaluates with true

ifif statementoraclepl/sqlselect
1
  • 1 1 Answer
  • 998 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    Related Questions

    • Export query result to Oracle Server
    • What is the difference between Implicit and Explicit Cursor in Oracle
    • How many triggers can I create on a single table in Oracle Database
    • How many types of collections are there in Oracle
    • Can we extend Varray in Oracle PL/SQL

    1 Answer

    • Voted
    • Oldest
    • Recent
    1. Hassan AbdElrahman
      Best Answer
      Hassan AbdElrahman Master Oracle ACE Pro ♠ | Oracle Senior ERP Technical Consultant
      2016-08-19T22:34:43+03:00Added an answer on August 19, 2016 at 10:34 pm

      hello Beter,
      you can’t use SQL Statement directly in a PL/SQL expression instead you can use variable to store your count then use your variable into PL/SQL expression like this :

      DECLARE
        v_count   NUMBER;
      BEGIN
        SELECT count (*) INTO v_count FROM dual;

        IF v_count >= 1 THEN
          dbms_output.put_line ('true');
        ELSE
          dbms_output.put_line ('false');
        END IF;
      END;

      or as you mentioned if you want to use it inside delete statement like this :

      DELETE FROM table_1
      WHERE       (SELECT count (*) FROM table_2) >= 1;

      hope this helpful 🙂

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

    Leave an answer
    Cancel reply

    You must login to add an answer.

    Forgot Password?

    Need An Account, Sign Up Here

    Sidebar

    Adv 250x250

    Explore

    • Categories
    • Questions
      • New Questions
      • Trending Questions
      • Must read Questions
      • Hot Questions
    • Dev Tools
      • Online Compiler
      • Base64 Converter
    • Wiki
      • SQL Tutorials
      • Java Tutorials
      • Python Tutorials
      • JavaScript Tutorials

    Footer

    Oraask

    About

    Oraask is a website for developers and software engineers who want to learn new skills, share their knowledge, and solve their coding problems. Oraask provides free content on various programming languages and topics, such as Oracle, Python, Java, etc. Oraask also allows users to ask questions and get answers from other members of the community.

    About Us

    • About Us
    • Contact Us

    Legal Stuff

    • Privacy Policy
    • Terms & Conditions

    Follow

    Oraask is licensed under CC BY-NC-SA 4.0Oraask CopyrightOraask CopyrightOraask CopyrightOraask Copyright

    © 2019 Oraask. All Rights Reserved
    With Love by Oraask.

    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.