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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:02:00+00:00 2026-05-25T17:02:00+00:00

I have created a for loop that loops until it hits 10 and outputs

  • 0

I have created a for loop that loops until it hits 10 and outputs INSERT everytime it hits 6 or 8 Now I want to insert a null value in the results column every time it hits a 6 or 8. How might I do this?

declare var1 number := 0;
begin
loop exit when var1 > 10; 
if var1 IN (6,8) THEN dbms_output.put_line(' INSERT'); ELSE
dbms_output.put_line(var1);
end if;
var1 := var1 + 1;
end loop;
dbms_output.put_line('Done');
end;
/

Table

 SQL> describe messages
 Name                                      Null?    Type
  ----------------------------------------- -------- ----------------------------

 RESULTS                                            VARCHAR2(60)
  • 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-25T17:02:01+00:00Added an answer on May 25, 2026 at 5:02 pm
    SQL> describe messages
     Name                                     Null?    Type
     ---------------------------------------- -------- ----------------------------
     RESULTS                                           VARCHAR2(60)
    
    SQL> SELECT COUNT(*) FROM messages;
    
      COUNT(*)
    ----------
             0
    
    SQL> SELECT * FROM messages;
    
    no rows selected
    
    SQL> get a.sql
      1  DECLARE
      2    var1 NUMBER := 0;
      3  BEGIN
      4    LOOP
      5      EXIT WHEN var1 > 10;
      6      IF var1 IN (6,8) THEN
      7        DBMS_OUTPUT.PUT_LINE(' INSERT');
      8        INSERT INTO messages VALUES (NULL);
      9      ELSE
     10        DBMS_OUTPUT.PUT_LINE(var1);
     11      END IF;
     12      var1 := var1 + 1;
     13    END LOOP;
     14    DBMS_OUTPUT.PUT_LINE('Done.');
     15* END;
     16  
     17  /
    0
    1
    2
    3
    4
    5
    INSERT
    7
    INSERT
    9
    10
    Done.
    
    PL/SQL procedure successfully completed.
    
    SQL> SELECT COUNT(*) FROM messages;
    
      COUNT(*)
    ----------
             2
    
    SQL> SELECT * FROM messages;
    
    RESULTS
    ------------------------------------------------------------
    
    
    
    SQL> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Inside a function I have created, I have this loop that checks if the
i have 5 links that gets created in a loop ($.each): $.each(data, function(index, element)
I have a for loop that creates multiple UIImageViews that I add to self.view
I have a recordset loop that creates a table, and every 9 items it
I have a loop created with each, check this example: $('.foo').each(function(i){ //do stuff });
I have created some python code which creates an object in a loop, and
I have created a PHP-script to update a web server that is live inside
I have created a UserControl that has a ListView in it. The ListView is
I have a method with a for() loop. In that loop, mylabel.text is updated
I have created a StreamReader that uses a FileStream. At the end of the

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.