title: Stored procedure in Oracle with Case and When
body: <p>I am having a scenario, where I am having 5 different tables:</p>
  
  <pre><code>Table 1 - Product, Columns - ProductId, BatchNummer, Status, GroupId, OrderNummer
  
  Table 2 - ProductGrop, Columns - GropId, ProductType, Description
  
  Table 3 - Electronics, Columns - EId, Description, BatchNummer, OrderNummer, OrderData
  
  Table 4 - Manual, Columns - MId, Description, Status, OrderNummer, ProcessStep
  
  Table 5 - ProcessedProduct, columns same as Product with one extra column of datetime
  </code></pre>
  
  <p>Now, according to business flow, I need to populate all the data from Product table, and have to check if the underlying table (Electronics or Manual, which depends on ProductType column of ProductGoup) has ordernuumer value, then Insert a record in table 5 "ProcessedProduct" else skip the records.</p>
  
  <p>For this requirement, i want to create a procedure. But I am stuck on how to check which underlying table (Electronics/Manual) shall i have to refer and how it can be achieved. </p>
  
  <p>Moreover how should i write the loop for inserting the records. </p>
  
  <p>Note: I cannot change the tables schema. </p>