tranfer of data within tables

Thread Solved

Join Date: Aug 2008
Posts: 53
Reputation: palavi is an unknown quantity at this point 
Solved Threads: 0
palavi's Avatar
palavi palavi is offline Offline
Junior Poster in Training

tranfer of data within tables

 
0
  #1
Feb 16th, 2009
i ve 1 table named 'A',it contains many attributes in 1 attribute the values are stored like this "Q108:5380;Q208:5380" this data present in table 'A' should be entered in table named 'B' in two fields named B1,B2 as
B1 B2
Q108 5380
Q208 5380

like this in two columns this data should be entered in table named 'B' from table 'A'. here : means separates two columns and ; means separates two rows.
please help me or tell me how to write this in code. i am using oracle database. thank you
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 48
Reputation: yilmazhuseyin is an unknown quantity at this point 
Solved Threads: 5
yilmazhuseyin's Avatar
yilmazhuseyin yilmazhuseyin is offline Offline
Light Poster

Re: tranfer of data within tables

 
0
  #2
Feb 16th, 2009
here is some pl/sql code that gives you an idea I hope that would help

  1. DECLARE
  2. a1 VARCHAR2(255);
  3. b1 VARCHAR2(255);
  4. a2 VARCHAR2(255);
  5. b2 VARCHAR2(255);
  6. qry VARCHAR2(4000);
  7. CURSOR cr_a IS (SELECT * FROM a);
  8. BEGIN
  9. --loop goes to every row in a
  10. FOR rc_a IN cr_a
  11. LOOP
  12. --seperates column of A table to for variable
  13. --you have to write it it is simple string operations
  14. seperatecolumn(rc_a.COLUMN , a1,a2,b1,b2);
  15. qry := 'insert into b (B1,B2) values (' || a1 || ',' || a2 || ')';
  16. --run query
  17. EXECUTE IMMEDIATE qry;
  18. qry := 'insert into b (B1,B2) values (' || b1 || ',' || b2 || ')';
  19. EXECUTE IMMEDIATE qry;
  20. END LOOP;
  21. END;
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 53
Reputation: palavi is an unknown quantity at this point 
Solved Threads: 0
palavi's Avatar
palavi palavi is offline Offline
Junior Poster in Training

Re: tranfer of data within tables

 
0
  #3
Feb 17th, 2009
thank you very much it help me.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the Oracle Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC