oracle - I want to covert rows from one table to columns to another table using Procedures(Pl/sql) -


table a:  col1 _______________________ jack  1200 20 peter 2000 10 robert  300 30 

to

table b :  name   sal   deptno ----------------------- jack 1200 20 peter 2000 10 robert 300 30 

here want using procedure parameter. can please tried giving errors.

create procedure getdatafromtable_a(v_1 in varchar2) cursor rwdatacursor select raw_data  table_a rowid<=3) t_record rwdatacursor%rowtype; begin open rwdatacursor; loop fetech rwdatacursor t_record; exit when rwdatacursor%notfund; insert temp_process; end loop close rwdatacursor; end; 

this codew have tried showing lot of errors

one way is:

procedure convert_tables   cursor data_cursor     select col1       table_a;    row1 data_cursor%rowtype;   row2 data_cursor%rowtype;   row3 data_cursor%rowtype; begin   open data_cursor;    loop     fetch data_cursor row1;     exit when data_cursor%notfound;      fetch data_cursor row2;     exit when data_cursor%notfound;      fetch data_cursor row3;     exit when data_cursor%notfound;      insert table_b (name, sal, deptno)       values (row1.col1, row2.col1, row3.col1);   end loop;    close data_cursor; end convert_tables; 

share , enjoy.


Comments

Popular posts from this blog

ruby on rails - Permission denied @ sys_fail2 - (D:/RoR/projects/grp/public/uploads/ -

c++ - nodejs socket.io closes connection before upgrading to websocket -

java - What is the equivalent of @Value in CDI world? -