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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:16:00+00:00 2026-06-05T21:16:00+00:00

Looking for best advice on how to do this: I have an insert like

  • 0

Looking for best advice on how to do this:

I have an insert like this:

insert into empty_table (
column_1,
column_2,
column_3,
column_4
)
(select
sequence_1.nextval,
v_variable_1,
v_variable_2,
value_1
from template_table
where some_value = "value 1");

The select statement on its own returns 22 records. What I want to do is iterate over this insert and set the variables equal to values from another query like:

select
variable_1,
variable_2
from table_with_var_values
where some_other_value = "value 2";

This query returns about 180 records and looks like this:

variable_1    variable_2
------------------------
Abc           101         
Def           102         
Ghi           103         
Jkl           104
etc...

So the ultimate result will be that empty_table holds 3,960 records (22 x 180) and will look something like this:

column_1    column_2    column_3    column_4
--------------------------------------------
1           Abc         101         Spring
2           Def         102         Summer
3           Ghi         103         Spring
4           Jkl         104         Fall
etc...

I can store this as function in a package but I am unsure how to begin structuring a function like this. Thanks in advance for any help.

  • 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-05T21:16:01+00:00Added an answer on June 5, 2026 at 9:16 pm

    Why not just combine the two queries and do your INSERT, as in:

    insert into empty_table (column_1,          
                             column_2,          
                             column_3,          
                             column_4)   
      SELECT sequence_1.nextval,  
             t2.variable_1,
             t2.variable_2,
             tt.v_variable_1,  
        from template_table tt,
             table_with_var_values t2
        where tt.some_value = 'value 1' AND
              t2.some_other_value = 'value 2'
    

    Because there’s no join criteria between TEMPLATE_TABLE and TABLE_WITH_VAR_VALUES you should get a Cartesian join, where every row of both tables are joined together, which is what I think you want. No need to loop to get that.

    Not sure which of your template_table columns had the ‘Spring’, ‘Summer’, and ‘Fall’ values so I just picked v_variable_1 – substitute as needed.

    Share and enjoy.

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

Sidebar

Related Questions

Looking for a best-practice advice: Let's suppose I have a Account object with limit
I'm looking for some best practice advice here. I have a library that I'd
I have an slightly unusual security requirement, and I'm looking for advice on best
Looking for advice (perhaps best practice). We have a MS Word document (Office 2007)
I'm just looking for advice with this as I have no idea where to
I'm looking for a best practice advice how to speed up queries and at
Looking for some advice on the best way to implement localization along with client
I'm looking for some advice on the best way to provide a single place
I'm looking for advice on best practice for annual subscription management where the fees
Looking for advice on the best technique for saving complex Python data structures across

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.