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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:11:19+00:00 2026-06-11T04:11:19+00:00

I’d like to update my employee database to set the batch_id to P-1000 if

  • 0

I’d like to update my employee database to set the batch_id to “P-1000” if the employee is a plumber.

Instead of creating 5 separate (and slow) queries, I want to:

  1. set each index of the array is a table name
  2. loop through the array
  3. update the table using the string value at the string index

I can’t find anything even remotely like the concept I’m proposing here, which leads me to think I’m barking up the wrong tree entirely.

None the less, here is the psuedocode owhat I’m trying to do.

declare
  type array_type is table of varchar2(100) index by binary_integer;
  dmt_tables array_type; 
begin
--fill dm_employeeTables array
    dm_employeeTables(0) := 'dm_address';
    dm_employeeTables(1) := 'dm_communications';
    dm_employeeTables(2) := 'dm_identifier';
    dm_employeeTables(3) := 'dm_name';
    dm_employeeTables(4) := 'dm_qualifications';

-- loop through tables
for i in dm_employeeTables.FIRST .. dmt_tables.LAST
   loop
    update dm_employeeTables(i) a 
    set employee_batch_id = 'P-1000'
    where a.employee_type = 'PLUMBER';
    i=i+1;
  end loop;

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-11T04:11:21+00:00Added an answer on June 11, 2026 at 4:11 am

    You would need to use dynamic SQL. Something like

    FOR i IN dm_employeeTables.FIRST .. dmt_tables.LAST
    LOOP
      EXECUTE IMMEDIATE 'UPDATE ' || dm_employeeTables(i) ||
                        '   SET employee_batch_id = :1 ' ||
                        ' WHERE employee_type = :2'
        USING 'P-1000', 'PLUMBER';
    END LOOP;
    

    Now, from a good coding standpoint, you probably want to declare a new local variable (i.e. l_sql_stmt) that you populate with the SQL statement you want to execute and then pass to EXECUTE IMMEDIATE. That allows you to do things like log the SQL statement (or print it out) before you execute the SQL statement. That generally makes debugging much easier.

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

Sidebar

Related Questions

Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words
I am trying to render a haml file in a javascript response like so:
I'm interested in microtypography issues on the web. I want a tool to fix:
I have a French site that I want to parse, but am running into

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.