Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Copy Columns from one Table to Another with PL/SQL in Apex

switbeckJul 10 2013 — edited Jul 11 2013

So my long term goal is to throw this PL/SQL statement into a DMBS_SCHEDULER proces in Apex 4.1 in order to create historical snapshots of the data by week but I am hung up on this code:

declare
V_DEKIT_ID varchar(255);
V_NT varchar(255);
V_QUANTITY number;
V_DDATE date;

begin
for DEKIT_ID in (select * from DKT_HIST)

loop

select DEKIT.DEKIT_ID into V_DEKIT_ID from DEKIT;
select DEKIT.NT into V_NT from DEKIT;
select DEKIT.QUANTITY into V_QUANTITY from DEKIT;
select CURRENT_DATE into V_DDATE from dual;

insert into DKT_HIST (DEKIT_ID,NT,QUANTITY,DDATE)
values (V_DEKIT_ID, V_NT, V_QUANTITY, V_DDATE);
end loop;

end;

I enter this code into the SQL Command prompt under the SQL workshop and it says that it is processed but when I go and look at the destination table (DKT_HIST), there is no data. Any help would be appreciated.  In this code I want to copy the three columns from the table DEKIT as well as the current date and copy them to DKT_HIST for each row in the DEKIT table.

Thanks,

-Steve

This post has been answered by Sven W. on Jul 11 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 8 2013
Added on Jul 10 2013
5 comments
1,195 views