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

  • Home
  • SEARCH
  • 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 7814743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:17:29+00:00 2026-06-02T05:17:29+00:00

I believe I need a cursor for loop to go through the street1 column

  • 0

I believe I need a cursor for loop to go through the street1 column from table test_data. I have a program which needs to test each row from the table.

This is what I have so far:

cursor c1 is
street1
from test_data

Begin
    If Instr(street1, ‘Cnr’, 1) >= 1;
    Then
        Newstreetname := Substr(street1, Instr(street1, ‘Cnr’, 1)+3);
    Else if
        Instr(street1, ‘PO Box’, 1) >= 1;
    Then
        Newstreetname:= Substr(street1, Instr(street1, ‘PO Box’, 1));
    Else if
        REGEXP_ Instr (street1, [\d], 1) = 0; 
    Then
        Newstreetname:= street1;
    Else if
        REGEXP_ Instr (street1, [\d], 1) >= 1;
    Then
        Newstreetnumber:= regexp_substr(street1, '\d+(\s|\/)(\d+)?-?(\d+)?(\w {1})?'); 
        Newstreetname:= regexp_substr(street1, '(\w+\s\w+)$'); 
End
  • 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-06-02T05:17:31+00:00Added an answer on June 2, 2026 at 5:17 am
    1. You need a SELECT and a semicolon in the cursor definition

    2. You can add a FOR LOOP over the cursor

      For example:

       DECLARE
         cursor c1 is
           SELECT street1
           from test_data;
         r1 c1%ROWTYPE;
       BEGIN
         FOR r1 IN c1 LOOP
            ... do your stuff with r1.street1
         END LOOP;
       END;
      

      You can, alternatively, avoid the explicit cursor definition entirely, e.g.:

      FOR r1 IN (SELECT street1 FROM test_data) LOOP
        ... do your stuff with r1.street1
      END LOOP;
      
    3. Your IF statements cannot include a semicolon – e.g.:

       If
       Instr(r1.street1, 'Cnr', 1) >= 1
       Then
      
    4. [edit] so you want to update your table, columns newstreetnumber and newstreetname – in which case you could do something like this:

       DECLARE
         cursor c1 is
           SELECT street1
           from test_data
           FOR UPDATE;
         r1 c1%ROWTYPE;
       BEGIN
         FOR r1 IN c1 LOOP
            ... do your stuff with r1.street1
            UPDATE test_data
            SET newstreetnumber = ...
               ,newstreetname = ...
            WHERE CURRENT OF c1;
         END LOOP;
       END;
      

      Note, however, that this will not perform well for large volumes, and I’d prefer to do it all in one UPDATE statement.

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

Sidebar

Related Questions

I have a pie chart which is made using UIBezierPath's. I now need those
I have a problem that I believe I need to use grouping using xsl:key
My problem is that I need to run a .exe program from my c++
I believe this is possible but I haven't done it before. I need to
I believe I have disabled the view state on all controls as well as
I believe this question might have been previously attempted in 2006 on a different
I'm working on a stored procedure that uses a cursor on a temporary table
Using Django with a PostgreSQL (8.x) backend, I have a model where I need
How can I check if a field exists in a table. I need an
i have a table ---------- User ---------- userID(pk) startdate // update : i am

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.