Copy data from one table to another
Hello everyone,
I have a student table with fields sno, sname. I created another table student1 with same fields sno, sname and with one new field class.
Now i want to copy data from sno, sname of student table to sno, sname of student1 table when the class field in styudent1 has no data i.e., its null.
Could any one let me know how to do this?
Thanks,
Prathima
i want to copy data from sno, sname of student table to sno, sname
of student1 table when the class field in styudent1 has no dataSo what is the join condition? What column in STUDENT1 tells us what row in STUDENT to copy?
Cheers, APC
Blog : http://radiofreetooting.blogspot.com/
Similar Messages
-
T code to Copy Data from one table to another table
Hi,
I want copy all data of one table to its copy table. Anyone knows transaction code to copy data from one table to another table.
Regards,
Jigar Thakkar.Hi
Create a small program.
Extract data from T1 - database table and put it in one internal table - itab1.
loop the itab1 data .............
insert itab1 into tab2. (tab2 - second database table)
endloop.
try this....
hope it works.... -
How to copy data from one table to another (in other database)
Hi. I would like to copy all rows from one table to another (and not use BC4J). Tables can be in various databases. I have already 2 connections and I am able to browse source table using
ResultSet rset = stmt.executeQuery("select ...");
But I would not like to create special insert statement for every row . There will be problems with date formats etc and it will be slow. Can I use retrieved ResultSet somehow ? Maybe with method insertRow, but how, if ResultSet is based on select statement and want to insert into target table? Please point me in the right direction. Thanks.No tools please, it must be common solution. We suceeded in converting our BC4J aplication to PostgreSQL, the MSSQL will be next. So we want to write simple aplication, which could transfer data from our tables between these 3 servers.
-
Copy data from one Table to another Table
How can I copy data from one Oracle Table to another Oracle Table on a different server? Question 2: How can I clear all of the data in one Table with a single SQL script?
Thanks...Question 1:
I assume you have the privileges. If you don't, ask the DBA to give them to you. Then
1. Login to database_source (It could be either the source or the target. Let's assume it's the source.)
2. Create a database link to database_target: CREATE DATABASE LINK link_to_database_target CONNECT TO myuserid IDENTIFIED BY mypassword USING 'database_target'; Note the single quotes.
3. Copy the table data: INSERT INTO targetowner.mytable@link_to_database_target SELECT * FROM sourceowner.mytable; COMMIT;
Question 2:
You have two options, but you may not have privileges for both.
Option 1:
DELETE FROM tableowner.tablename; COMMIT;
Advantage: Since this is a DML (Data Manipulation Language) statement, you have to commit the transaction. Also, the data will be gone but the table size is NOT changed, so it's ready for accepting replacement data. DML statements can simply be executed not only from SQL scripts, but from PL/SQL scripts as well.
Disadvantage: Slow, because all record deletion is logged, so you can recover from it by issuing a ROLLBACK; instead of the COMMIT; above. The table size is NOT changed, so if you are short of disk space or tablespace space, you have not resolved the issue.
Option 2:
TRUNCATE TABLE tableowner.tablename;
Advantage: Since this is a DDL (Data Definition Language) command, you do NOT have to commit the transaction. (DDL commands automatically commit both before and after their execution.) The table size will be changed back to the initial extent size which is the minimum size a table can have and can only be set when the table is created. If it needs to be changed, the table has to be dropped and recreated with a different initial extent size. The statement execution of this command is not logged, therefore it's much faster then the DELETE.
Disadvantage: No rollback. Being a DDL, this command cannot be executed straight from PL/SQL. If you need to issue this within PL/SQL, you will have to use dynamic SQL. -
Copying data from one table to another table thru java
Hi
I have to copy data from table emp in Database A to table emp in Database B. My input would be table name and number of rows to be fetched. these rows i need to insert in table B.
The problem over here is I won't be having any info. of table emp i.e the number of columns it has and their type.
So is their any way i can copy the data from one table to other without having the info abt the number of cols and their type.
TIACross post - http://forum.java.sun.com/thread.jspa?threadID=5169293&messageID=9649839#9649839
-
Copying data from one table to another, but not duplicate
Good afternoon!
I am new to Oracle SQL, I have a difficulty.
I have a script that copies or add another table with data from another table.
If the table already has 01 "Registry 01" when you make a copy of the data in table 02, can not duplicate the "Registry 01" again.
As the table already exists since the beginning of the year before last and duplicate information, I can not apply the UNIQUE constraint because of the error. I have to make this change from now.
How to perform this validation so that no duplicate data?
DECLARE
w_cont NUMBER;
CURSOR c_simpro IS
SELECT sc.cd_simpro,
sc.ds_produto,
sp.qt_embalagem,
MAX(sp.dt_vigencia)
FROM simpro_cadastro sc,
simpro_preco sp
WHERE sc.cd_simpro = sp.cd_simpro
GROUP BY sc.cd_simpro,
sc.ds_produto,
sp.qt_embalagem;
BEGIN
FOR r_simpro IN c_simpro LOOP
w_cont := 0;
SELECT COUNT(1)
INTO w_cont
FROM pls_material pm
WHERE pm.cd_material_ops = r_simpro.cd_simpro;
IF w_cont = 0 THEN
INSERT INTO pls_material(nr_sequencia,
dt_atualizacao,
nm_usuario,
dt_atualizacao_nrec,
nm_usuario_nrec,
ie_tipo_despesa,
cd_estabelecimento,
nr_seq_estrut_mat,
cd_simpro,
ds_material,
ie_situacao,
ds_material_sem_acento,
dt_inclusao,
cd_material_ops_orig,
cd_unidade_medida,
cd_material_ops,
qt_conversao_simpro)
VALUES(pls_material_seq.nextval,
SYSDATE,
'ES-SIMPRO',
SYSDATE,
'ES-SIMPRO',
3,
1,
3,
r_simpro.cd_simpro,
r_simpro.ds_PRODUTO,
'A',
r_simpro.ds_PRODUTO,
SYSDATE,
r_simpro.cd_simpro,
'un',
TRIM(to_char(r_simpro.cd_simpro,'0000099999')),
r_simpro.qt_embalagem);
COMMIT;
END IF;
IF w_cont > 0 THEN
UPDATE pls_material p
SET p.qt_conversao_simpro = r_simpro.qt_embalagem,
p.dt_atualizacao = SYSDATE
WHERE p.cd_simpro = r_simpro.cd_simpro;
COMMIT;
END IF;
END LOOP;
END;
Edited by: 983464 on 22/01/2013 10:30Hi,
in addition to what Marwin has already said, I suggest you to post CREATE TABLE and INSERT statements (as mentioned in the FAQ).
The error you are getting from MERGE command is because you need a way to uniquely identify within the table. So it's is important to know also if your table has a primary key/unique index so the keys could to be used in the MERGE command.
Additionally when you put some code or output please enclose it between two lines starting with {noformat}{noformat}
i.e.:
{noformat}{noformat}
SELECT ...
{noformat}{noformat}
Regards.
Al -
Copying data from one table to another
Hello!
I have a table (TABLE1) and I want to copy part of TABLE1's data to an another table (TABLE2).This proccess is made by an application in PROC Language with ORACLE 8.1 in UNIX environment.
1) I've tried to make the copy with a cursor:
void search() {
char alias[ALIASTAM];
struct tpNoticia noticia;
printf("Introduzca el nombre del autor: ");
scanf("%s",alias);
EXEC SQL DECLARE AUX CURSOR FOR
SELECT idNoticia,titulo,texto,TO_CHAR(publicacion,'HH24:MI:SS DD-MM-YYYY'),
URLimagen,numVisitas,sumaVal,totalVal,esBorrador,alias,nombreT
FROM TABLE1
WHERE alias=:alias;
EXEC SQL OPEN AUX;
EXEC SQL WHENEVER NOT FOUND DO break;
for (;;) {
EXEC SQL FETCH AUX INTO :noticia;
printf("%d %s \n", noticia.idNoticia,noticia.titulo);
EXEC SQL INSERT INTO TABLE2 (idNoticia,titulo,texto,publicacion,URLimagen,numVisitas,sumaVal,totalVal,esBorrador,alias,nombreT)
VALUES (:(noticia.idNoticia),:(noticia.titulo),:(noticia.texto), TO_DATE('00:00:00 01-01-1900','HH24:MI:SS DD-MM-YYYY'),:(noticia.URLimagen),:(noticia.numVisitas),
:(noticia.sumaVal),:(noticia.totalVal),:(noticia.esBorrador),:(noticia.alias),:(noticia.nombreT));
EXEC SQL CLOSE AUX;
IN THIS CURSOR printf SHOWS CORRECTLY THE DATA BUT IT ISN'T INSERTED INTO TABLE 2;
2) I've tried to define TABLE2 from TABLE1:
EXEC SQL CREATE TABLE TABLE2 AS
SELECT * FROM TABLE1 WHERE alias=:alias
BUT MY COMPILER SAYS: PCC-S-02206, Host variables are not permitted within a DDL statement
ANY IDEA???
ThanksIf you want to create the table dynamically, then you have to use dynamic Sql. Didn't you like my above suggestion ? If you want I can post a small example of a similar stored procedure.
See also http://www.mcs.csuhayward.edu/support/oracle/doc/8.1.7/appdev.817/a76942/pc_07pls.htm#2778 -
Adding Data From One Table to Another
Now, this doesn't strike me as a particularly complex problem, but I've either strayed outside the domain of Numbers or I'm just not looking at the problem from the right angle. In any case, I'm sure you guys can offer some insight.
What I'm trying to do is, essentially, move data from one table to another. One table is a calendar, a simple two column 'date/task to be completed' affair, the other is a schedule of jogging workouts, i.e, times, distances. Basically, I'm trying to create a formula that copies data from the second table onto the first but only for odd days of the week, excepting Sundays (and assuming Monday as the start of the week). Now, this isn't the hard part, I can do that. The problem comes when I replicate the formula down the calendar. Even on the days when the 'if' statement identifies it as an 'even day', the cell reference to the appropriate workout on the second table is incremented, so when it comes to the next 'odd day', it has skipped a workout.
I can't seem to see any way of getting it to specifically copy the NEXT line in the second table, and not the corresponding line.
This began as a distraction to try and organise my running so I could see at a glance what I had to do that day and track my progress, but now it's turned into an obsession. SURELY there's a solution?
Cheers.Hi Sealatron,
Welcome to Apple Discussions and the Numbers '09 forum.
Several possible ways to move the data occur to me, but the devil's in the details of how the data is currently arranged.
Is it
• a list of three workouts, one for each of Monday, Wednesday and Friday, then the same three repeated the following week?
• an open-ended list that does not repeat?
• something else?
Regards,
Barry -
Move data from one table to another table
Hi all,
I had a custom table called sales_data in that table there are columns like JAn,FEB,upto DEC including other columns so in each month there is some data total data is 23000 count but each month has has specific data like JAn-2500,FEB-2000 like that it has total 23000 records
My Requirement is i have to move data from one table to another table that too if i will pass jan only jan data should move like that feb,march,.....
in my table there is no month column i had get it from another table called gl_periods and by using cursor and case function i have written the code
well while when i am inserting data am passing year,month as parameters but 23000 data is moving it should get like that.
Please suggest me.its urgent
Thank YouHi hamid,
Please go through the below procedure.
CREATE OR REPLACE PROCEDURE APPS.copy_sales_to_forecast(p_fiscal_year varchar2,p_month number)
IS
CURSOR C1 IS select period_year,period_num,start_date,end_date from apps.gl_periods
where period_set_name='Accounting'
and period_year=p_fiscal_year
and period_num<=p_month;
type type1 is table of xxc_forecast_data%rowtype;
t1 type1;
BEGIN
FOR CREC IN C1 LOOP
BEGIN
DELETE FROM xxc_forecast2
where fiscal_year = crec.period_year
and attribute1='Copied From Sales to Forecast Table of Month '||crec.period_num;
END;
SELECT
product_category ,
product_sub_category ,
product_line ,
product_style ,
item_number ,
item_description ,
customer_name ,
customer_number ,
sales_channel ,
null ,
CASE
WHEN crec.period_num=1 THEN sales_amount_month1
ELSE 0
END Transaction_quantity_period1,
CASE
WHEN crec.period_num=1 THEN sales_cost_month1
ELSE 0
END item_cogs_period1,
CASE
WHEN crec.period_num=1 THEN sales_mtl_cost_month1
ELSE 0
END item_material_cogs_period1 ,
CASE
WHEN crec.period_num=1 THEN sales_mtl_ovhd_cost_month1
ELSE 0
END item_mtl_ovhd_cogs_period1,
CASE
WHEN crec.period_num=1 THEN sales_res_cost_month1
ELSE 0
END item_resource_cogs_period1,
CASE
WHEN crec.period_num=1 THEN sales_op_cost_month1
ELSE 0
END item_op_cogs_period1,
CASE
WHEN crec.period_num=1 THEN sales_ovhd_month1
ELSE 0
END item_ovhd_cogs_period1,
CASE
WHEN crec.period_num=1 THEN sales_units_month1
ELSE 0
END extended_amount_us_period1,
CASE
WHEN crec.period_num=2 THEN sales_amount_month2
ELSE 0
END Transaction_quantity_period2,
CASE
WHEN crec.period_num=2 THEN sales_mtl_cost_month2
ELSE 0
END item_material_cogs_period2,
CASE
WHEN crec.period_num=2 THEN sales_mtl_ovhd_cost_month2
ELSE 0
END item_mtl_ovhd_cogs_period2,
CASE
WHEN crec.period_num=2 THEN sales_res_cost_month2
ELSE 0
END item_resource_cogs_period2,
CASE
WHEN crec.period_num=2 THEN sales_op_cost_month2
ELSE 0
END item_op_cogs_period2,
CASE
WHEN crec.period_num=2 THEN sales_ovhd_month2
ELSE 0
END item_ovhd_cogs_period2,
CASE
WHEN crec.period_num=2 THEN sales_units_month2
ELSE 0
END extended_amount_us_period2,
CASE
WHEN crec.period_num=3 THEN sales_amount_month3
ELSE 0
END Transaction_quantity_period3,
CASE
WHEN crec.period_num=3 THEN sales_mtl_cost_month3
ELSE 0
END item_material_cogs_period3,
CASE
WHEN crec.period_num=3 THEN sales_mtl_ovhd_cost_month3
ELSE 0
END item_mtl_ovhd_cogs_period3,
CASE
WHEN crec.period_num=3 THEN sales_res_cost_month3
ELSE 0
END item_resource_cogs_period3,
CASE
WHEN crec.period_num=3 THEN sales_op_cost_month3
ELSE 0
END item_op_cogs_period3,
CASE
WHEN crec.period_num=3 THEN sales_ovhd_month3
ELSE 0
END item_ovhd_cogs_period3,
CASE
WHEN crec.period_num=3 THEN sales_units_month3
ELSE 0
END extended_amount_us_period3,
CASE
WHEN crec.period_num=4 THEN sales_amount_month4
ELSE 0
END Transaction_quantity_period4,
CASE
WHEN crec.period_num=4 THEN sales_mtl_cost_month4
ELSE 0
END item_material_cogs_period4,
CASE
WHEN crec.period_num=4 THEN sales_mtl_ovhd_cost_month4
ELSE 0
END item_mtl_ovhd_cogs_period4,
CASE
WHEN crec.period_num=4 THEN sales_res_cost_month4
ELSE 0
END item_resource_cogs_period4,
CASE
WHEN crec.period_num=4 THEN sales_op_cost_month4
ELSE 0
END item_op_cogs_period4,
CASE
WHEN crec.period_num=4 THEN sales_ovhd_month4
ELSE 0
END item_ovhd_cogs_period4,
CASE
WHEN crec.period_num=4 THEN sales_units_month4
ELSE 0
END extended_amount_us_period4,
CASE
WHEN crec.period_num=5 THEN sales_amount_month5
ELSE 0
END Transaction_quantity_period5,
CASE
WHEN crec.period_num=5 THEN sales_mtl_cost_month5
ELSE 0
END item_material_cogs_period5,
CASE
WHEN crec.period_num=5 THEN sales_mtl_ovhd_cost_month5
ELSE 0
END item_mtl_ovhd_cogs_period5,
CASE
WHEN crec.period_num=5 THEN sales_res_cost_month5
ELSE 0
END item_resource_cogs_period5,
CASE
WHEN crec.period_num=5 THEN sales_op_cost_month5
ELSE 0
END item_op_cogs_period5,
CASE
WHEN crec.period_num=5 THEN sales_ovhd_month5
ELSE 0
END item_ovhd_cogs_period5,
CASE
WHEN crec.period_num=5 THEN sales_units_month5
ELSE 0
END extended_amount_us_period5,
CASE
WHEN crec.period_num=6 THEN sales_amount_month6
ELSE 0
END Transaction_quantity_period6,
CASE
WHEN crec.period_num=6 THEN sales_mtl_cost_month6
ELSE 0
END item_material_cogs_period6,
CASE
WHEN crec.period_num=6 THEN sales_mtl_ovhd_cost_month6
ELSE 0
END item_mtl_ovhd_cogs_period6,
CASE
WHEN crec.period_num=6 THEN sales_res_cost_month6
ELSE 0
END item_resource_cogs_period6,
CASE
WHEN crec.period_num=6 THEN sales_op_cost_month6
ELSE 0
END item_op_cogs_period6,
CASE
WHEN crec.period_num=6 THEN sales_ovhd_month6
ELSE 0
END item_ovhd_cogs_period6,
CASE
WHEN crec.period_num=6 THEN sales_units_month6
ELSE 0
END extended_amount_us_period6,
CASE
WHEN crec.period_num=7 THEN sales_amount_month7
ELSE 0
END Transaction_quantity_period7,
CASE
WHEN crec.period_num=7 THEN sales_mtl_cost_month7
ELSE 0
END item_material_cogs_period7,
CASE
WHEN crec.period_num=7 THEN sales_mtl_ovhd_cost_month7
ELSE 0
END item_mtl_ovhd_cogs_period7,
CASE
WHEN crec.period_num=7 THEN sales_res_cost_month7
ELSE 0
END item_resource_cogs_period7,
CASE
WHEN crec.period_num=7 THEN sales_op_cost_month7
ELSE 0
END item_op_cogs_period7,
CASE
WHEN crec.period_num=7 THEN sales_ovhd_month7
ELSE 0
END item_ovhd_cogs_period7,
CASE
WHEN crec.period_num=7 THEN sales_units_month7
ELSE 0
END extended_amount_us_period7,
CASE
WHEN crec.period_num=8 THEN sales_amount_month8
ELSE 0
END Transaction_quantity_period8,
CASE
WHEN crec.period_num=8 THEN sales_mtl_cost_month8
ELSE 0
END item_material_cogs_period8,
CASE
WHEN crec.period_num=8 THEN sales_mtl_ovhd_cost_month8
ELSE 0
END item_mtl_ovhd_cogs_period8,
CASE
WHEN crec.period_num=8 THEN sales_res_cost_month8
ELSE 0
END item_resource_cogs_period7,
CASE
WHEN crec.period_num=8 THEN sales_op_cost_month8
ELSE 0
END item_op_cogs_period8,
CASE
WHEN crec.period_num=8 THEN sales_ovhd_month8
ELSE 0
END item_ovhd_cogs_period8,
CASE
WHEN crec.period_num=8 THEN sales_units_month8
ELSE 0
END extended_amount_us_period8,
CASE
WHEN crec.period_num=9 THEN sales_amount_month9
ELSE 0
END Transaction_quantity_period9,
CASE
WHEN crec.period_num=9 THEN sales_mtl_cost_month9
ELSE 0
END item_material_cogs_period9,
CASE
WHEN crec.period_num=9 THEN sales_mtl_ovhd_cost_month9
ELSE 0
END item_mtl_ovhd_cogs_period9,
CASE
WHEN crec.period_num=9 THEN sales_res_cost_month9
ELSE 0
END item_resource_cogs_period7,
CASE
WHEN crec.period_num=9 THEN sales_op_cost_month9
ELSE 0
END item_op_cogs_period9,
CASE
WHEN crec.period_num=9 THEN sales_ovhd_month9
ELSE 0
END item_ovhd_cogs_period9,
CASE
WHEN crec.period_num=9 THEN sales_units_month9
ELSE 0
END extended_amount_us_period9,
CASE
WHEN crec.period_num=10 THEN sales_amount_month10
ELSE 0
END Transaction_quantity_period10,
CASE
WHEN crec.period_num=10 THEN sales_mtl_cost_month10
ELSE 0
END item_material_cogs_period10,
CASE
WHEN crec.period_num=10 THEN sales_mtl_ovhd_cost_month10
ELSE 0
END item_mtl_ovhd_cogs_period10,
CASE
WHEN crec.period_num=10 THEN sales_res_cost_month10
ELSE 0
END item_resource_cogs_period10,
CASE
WHEN crec.period_num=10 THEN sales_op_cost_month10
ELSE 0
END item_op_cogs_period10,
CASE
WHEN crec.period_num=10 THEN sales_ovhd_month10
ELSE 0
END item_ovhd_cogs_period10,
CASE
WHEN crec.period_num=10 THEN sales_units_month10
ELSE 0
END extended_amount_us_period10,
CASE
WHEN crec.period_num=11 THEN sales_amount_month11
ELSE 0
END Transaction_quantity_period11,
CASE
WHEN crec.period_num=11 THEN sales_mtl_cost_month11
ELSE 0
END item_material_cogs_period11,
CASE
WHEN crec.period_num=11 THEN sales_mtl_ovhd_cost_month11
ELSE 0
END item_mtl_ovhd_cogs_period11,
CASE
WHEN crec.period_num=11 THEN sales_res_cost_month11
ELSE 0
END item_resource_cogs_period11,
CASE
WHEN crec.period_num=11 THEN sales_op_cost_month11
ELSE 0
END item_op_cogs_period11,
CASE
WHEN crec.period_num=11 THEN sales_ovhd_month11
ELSE 0
END item_ovhd_cogs_period11,
CASE
WHEN crec.period_num=11 THEN sales_units_month11
ELSE 0
END extended_amount_us_period11,
CASE
WHEN crec.period_num=12 THEN sales_amount_month12
ELSE 0
END Transaction_quantity_period12,
CASE
WHEN crec.period_num=12 THEN sales_mtl_cost_month12
ELSE 0
END item_material_cogs_period12,
CASE
WHEN crec.period_num=12 THEN sales_mtl_ovhd_cost_month12
ELSE 0
END item_mtl_ovhd_cogs_period12,
CASE
WHEN crec.period_num=12 THEN sales_res_cost_month12
ELSE 0
END item_resource_cogs_period12,
CASE
WHEN crec.period_num=12 THEN sales_op_cost_month12
ELSE 0
END item_op_cogs_period12,
CASE
WHEN crec.period_num=12 THEN sales_ovhd_month12
ELSE 0
END item_ovhd_cogs_period12,
CASE
WHEN crec.period_num=12 THEN sales_units_month12
ELSE 0
END extended_amount_us_period12,
CASE
WHEN crec.period_num=2 THEN sales_cost_month2
ELSE 0
END item_cogs_period2,
CASE
WHEN crec.period_num=3 THEN sales_cost_month3
ELSE 0
END item_cogs_period3,
CASE
WHEN crec.period_num=4 THEN sales_cost_month4
ELSE 0
END item_cogs_period4,
CASE
WHEN crec.period_num=5 THEN sales_cost_month5
ELSE 0
END item_cogs_period5,
CASE
WHEN crec.period_num=6 THEN sales_cost_month6
ELSE 0
END item_cogs_period6,
CASE
WHEN crec.period_num=7 THEN sales_cost_month7
ELSE 0
END item_cogs_period7,
CASE
WHEN crec.period_num=8 THEN sales_cost_month8
ELSE 0
END item_cogs_period8,
CASE
WHEN crec.period_num=9 THEN sales_cost_month9
ELSE 0
END item_cogs_period9,
CASE
WHEN crec.period_num=10 THEN sales_cost_month10
ELSE 0
END item_cogs_period10,
CASE
WHEN crec.period_num=11 THEN sales_cost_month11
ELSE 0
END item_cogs_period11,
CASE
WHEN crec.period_num=12 THEN sales_cost_month12
ELSE 0
END item_cogs_period12,
a.fiscal_year ,
a.budget_entity ,
a.organization_code,
a.customer_id ,
a.inventory_item_id ,
NULL,
NULL,
a.created_by ,
a.last_updated_by ,
a.creation_date ,
a.last_update_date ,
'Copied From Sales to Forecast Table of Month '||crec.period_num,
a.attribute2,
a.attribute3 ,
a.attribute4 ,
a.attribute5 ,
a.attribute6 ,
a.attribute7 ,
a.attribute8 ,
a.attribute9 ,
a.attribute10,
a.attribute11,
a.attribute12,
a.attribute13,
a.attribute14,
a.attribute15
bulk collect into t1
FROM xxc_sales_data a
where a.fiscal_year = crec.period_year
having CASE
WHEN crec.period_num=1 THEN sum(sales_amount_month1)
WHEN crec.period_num=2 THEN sum(sales_amount_month2)
WHEN crec.period_num=3 THEN sum(sales_amount_month3)
WHEN crec.period_num=4 THEN sum(sales_amount_month4)
WHEN crec.period_num=5 THEN sum(sales_amount_month5)
WHEN crec.period_num=6 THEN sum(sales_amount_month6)
WHEN crec.period_num=7 THEN sum(sales_amount_month7)
WHEN crec.period_num=8 THEN sum(sales_amount_month8)
WHEN crec.period_num=9 THEN sum(sales_amount_month9)
WHEN crec.period_num=10 THEN sum(sales_amount_month10)
WHEN crec.period_num=11 THEN sum(sales_amount_month11)
WHEN crec.period_num=12 THEN sum(sales_amount_month12)
END !=0;
FORALL i IN t1.first .. t1.last
INSERT INTO xxc_forecast2 VALUES t1(i);
--commit;
END LOOP;
END;
Thank You -
What are the diffrent ways to copy data from one application to another?
Hi,
Can you guys tell me what are the different ways to copy data from one application to another application??
I know we can do it through script logic using DESTINATION_APP.
Is there any other way to copy data from one application to another application?
Please help me
Thanks,
CharlyYou can also call a custom DTSX package in SSIS via the datamanager.
there are at least 5 ways of transfering data in BPC between apps.
1. Through the front end (excel etc) via evdre/evsnds
2. Through Script logic using *Dest App
3. Using BPC's standard export dtsx package via DM
4. Using SSIS using BPC's custom SSIS tasks
5. Through Script logic using stored procs.
i am sure people will come up with more.
remember if you use ssis and move data into any table but the wb, you need to process the cube afterwards. -
Moving time-dependant data from one table to another (archiving)
Hello all
I would like to know if there's an easier solution or a "best practice" to move data from one table to another. The context of this issue can be found within "archiving".
More concretely: we have an application that uses several tables to log information to.
These tables are growing like crazy, and we would like to keep only "relevant" data in those tables, so I was thinking about moving data from these tables that have been in there for, say 2 months, to "archiving" tables.
I figured there must be some kind of "best practice" to get this done.
I have already written a procedure that loops the table that has the time indicator and inserts the records from the normal tables into the archive tables (and afterwards delete this data), but it seems to be taking ages to get it done.
Thanks in advance!
Message was edited by:
timschraepenThere is nothing to do with PL/SQL.
You can refer below links:
http://www.lc.leidenuniv.nl/awcourse/oracle/server.920/a96524/c12parti.htm
http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10739/partiti.htm#i1006727 -
Insert old missing data from one table to another(databaase trigger)
Hello,
i want to do two things
1)I want to insert old missing data from one table to another through a database trigger but it can't be executed that way i don't know what should i do in case of replacing old data in table_1 into table_2
2)what should i use :NEW. OR :OLD. instead.
3) what should i do if i have records exising between the two dates
i want to surpress the existing records.
the following code is what i have but no effect occured.
CREATE OR REPLACE TRIGGER ATTENDANCEE_FOLLOWS
AFTER INSERT ON ACCESSLOG
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
V_COUNT NUMBER(2);
V_TIME_OUT DATE;
V_DATE_IN DATE;
V_DATE_OUT DATE;
V_TIME_IN DATE;
V_ATT_FLAG VARCHAR2(3);
V_EMP_ID NUMBER(11);
CURSOR EMP_FOLLOWS IS
SELECT EMPLOYEEID , LOGDATE , LOGTIME , INOUT
FROM ACCESSLOG
WHERE LOGDATE
BETWEEN TO_DATE('18/12/2008','dd/mm/rrrr')
AND TO_DATE('19/12/2008','dd/mm/rrrr');
BEGIN
FOR EMP IN EMP_FOLLOWS LOOP
SELECT COUNT(*)
INTO V_COUNT
FROM EMP_ATTENDANCEE
WHERE EMP_ID = EMP.EMPLOYEEID
AND DATE_IN = EMP.LOGDATE
AND ATT_FLAG = 'I';
IF V_COUNT = 0 THEN
INSERT INTO EMP_ATTENDANCEE (EMP_ID, DATE_IN ,DATE_OUT
,TIME_IN ,TIME_OUT,ATT_FLAG)
VALUES (TO_NUMBER(TO_CHAR(:NEW.employeeid,99999)),
TO_DATE(:NEW.LOGDATE,'dd/mm/rrrr'), -- DATE_IN
NULL,
TO_DATE(:NEW.LOGTIME,'HH24:MI:SS'), -- TIME_IN
NULL ,'I');
ELSIF V_COUNT > 0 THEN
UPDATE EMP_ATTENDANCEE
SET DATE_OUT = TO_DATE(:NEW.LOGDATE,'dd/mm/rrrr'), -- DATE_OUT,
TIME_OUT = TO_DATE(:NEW.LOGTIME,'HH24:MI:SS'), -- TIME_OUT
ATT_FLAG = 'O'
WHERE EMP_ID = TO_NUMBER(TO_CHAR(:NEW.employeeid,99999))
AND DATE_IN <= (SELECT MAX (DATE_IN )
FROM EMP_ATTENDANCEE
WHERE EMP_ID = TO_NUMBER(TO_CHAR(:NEW.employeeid,99999))
AND DATE_OUT IS NULL
AND TIME_OUT IS NULL )
AND DATE_OUT IS NULL
AND TIME_OUT IS NULL ;
END IF;
END LOOP;
EXCEPTION
WHEN OTHERS THEN RAISE;
END ATTENDANCEE_FOLLOWS ;
Regards,
Abdetu..INSERT INTO SALES_MASTER
( NO
, Name
, PINCODE )
SELECT SALESMANNO
, SALESMANNAME
, PINCODE
FROM SALESMAN_MASTER;Regards,
Christian Balz -
Moving Data from one table to another table
Hi,
I've a requirement to move large volumes (few billions) of data from one table to another empty target table. The target has more number of attributes and may not have same attribute name as the source. Please let me know what's the best method using oracle to move data in this case?
Thanks in Advance,
TomYou should use nologging and parallelism options
Please refer to Tom's answers:
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:164612348068
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:6407993912330
Kamran Agayev A. (10g OCP)
http://kamranagayev.wordpress.com
[Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/] -
Append data from one table to another.
Hi,
I want to insert/append some or all the data from one table to another table.
For eg: Data from table table1 to be appended to table2 with the same constraints, indexes etc. The columns are same for both the tables.
I am using 10g version 2.
Please specify which method would be good for this process.
Thanks
JafarINSERT INTO TABLE1 SELECT * FROM TABLE2;The above command would insert data into table2 and it also contain the old data.Is that right,
Thanks
Jafar -
Trigger to copy records from one table to another; ORA-04091:
Hello,
I'm trying to create a trigger that will move data from one table to another.
I have two tables (Trial1, Trial2) Both of them contains the same attributes (code, c_index)
I want to move each new record inserted in (code in Trial1) to (code in Trial2)
This is my trigger:
Create or replace trigger trg_move_to_trial2
After insert on Trial1
for each row
begin
insert into Trial2 (code)
select :new.code from Trial1;
end;It compiled, but when I insert new (code) record into (Trial1) it display this error:
Error report:
SQL Error: ORA-04091: table STU101.TRIAL1 is mutating, trigger/function may not see it
ORA-06512: at "STU101.TRG_MOVE_TO_TRIAL2", line 3
ORA-04088: error during execution of trigger 'STU101.TRG_MOVE_TO_TRIAL2'
04091. 00000 - "table %s.%s is mutating, trigger/function may not see it"
*Cause: A trigger (or a user defined plsql function that is referenced in
this statement) attempted to look at (or modify) a table that was
in the middle of being modified by the statement which fired it.
*Action: Rewrite the trigger (or function) so it does not read that table.I know what does this error mean, but I don't how to fix the error.
I tried to change the (After insert on Trial1) to be (Before insert on Trial1); that worked, but not in the right way. When I insert new value into (code in Trial1) and refreshed Trial2 table, as much as records I have in Trial 2 they will be duplicated. E.g.
Trial2
code
111
222
333when I insert in Trial1
Trial1
code
444
Trial2 will be:
code
111
222
333
444
444
444Can you please tell me how to solve this issue?
Regards,
Edited by: 1002059 on Apr 23, 2013 5:36 PMYou should not select from Trial1 - you have the data already. Just insert that value.
Create or replace trigger trg_move_to_trial2
After insert on Trial1
for each row
begin
insert into Trial2 (code)
values (:new.code);
end; regards,
David
Maybe you are looking for
-
What is difference between user group and reference user group?
hi guys, what is difference between user group and reference user group? your regards p.suresh
-
Connecting os9 G3 to 10.3 G4
First I would like to thank everyone for the help on (help or I'm going pc) quick up date I had to erase HD and install osx 3 times before i got a clean install. Yea os9 was long gone. all i can say is +REPAIR PERMISSION+ and do it again. and wow tha
-
I have had serveral instansces where, when I want to open a file, the "Creating Flash Preview..." starts and just goes on for ever.
-
Adding image to panel gives an error
any ideas whatz wrong with this Panel p = new Panel(); Graphics g = getGraphics(); g.drawImage(splashImage, 0,0, p); add(p,BorderLayout.CENTER ); the error i get is "AWT-Windows" (TID:0x14bda60, sys_thread_t:0x56a0cb8, state:R, native ID:0x540) prio=
-
Hi, I have installed oracle 9i on Win 2k. When i Create a new database by using "Database configuration assistant" it creates total 9 .dbf files. like SYSTEM01.DBF, TOOLS01.DBF,UNDOTBS01.DBF,USERS01.DBF,TEMP01.DBF etc what I want to know is , if i lo