A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Using a Cursor to Retrieve Data From One Table and Insert Into Another table
Joined: Feb 17, 2009
Mar 14, 2013 11:35:56
Using a Cursor to Retrieve Data From One Table and Insert Into Another
i tried the below code but it couldnt helped...
p_delta_sequence NUMBER NOT NULL:= 1233; p_delta_date DATE NOT NULL:= SYSDATE; CURSOR c1 IS select delta1.delta_sequence, delta1.delta_date from cssng_psap_tcs_delta delta1; BEGIN --P_DELTA_SEQUENCE := 2254; --P_DELTA_DATE := SYSDATE; FOR c1_rec IN c1 LOOP p_delta_sequence :=c1_rec.delta_sequence; p_delta_date :=c1_rec.delta_date; DBMS_OUTPUT.PUT_LINE('Delta SEQUENCE' ||' '||p_delta_sequence); DBMS_OUTPUT.PUT_LINE('Delta DATE' ||' '||p_delta_date); Insert into cssng_psap_intrado_delta(delta_sequence, delta_date) values(c1_rec.delta_sequence, c1_rec.delta_date); COMMIT; END LOOP; COMMIT; END;
Joined: Oct 02, 2003
Mar 14, 2013 11:50:12
Nope. We don't hand out answers here. Folk will help YOU write it, but you need to
Show Some Effort
Or, you can always make a post in "Jobs offered" and see if anyone will code it for a fee.
Never ascribe to malice that which can be adequately explained by stupidity.
Joined: Mar 01, 2009
Mar 15, 2013 04:33:55
As Fred says, you should
However, here is a tip: Use "INSERT...SELECT" to perform the SELECT and the INSERT in a single statement e.g.
INSERT INTO cssng_psap_intrado_delta(delta_sequence, delta_date) SELECT col1, col2 FROM some_other_table WHERE etc....
You should be able to figure it out from here.
[Edited my reply after I spotted the fairly obvious fact that you are using Oracle PL/SQL - doh!]
I agree. Here's the link:
subject: Using a Cursor to Retrieve Data From One Table and Insert Into Another table
Closing cursor in a stored procedure when invoked from a callable statement
how to update multiple table in frame
Doubt on cursor position of resultset?
Looking for a good design for performance
multiple inserts with multiple connections into same db table.
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013