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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:23:20+00:00 2026-05-29T11:23:20+00:00

Often I use cursors in this way: for rec in (select * from MY_TABLE

  • 0

Often I use cursors in this way:

for rec in (select * from MY_TABLE where MY_COND = ITION) loop
    if rec.FIELD1 = 'something' then
        do_something();
    end if;

    if rec.FIELD2 <> 'somethingelse' then
        blabla();
    end if;
end loop;

My team leader told me not to use select * because it is bad programming, but I don’t understand why (in this context).

  • 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-29T11:23:21+00:00Added an answer on May 29, 2026 at 11:23 am

    Using select * in your code is what I would call lazy programming, with several nasty side effects. How much you experience those side effects, will differ, but it’s never positive.

    I’ll use some of the points already mentioned in other answers, but feel free to edit my answer and add some more negative points about using select *.

    1. You are shipping more data from the SQL engine to your code than necessary, which has a negative effect on performance.

    2. The information you get back needs to be placed in variables (a record variable for example). This will take more PGA memory than necessary.

    3. By using select * you will never use an index alone to retrieve the wanted information, you’ll always have to visit the table as well (provided no index exists which holds all columns of the table). Again, with a negative effect on performance.

    4. Less clear for people maintaining your code what your intention is. They need to delve into the code to spot all occurrences of your record variable to know what is being retrieved.

    5. You will not use SQL functions to perform calculations, but always rely on PL/SQL or Java calculations. You are possibly missing out on some great SQL improvements like analytic functions, model clause, recursive subquery factoring and the like.

    6. From Oracle11 onwards, dependencies are being tracked on column level, meaning that when you use select *, your code is being marked in the data dictionary as “dependent on all columns” of that table. Your procedure will be invalidated when something happens to one of those columns. So using select * means your code will be invalidated more often than necessary.

    Again, feel free to add your own points.

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

Sidebar

Related Questions

I often use webservice this way public void CallWebservice() { mywebservice web = new
I often use this recursive 'visitor' in F# let rec visitor dir filter= seq
I often use this code pattern: while(true) { //do something if(<some condition>) { break;
I often use git from Terminal on Mac to download some repositories and then
I often use visual block then inserting on multiple lines when for example commenting
i often use but i have this problem. if there is a whose action
We often use the following lambda expression MyList.Select(x => x.Id).ToList(); Is possible to get
I often use this code or a form of this code throughout OnClicks and
In my projects i often use get params as a temporary way to test
I often use this list command in Unix (AIX / KSH): ls -Artl It

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.