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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:42:59+00:00 2026-05-31T01:42:59+00:00

I have to add many registries to a table and I need help since

  • 0

I have to add many registries to a table and I need help since I am starting to work with PL/SQL

I have a table with three columns (ID, KEY, VALUE). The ID & KEY has to be unique, and if there is not a value for a KEY called ‘process_name’ is have to create a new registry where the value has to be the same as the ID.

for example, I could have this in my table

ID      KEY            VALUE
A       cycles           4  
A       process_name     A
A       number           2
B       cycles           3
B       number           2
C       cycles           5

So, I would need to insert 2 records to the DB:

B      process_name       B
C      process_name       C

How should I start creating the script?

Thanks

SOLUTION

INSERT INTO my_table
   (SELECT distinct my_table.ID, 'process_name', my_table.ID
      FROM my_table
      WHERE my_table.ID NOT IN (SELECT distinct my_table.ID
                                 FROM my_table
                                 WHERE key = 'process_name'));  
  • 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-31T01:43:00+00:00Added an answer on May 31, 2026 at 1:43 am

    Assuming distinct_id is not nullable, you could use:

    INSERT INTO your_table 
       (SELECT distinct id, 'process_name', id
          FROM your_table
         WHERE distinct_id NOT IN (SELECT distinct_id 
                                     FROM your_table
                                    WHERE key = 'process_name'));
    

    If distinct_id is nullable, use NOT EXISTS instead:

    INSERT INTO your_table 
       (SELECT distinct id, 'process_name', id
          FROM your_table t_out
         WHERE NOT EXISTS (SELECT NULL
                             FROM your_table t_in
                            WHERE t_in.id = t_out.id
                              AND t_in.key = 'process_name'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Excel add-in which I add so many class modules that it is
I have a dynamic form that allow to add many fields dynamically, I Know
I have a tab container, where i can add many tabs with long captions.
I have 3 tables: Book, Section and Content. I want to add many-to-many relation
I have to add certificate to IIS 6.0. But there are many other websites
I have a many-to-many relationship in my django application where I use the add
I have seen in many times in JavaScript code people add a return true
I have an app where I create many uiviews and add them to the
Hello i have tableview with many objects in it. If i want to add
I'm trying to add values from array to DB, have tried many variuos examples

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.