Skip to content
Advertisement

How to update table in pl/sql?

Example contrived for this question. Two tables, Project and Employee. Employee has a project id foreign key. Query needs to

  1. select all the projects that are of year 2021 with ongoing status in Employee table

  2. for each record from above select statement (1),

    • create a new row in project table and set year to 2022.

    • Get project Id (step 3) of this newly created row in project table, and update all the foreign keys in employee table (replacing old with new project id for each corresponding record)

Project Table

Employee table

Advertisement

Answer

I have commented the code make sure u read it, hope this helps.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement