I am working on a PL/SQL process. I am having trouble taking queried results from one table and inserting those values into another. Whats complicating things, as far as syntax, is that my columns are aliased or have aliases. i.e. b.empno
The process is as follows
DECLARE
CNT NUMBER;
Select count(*) into CNT
From hwe_inspection_scheduling SCH
Where SCH.id =3
IF CNT = 0 THEN
null; /* Output an Error Message */
ELSIF CNT != 0 THEN
/* We run our query to get the rows and once we have them, we can insert them into a table */
So far so good with the conditional. We have pulled the count to let ourselves know that we can pull data from the table. This data we pull, will go into another table
However, this is where it gets a little tricky. I am in pl/sql and I have this query:
Select xref.inspection_role, xref.sequence, pr.person_id
From hwe_inspection_scheduling SCH
Left Join hwe_inspection_person_xref XREF on SCH.hwe_inspection_scheduling_id = XREF.hwe_inspection_scheduling_id
Left Join persons PR on XREF.person_id = PR.person_id
Where SCH.id = 3
I need to take the rows that are queried from this table and insert them into another table. I know how to insert individual rows but not too sure how to keep looping through to place all the rows that I get into a table. Also, I'm not sure if I'd need to select these fields INTO variables, since I'm using PL/SQL.
Any help on this matter would be greatly appreciated. If any more information is needed or better explaining, let me know. Thanks in advance for your help