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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:16:41+00:00 2026-06-02T13:16:41+00:00

I am new to oracle so not sure about how to write stored procedure

  • 0

I am new to oracle so not sure about how to write stored procedure in oracle. Currently I am googling and reading some articles/blogs on net on SP’s in oracle. I am begining to get some ideas about it. Even then I have following few queries.

What I am trying to do is,

I have a Employee table with emp_id, Region, Division, Product, Title etc.

I also have emp_update table with emp_id, column (what is changed), old_value, new_value and date.

e.g. emp_update table will have a row for for emp_id = 10, which says region is changed from Asia to UK on 30 April.

Another row for same emp which says product changed from A to B on 30 April.

So, multiple entries for same employee and on same date.

Now on that particular date I am running a cron job which will run this Sp to update employee table to these updates.

e.g. On date 30 April, update employee set region = UK, Product = B where emp_id = 10.

I want to run a single update statement for a employee with all its updates from emp_update table on that date.

So basically,

get all employees from emp_update with update on today.
iterate over that employees updates, assembple them in a single update statement and then execute that update query.
repeat for each employee.

Please help

EDIT 1:-

    CREATE OR REPLACE
PROCEDURE SP_RUN_EMPLOYEE_UPDATES 
IS


 CURSOR 
    c_emp 
 IS
    SELECT DISTINCT(employee_id) as employee_id FROM BI_EMPLOYEE_UPDATE WHERE EFFECTIVE_DATE = to_date('30-Apr-2012','dd-mm-yy');

BEGIN

FOR employee in c_emp

  LOOP

    CURSOR 
        c_emp_update 
    IS
      SELECT * FROM BI_EMPLOYEE_UPDATE WHERE employee_id = :employee.employee_id AND EFFECTIVE_DATE = to_date('30-Apr-2012','dd-mm-yy');

    FOR emp_update in c_emp_update
    LOOP



  --      dbms_output.put_line(emp_update.column_name);
    END LOOP;

  END LOOP;

END;

Currently this is what I have done so far

  • 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-02T13:16:45+00:00Added an answer on June 2, 2026 at 1:16 pm

    This question seems to be less about stored procedures and more about creating dynamic queries. Basically, you want this:

    1. Cron job calls stored procedure
    2. Proc will iterate over the records in emp_update with today’s date, sorted by employee_id
    3. You will start building a dynamic SQL for the set expression of the update statement based off the values from the query. Simply “COLUMN_NAME = NEW_VALUE,” concatenated over and over for each column for that employee_id/date combination.
    4. Build your SQL with the template UPDATE EMP SET <previous string here> WHERE EMPLOYEE_ID = <emp_id>.
    5. Execute dynamic update sql
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm rather new to Oracle PL/SQL, so I'm not sure whether it's possible to
Not sure if this is a Perl or Oracle issue. I'm new to both.
I'm very new to oracle but I've been learning about it in class and
I am new to Oracle PL/SQL and am having some difficulty conceptualizing collections with
I'm quite new to Oracle and seem to having some problems with my query
Not too sure what happened here. I'm using Visual Studio 2010 .NET 4. With
I'm Working with a new Oracle DB, with one table having the following indexes:
I have an Excel file that I need to import into a (new) Oracle
I am new to Oracle. Since we have rewritten an earlier application , we
I'm very new to Oracle and was wondering if there's a way either through

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.