943,694 Members | Top Members by Rank

Ad:
  • Oracle Discussion Thread
  • Marked Solved
  • Views: 827
  • Oracle RSS
Feb 16th, 2009
0

tranfer of data within tables

Expand Post »
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
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
palavi is offline Offline
58 posts
since Aug 2008
Feb 16th, 2009
0

Re: tranfer of data within tables

here is some pl/sql code that gives you an idea I hope that would help

Oracle Syntax (Toggle Plain Text)
  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;
Reputation Points: 31
Solved Threads: 5
Light Poster
yilmazhuseyin is offline Offline
48 posts
since Oct 2006
Feb 17th, 2009
0

Re: tranfer of data within tables

thank you very much it help me.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
palavi is offline Offline
58 posts
since Aug 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Oracle Forum Timeline: Cloud computing
Next Thread in Oracle Forum Timeline: Update using join





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC