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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:37:32+00:00 2026-06-09T11:37:32+00:00

I have a table which doesn’t have an unique ID. I want to make

  • 0

I have a table which doesn’t have an unique ID. I want to make a stored procedure which is adding to each row the number of the row as ID, but I don’t know how to get the current row number. This is what I have done until now

CREATE OR ALTER PROCEDURE INSERTID_MYTABLE 
returns (
    cnt integer)
as
declare variable rnaml_count integer;
begin
  /* Procedure Text */
  Cnt = 1;
  for select count(*) from MYTABLE r into:rnaml_count do
   while (cnt <= rnaml_count) do
    begin
     update MYTABLE set id=:cnt
       where :cnt = /*how should I get the rownumber here from select??*/
     Cnt = Cnt + 1; 
     suspend;
    end
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-09T11:37:33+00:00Added an answer on June 9, 2026 at 11:37 am

    I think better way will be:

    1. Add new nullable column (let’s call it ID).
    2. Create a generator/sequence (let’s call it GEN_ID).
    3. Create a before update/insert trigger that fetches new value from sequence whenever the NEW.ID is null. Example.
    4. Do update table set ID = ID. (This will populate the keys.)
    5. Change the ID column to not null.

    A bonus. The trigger can be left there, because it will generate the value in new inserted rows.

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

Sidebar

Related Questions

i have a table which has many fields but i want to get count
I have a table which I want to get the latest entry for each
I have a table view controller which doesn't let me manually scroll to the
I have a stored proc, SP1, which executes and does select on one table.
I have table which contains double values stored in mysql database ...I need to
I have table in which I am inserting rows for employee but next time
I have a table which i want to store all the outputs into one
I have 2 tables which doesn't have any references to each other and I'm
I have a table which has no identity column. I want to change a
I have a table with 27 varchar fields. I want to make all fields

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.