Generate INSERT Statements question
Is there a built-in PL/SQL procedure that SQL Developer utilizes to generate the INSERT statements when one exports data from a worksheet in 'insert' format? Is it part of the DBMS_METADATA package?
Mike
No this is all done in Java, we use the DBMB-METADATA only for generating DDL...
Similar Messages
-
Generate Insert Statement Script to Extract Data from Table in Oracle 7i
Hi all, I have an old Oracle legacy system that is running for over 15 years.Every now and then we need to extract data from this table@ ORacle 7i to be imported back to Oracle 10G.
My thoughts are to create a script of Insert statements in oracle 7 and that to be deployed back to Oracle 10G.
I found this scripts in Google and not sure how exactly this works.Any explanation on thsi scripts , would be greatly appreciated.I find this scripst may help to generate a set of insert statements from that table to the latest table at 10G.
<pre>
-- Step 1: Create this procedure:
create or replace Function ExtractData(v_table_name varchar2) return varchar2 As
b_found boolean:=false;
v_tempa varchar2(8000);
v_tempb varchar2(8000);
v_tempc varchar2(255);
begin
for tab_rec in (select table_name from user_tables where table_name=upper(v_table_name))
loop
b_found:=true;
v_tempa:='select ''insert into '||tab_rec.table_name||' (';
for col_rec in (select * from user_tab_columns
where
table_name=tab_rec.table_name
order by
column_id)
loop
if col_rec.column_id=1 then
v_tempa:=v_tempa||'''||chr(10)||''';
else
v_tempa:=v_tempa||',''||chr(10)||''';
v_tempb:=v_tempb||',''||chr(10)||''';
end if;
v_tempa:=v_tempa||col_rec.column_name;
if instr(col_rec.data_type,'CHAR') > 0 then
v_tempc:='''''''''||'||col_rec.column_name||'||''''''''';
elsif instr(col_rec.data_type,'DATE') > 0 then
v_tempc:='''to_date(''''''||to_char('||col_rec.column_name||',''mm/dd/yyyy hh24:mi'')||'''''',''''mm/dd/yyyy hh24:mi'''')''';
else
v_tempc:=col_rec.column_name;
end if;
v_tempb:=v_tempb||'''||decode('||col_rec.column_name||',Null,''Null'','||v_tempc||')||''';
end loop;
v_tempa:=v_tempa||') values ('||v_tempb||');'' from '||tab_rec.table_name||';';
end loop;
if Not b_found then
v_tempa:='-- Table '||v_table_name||' not found';
else
v_tempa:=v_tempa||chr(10)||'select ''-- commit;'' from dual;';
end if;
return v_tempa;
end;
show errors
-- STEP 2: Run the following code to extract the data.
set head off
set pages 0
set trims on
set lines 2000
set feed off
set echo off
var retline varchar2(4000)
spool c:\t1.sql
select 'set echo off' from dual;
select 'spool c:\recreatedata.sql' from dual;
select 'select ''-- This data was extracted on ''||to_char(sysdate,''mm/dd/yyyy hh24:mi'') from dual;' from dual;
-- Repeat the following two lines as many times as tables you want to extract
exec :retline:=ExtractData('dept');
print :retline;
exec :retline:=ExtractData('emp');
print :retline;
select 'spool off' from dual;
spool off
@c:\t1
-- STEP3: Run the spooled output c:\recreatedata.sql to recreate data.
Source:http://www.idevelopment.info/data/Oracle/DBA_tips/PL_SQL/PLSQL_5.shtml
</pre>Thanks Justin.
I get what you are saying,i really wanted to see the output of the codes, because the furtherst i could get from that code is
SELECT EXTRACTDATA('MYTABLE') FROM MYTABLE;
and it generated this:
"select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
select '-- commit;' from dual;"
"select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
select '-- commit;' from dual;"
"select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
select '-- commit;' from dual;"
"select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
select '-- commit;' from dual;"
"select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
select '-- commit;' from dual;"
"select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
select '-- commit;' from dual;"
I was expecting a string of
insert into mytable values (19/1/2009,1,1);
insert into mytable values (19/10/2008,5,10);
Thanks for the explanation . -
Script for generating insert statements
I have different tables with data and I would like to have the insert statements generated of the data in the tables. Does someone have a generic script to do the job?
Hi trafoc,
You can also check out SQL Developer which has function to output table ddl and/or
data under Tools selection. Link is "http://www.oracle.com/technology/software/products/sql/index.html"
Below is a sample output :
-- DATA FOR TABLE PEOPLE
-- FILTER = none used
REM INSERTING into PEOPLE
Insert into PEOPLE (USERNAME,JOB,SALARY,DEPTNO) values ('SMITH','CLERK',800,20);
Insert into PEOPLE (USERNAME,JOB,SALARY,DEPTNO) values ('ALLEN','SALESMAN',1600,30);
Insert into PEOPLE (USERNAME,JOB,SALARY,DEPTNO) values ('WARD','SALESMAN',1250,30);
Insert into PEOPLE (USERNAME,JOB,SALARY,DEPTNO) values ('JONES','MANAGER',2975,20);
Insert into PEOPLE (USERNAME,JOB,SALARY,DEPTNO) values ('MARTIN','SALESMAN',1250,30);
Insert into PEOPLE (USERNAME,JOB,SALARY,DEPTNO) values ('BLAKE','MANAGER',2850,30);
Insert into PEOPLE (USERNAME,JOB,SALARY,DEPTNO) values ('CLARK','MANAGER',2450,10);
Insert into PEOPLE (USERNAME,JOB,SALARY,DEPTNO) values ('KING','PRESIDENT',5000,10);
Insert into PEOPLE (USERNAME,JOB,SALARY,DEPTNO) values ('TURNER','SALESMAN',1500,30);
Insert into PEOPLE (USERNAME,JOB,SALARY,DEPTNO) values ('GRIZZLY','CLERK',1100,20);
Insert into PEOPLE (USERNAME,JOB,SALARY,DEPTNO) values ('JAMES','CLERK',950,30);
Insert into PEOPLE (USERNAME,JOB,SALARY,DEPTNO) values ('FORD','ANALYST',3000,20);
Insert into PEOPLE (USERNAME,JOB,SALARY,DEPTNO) values ('MILLER','CLERK',1300,10);
Insert into PEOPLE (USERNAME,JOB,SALARY,DEPTNO) values ('SCOTT','Clerk',9999,20);
Insert into PEOPLE (USERNAME,JOB,SALARY,DEPTNO) values ('TEST_VPD','Clerk',1500,20);
-- END DATA FOR TABLE PEOPLE
HTH
Zack -
Generate insert statement using columns from all_tab_cols view
i am trying to generate a dynamic insert statement using the columns for a table from the all_tab_cols view. if i do a select, i get the output as rows. How do i convert the row out to columns so that i get something like this : INSERT INTO TABLE_NAME (COL1, COL2, COL3,COL4.....) .
Any help will be appreciated!SQL> select * from my_test;
no rows selected
SQL> desc my_Test;
Name Null? Type
COL1 NUMBER
COL2 NUMBER
COL3 NUMBER
SQL> declare
2 cursor c1 is select column_name from all_tab_cols where table_name = 'MY_TEST';
3 v_sql VARCHAR2(10000) := NULL;
4 v_cnt NUMBER := 0;
5 BEGIN
6 FOR I in C1 LOOP
7 v_cnt := v_cnt + 1;
8 v_sql := 'INSERT INTO my_test('||I.column_name||') values('||v_cnt||')';
9 EXECUTE IMMEDIATE v_sql;
10 END LOOP;
11 COMMIT;
12 end;
13 /
PL/SQL procedure successfully completed.
SQL> select * from my_Test;
COL1 COL2 COL3
1
2
3
SQL> -
Quote problem in Generating Insert Statement Script to Extract Data
Hi every body;
I would like to write an sql/plsql script which can extract data from an oracle existing table in insert statements.
example:
the table employees:
empno name
1 john
2 M'hir
3 M'silou
My problem is that i have the following result:
insert into employees values('1','john');
insert into employees values('2','m'hir');------- Problem with M'hir qote
insert into employees values('3','M'silou');----- Problem with M'silou quote
How can i have :
insert into employees values('2','m''hir');------- two quotes with M'hir =M''hir
insert into employees values('3','M''silou');----- Problem with M'silou=M''silou
plz your help
thank you at advanceHi,
What is your DB version?? If it is >10g, you can use the Q delimiter (as mentioned by Solomon).
Check this out.
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_sqltypes.htm#BABFEDBG
-Arun -
How to set commit interval after n rows when generating insert statements?
Hi
I'm trying to generate a sql insert script with a few million rows using SQL Developer 1.5.4.
I can generate insert scripts ok, but can't see anywhere to set the commit interval.
In the preferences screen under migration I see you can set the commit interval under data move options, but I assume this is something different.
I know we could use sql loader, but this insert is part of deployment package which has a series of sql scripts that we need to run together. So I don't want to run a series of sql scripts, then run sql loader, and then go back to sql scripts.
Am i missing something, or is this just not possible with SQL Developer?
Thanks in advance for your help,
PeteUnfortunately, SQL Developer doesn't cover all of the SQL*Plus commands. There is a preference in SQL Developer to switch on autocommit in the SQL worksheet (Tools > Preferences > Database > Worksheet Parameters), but that is presumably every record, rather than every 100 as you are trying to do.
There is a document on SQL Developer's SQL*Plus support (here), but that doesn't list autocommit in either the supported or unsupported sections.
theFurryOne -
Generate SQL Insert Statements
Hello,
I am testing generating insert statements for which I have a function which will return a sql statement.
This sql statement when I execute would results as sql insert statements.
What I am trying to acheive through a procedure is when I execute function, the result I would like to execute automatically and then the second sql I would like to store to a control file or sql file.
How can I acheive this?
Any help is very helpful
Regards
Edited by: user20090209 on Aug 20, 2009 11:34 AMHere is the function to generate sql
CREATE OR REPLACE function insert_sql(v_table_name varchar2)
return varchar2 as
b_found boolean := false;
v varchar2(32000);
v1 varchar2(32000);
v2 varchar2(32000);
begin
for s in (
select *
from all_tables
where table_name=upper(v_table_name)
--and owner=upper(v_owner)
) loop
b_found := true;
for ss in (
select *
from all_tab_columns
where table_name = s.table_name
order by column_id
) loop
if ss.data_type='NUMBER' then
v1:=v1||','||ss.column_name;
v2:=v2||',''''''||to_char('||ss.column_name||')||''''''';
end if;
if ss.data_type in ('VARCHAR2','CHAR') then
v1:=v1||','||ss.column_name;
v2:=v2||',''''''||replace(replace('||ss.column_name||','''''''',''''''''''''),''&'','''')||''''''';
end if;
if ss.data_type='DATE' then
v1:=v1||','||ss.column_name;
v2:=v2||',to_date(''''''||to_char('||ss.column_name||',''dd.mm.yyyy hh:mi:ss'')||'''''',''''dd.mm.yyyy hh:mi:ss'''')';
end if;
end loop;
v:='select ''insert into '||s.table_name||' (';
v:=v||substr(v1,2,9999)||') '||chr(10)||' values ('||substr(v2,2,9999)||'); '' txt from '||s.table_name;
end loop;
if not b_found then
v:='- Table ' || v_table_name || ' not found';
else
v:=v;
end if;
return v;
end;
/And I am calling like
CREATE OR REPLACE PROCEDURE test_gen_script_exec IS
type v_ref_cur is REF CURSOR;
v_ref_cur_var v_ref_cur;
v_temp_sql VARCHAR2(4000);
v_sql varchar2(4000);
begin
v_sql := insert_sql('table_name');--change here
open v_ref_cur_var for v_sql;
loop
fetch v_ref_cur_var into v_temp_sql;
exit when v_ref_cur_var%notfound;
execute immediate v_temp_sql;
end loop;
close v_ref_cur_var;
end;
/Edited by: user20090209 on Aug 20, 2009 1:24 PM -
Simple SELECT query to generate INSERT for a table
Hi,
I am looking for a SELECT query which generates INSERT statements for a table.Please guide.
Thanks
PG.Like this?
SQL> SELECT * from kons;
COL1 COL2
1 1
2 2
SQL> SELECT 'INSERT INTO kons VALUES('||col1||','||col2||');' statement FROM kons;
STATEMENT
INSERT INTO kons VALUES(1,1);
INSERT INTO kons VALUES(2,2);
SQL> If you have character and / or date columns you will have to change my example,
but you might get the idea from it.
You can spool the result to a file.
Regards,
Guido
Edit: ';' added to end of statement... -
Unable to generate insert stmt scripts using sql developer
We are not able to generate INSERT statement script using SQL Developer. In the INSERT script system is inserting some spaces due to carriage return which we cannot reviewed individually.
DELETE FROM IM_INSTANCE_EXT_VAL_FRM
WHERE IEVF_TRG_FLD_NAME = 'PRAI_NUM_03'
AND IEVF_INST_CODE = 'APV-QQ-03'
AND IEVF_BLK_NAME = 'PGIT_POL_RISK_ADDL_INFO_01';
-- INSERTING into IM_INSTANCE_EXT_VAL_FRM
Insert into IM_INSTANCE_EXT_VAL_FRM (IEVF_SYS_ID,IEVF_INST_CODE,IEVF_PROG_CODE,IEVF_BLK_NAME,IEVF_TRG_FLD_NAME,IEVF_ACT_FLDS,IEVF_ACTION,IEVF_PROC,IEVF_SRNO,IEVF_ERR_NO,IEVF_ERR_YN,IEVF_APP_CODE,IEVF_REMARKS,IEVF_UPD_UID,IEVF_UPD_DT,IEVF_CR_UID,IEVF_CR_DT,IEVF_TRG_NAME,IEVF_CLEAR_FLD_YN,IEVF_VALIDATE_YN) values (IEVF_SYS_ID.NEXTVAL,'APV-QQ-03','PGIT6_03','PGIT_POL_RISK_ADDL_INFO_01','PRAI_NUM_03','PRAI_DATA_15,','ENABLED','VFB_EV_GEN.EXT_VAL_DISABLE_PHY_DAMAGE(:PGIT_POL_RISK_ADDL_INFO_01.PRAI_POL_SYS_ID,
:PGIT_POL_RISK_ADDL_INFO_01.PRAI_END_NO_IDX,
:PGIT_POL_RISK_ADDL_INFO_01.PRAI_END_SR_NO,
:PGIT_POL_RISK_ADDL_INFO_01.PRAI_LVL1_SYS_ID,
:PGIT_POL_RISK_ADDL_INFO_01.PRAI_CODE_02,
:PGIT_POL_RISK_ADDL_INFO_01.PRAI_NUM_03,:P_FLAG_OUT)',1,null,'N','01','VALIADTION',null,null,'PREMIA',
to_date('19-SEP-07','DD-MON-RR'),'WHEN-VALIDATE-ITEM','0','1');
Insert into IM_INSTANCE_EXT_VAL_FRM (IEVF_SYS_ID,IEVF_INST_CODE,IEVF_PROG_CODE,IEVF_BLK_NAME,IEVF_TRG_FLD_NAME,IEVF_ACT_FLDS,IEVF_ACTION,IEVF_PROC,IEVF_SRNO,IEVF_ERR_NO,IEVF_ERR_YN,IEVF_APP_CODE,IEVF_REMARKS,IEVF_UPD_UID,IEVF_UPD_DT,IEVF_CR_UID,IEVF_CR_DT,IEVF_TRG_NAME,IEVF_CLEAR_FLD_YN,IEVF_VALIDATE_YN) values (IEVF_SYS_ID.NEXTVAL,'APV-QQ-03','PGIT6_03','PGIT_POL_RISK_ADDL_INFO_01','PRAI_NUM_03',null,'VALIDATE','VFB_EV_GEN.EXT_VAL_VEHICLE_AGE(:PGIT_POL_RISK_ADDL_INFO_01.PRAI_POL_SYS_ID, :PGIT_POL_RISK_ADDL_INFO_01.PRAI_PSEC_SYS_ID,
''APV'',
''APV'',
:PGIT_POL_RISK_ADDL_INFO_01.PRAI_NUM_03,
:PGIT_POL_RISK_ADDL_INFO_01.PRAI_NUM_07,
:PGIT_POL_RISK_ADDL_INFO_01.PRAI_NUM_08,
:P_FLAG_OUT,
:PGIT_POL_RISK_ADDL_INFO_01.PRAI_NUM_35_OUT) ',3,null,'N','01','VALIADTION',null,null,'PREMIA',to_date('19-SEP-07','DD-MON-RR'),'WHEN-VALIDATE-ITEM','1','1');
Insert into IM_INSTANCE_EXT_VAL_FRM (IEVF_SYS_ID,IEVF_INST_CODE,IEVF_PROG_CODE,IEVF_BLK_NAME,IEVF_TRG_FLD_NAME,IEVF_ACT_FLDS,IEVF_ACTION,IEVF_PROC,IEVF_SRNO,IEVF_ERR_NO,IEVF_ERR_YN,IEVF_APP_CODE,IEVF_REMARKS,IEVF_UPD_UID,IEVF_UPD_DT,IEVF_CR_UID,IEVF_CR_DT,IEVF_TRG_NAME,IEVF_CLEAR_FLD_YN,IEVF_VALIDATE_YN) values (IEVF_SYS_ID.NEXTVAL,'APV-QQ-03','PGIT6_03','PGIT_POL_RISK_ADDL_INFO_01','PRAI_NUM_03','PRAI_DATA_15,','DEFAULT','VFB_EV_GEN.DEFAULT_PHYSICAL_DAMAGE_SYMBOL(:PGIT_POL_RISK_ADDL_INFO_01.PRAI_POL_SYS_ID,
:PGIT_POL_RISK_ADDL_INFO_01.PRAI_PROD_CODE,
:PGIT_POL_RISK_ADDL_INFO_01.PRAI_PSEC_SYS_ID,
''APV'',
:PGIT_POL_RISK_ADDL_INFO_01.PRAI_NUM_03,
:PGIT_POL_RISK_ADDL_INFO_01.PRAI_NUM_07,
:PGIT_POL_RISK_ADDL_INFO_01.PRAI_CODE_03,
:PGIT_POL_RISK_ADDL_INFO_01.PRAI_CODE_02,
:P_FLAG_OUT,
:PGIT_POL_RISK_ADDL_INFO_01.PRAI_DATA_15_OUT)',2,null,'N','01','DEFAULT',null,null,'PREMIA',to_date('30-AUG-07','DD-MON-RR'),'WHEN-VALIDATE-ITEM','0','1');
Insert into IM_INSTANCE_EXT_VAL_FRM (IEVF_SYS_ID,IEVF_INST_CODE,IEVF_PROG_CODE,IEVF_BLK_NAME,IEVF_TRG_FLD_NAME,IEVF_ACT_FLDS,IEVF_ACTION,IEVF_PROC,IEVF_SRNO,IEVF_ERR_NO,IEVF_ERR_YN,IEVF_APP_CODE,IEVF_REMARKS,IEVF_UPD_UID,IEVF_UPD_DT,IEVF_CR_UID,IEVF_CR_DT,IEVF_TRG_NAME,IEVF_CLEAR_FLD_YN,IEVF_VALIDATE_YN) values (IEVF_SYS_ID.NEXTVAL,'APV-QQ-03','PGIT6_03','PGIT_POL_RISK_ADDL_INFO_01','PRAI_NUM_03',null,'VALIDATE','VFB_EV_GEN.EXT_VAL_PHY_DAMAGE(:PGIT_POL_RISK_ADDL_INFO_01.PRAI_POL_SYS_ID,
:PGIT_POL_RISK_ADDL_INFO_01.PRAI_END_NO_IDX,
:PGIT_POL_RISK_ADDL_INFO_01.PRAI_END_SR_NO,
:PGIT_POL_RISK_ADDL_INFO_01.PRAI_LVL1_SYS_ID,
:PGIT_POL_RISK_ADDL_INFO_01.PRAI_CODE_02,
:PGIT_POL_RISK_ADDL_INFO_01.PRAI_NUM_03,
:P_FLAG_OUT,
:PGIT_POL_RISK_ADDL_INFO_01.PRAI_DATA_15_OUT)',9,null,'N','01','VALIADTION',null,null,'PREMIA',
to_date('19-SEP-07','DD-MON-RR'),'WHEN-VALIDATE-ITEM','1','1');
script which is taken from Sql Developer and got error while running in SQL* PLUS
Following error was raised on running the script in SQL * PLUS
5 rows deleted.
1 row created.
1 row created.
1 row created.
SP2-0734: unknown command beginning ":P_FLAG_OU..." - rest of line ignored.
SP2-0734: unknown command beginning ":PGIT_POL_..." - rest of line ignored.
SP2-0734: unknown command beginning "to_date('1..." - rest of line ignored. -
VLD-1119: Unable to generate Multi-table Insert statement for some or all t
Hi All -
I have a map in OWB 10.2.0.4 which is ending with following error: -
VLD-1119: Unable to generate Multi-table Insert statement for some or all targets.*
Multi-table insert statement cannot be generated for some or all of the targets due to upstream graphs of those targets are not identical on "active operators" such as "join".*
The map is created with following logic in mind. Let me know if you need more info. Any directions are highly appreciated and many thanks for your inputs in advance: -
I have two source tables say T1 and T2. There are full outer joined in a joiner and output of this joined is passed to an expression to evaluate values of columns based on
business logic i.e. If T1 is available than take T1.C1 else take T2.C1 so on.
A flag is also evaluated in the expression because these intermediate results needs to be joined to third source table say T3 with different condition.
Based on value taken a flag is being set in the expression which is used in a splitter to get results in three intermediate tables based on flag value evaluated earlier.
These three intermediate tables are all truncate insert and these are unioned to fill a final target table.
Visually it is something like this: -
T1 -- T3 -- JOINER1
| -->Join1 (FULL OUTER) --> Expression -->SPLITTER -- JOINER2 UNION --> Target Table
| JOINER3
T2 --
Please suggest.I verified that their is a limitation with the splitter operator which will not let you generate a multi split having more than 999 columns in all.
I had to use two separate splitters to achieve what I was trying to do.
So the situation is now: -
Siource -> Split -> Split 1 -> Insert into table -> Union1---------Final tableA
Siource -> Split -> Split 2 -> Insert into table -> Union1 -
Question related to INSERT statement
Consider this scenario:
- table_a has 5,000,000 records at time t1
- table_b is empty at time t1
- At time t1, I execute the following statement:
insert into table_b
select * from table_a;
- The insert statement finishes at time t2
- Between t1 and t2, say 3,000 new records were added to table_a (by OLTP processes).
So at time t2, table_a has 5,003,000 records.
My question is, at time t2, how many records will be in table_b? Will it be 5,000,000 or
5,003,000 or somewhere between these two counts?
I am guessing it will be 5,000,000 since that was the number when the insert statement
started to execute.
Any feedback is much appreciated.Syed Ullah wrote:
Consider this scenario:
- table_a has 5,000,000 records at time t1
- table_b is empty at time t1
- At time t1, I execute the following statement:
insert into table_b
select * from table_a; - The insert statement finishes at time t2
- Between t1 and t2, say 3,000 new records were added to table_a (by OLTP processes).
So at time t2, table_a has 5,003,000 records.
My question is, at time t2, how many records will be in table_b? Will it be 5,000,000 or
5,003,000 or somewhere between these two counts?
I am guessing it will be 5,000,000 since that was the number when the insert statement
started to execute.
Any feedback is much appreciated.At time t2 it's possible the answer is 0. Once the insert operation finishes (could be any time after t1 in your example, possibly before t2, possibly after) and assuming you checked within the same session where you ran the insert, you'd see 5,000,000. In other sessions you would continue to see 0 until the session that performed the insert did a COMMIT.
http://docs.oracle.com/cd/E11882_01/server.112/e25789/consist.htm#CNCPT121
Is something you should be reading. It outlines these fundamental concepts much better than you're likely going to find in a few forum posts. -
TopLink does not generate SQL statements for inserting new objects
TopLink does not generate SQL statements for inserting new objects. Why?
Thanks in advance...Please see the response in
Why does not unitofwork.commit write data to the database?
Regards,
Chris -
Can I insert pretest questions as knowledge checks between content slides and before a graded quiz without affecting the scoring of the graded quiz? Help documentation states that they should be used before a course begins.
If I use both pretest questions and graded questions, can I also include remedial with return to quiz for both?Sorry, but I gave two workarounds: my preference is custom question slides, but you can also have questions slides where you do not add the score to the Total score. They will not be reported to the LMS and can act as Knowledge slides. Only some quizzing system variables can count all question slides, including the Knowledge slides, but the core variables (score, maximum score, percentage) will be correct. Here some links to my blog, that could help you:
System variables in Captivate 8 - Captivate blog
Intermediate Score Slides - Captivate blog
That each SCORM module can have only one quiz is a SCORM requirement, not a a Captivate specific feature. Camtasia is bit difficult to compare, it is not a fully blown authoring tool although the best video screen capture tool around (video is non interactive by definition). I don't use Storyline, but cannot imagine that they shouldn't create SCORM-compliant files. -
Bulk Load question for an insert statement.
I'm looking to put the following statement into a FORALL statement using BULK COLLLECT and I need some guidance.
Am I going to be putting the SELECT statement into a cursor and then load the cursor values into a defined Nested Table type defined variable?
INSERT INTO TEMP_ASSOC_CURRENT_WEEK_IDS
SELECT aor.associate_office_record_id ,
sched.get_assoc_sched_rotation_week(aor.associate_office_record_id, v_weekType.start_date) week_id
FROM ASSOCIATE_OFFICE_RECORDS aor
WHERE aor.OFFICE_ID = v_office_id
AND (
(aor.lt_assoc_stage_result_id in (4,8)
AND v_officeWeekType.start_date >= trunc(aor.schedule_start_date)
OR aor.lt_assoc_stage_result_id in (1, 2)
));I see people are reading this so for the insanely curious here's how I did it.
Type AOR_REC is RECORD(
associate_office_record_id dbms_sql.number_table,
week_id dbms_sql.number_table); --RJS.***Setting up Type for use with Bulk Collect FORALL statements.
v_a_rec AOR_REC; -- RJS. *** defining variable of defined Type to use with Bulk Collect FORALL statements.
CURSOR cur_aor_ids -- RJS *** Cursor for BULK COLLECT.
IS
SELECT aor.associate_office_record_id associate_office_record_id,
sched.get_assoc_sched_rotation_week(aor.associate_office_record_id, v_weekType.start_date) week_id
FROM ASSOCIATE_OFFICE_RECORDS aor
WHERE aor.OFFICE_ID = v_office_id
AND (
(aor.lt_assoc_stage_result_id in (4,8)
AND v_officeWeekType.start_date >= trunc(aor.schedule_start_date)
OR aor.lt_assoc_stage_result_id in (1, 2)
FOR UPDATE NOWAIT;
BEGIN
BEGIN
OPEN cur_aor_ids;
LOOP
FETCH cur_aor_ids BULK COLLECT into
v_a_rec.associate_office_record_id, v_a_rec.week_id; --RJS. *** Bulk Load your cursor data into a buffer to do the Delete all at once.
FORALL i IN 1..v_a_rec.associate_office_record_id.COUNT SAVE EXCEPTIONS
INSERT INTO TEMP_ASSOC_CURRENT_WEEK_IDS
(associate_office_record_id,week_id)
VALUES
(v_a_rec.associate_office_record_id(i), v_a_rec.week_id(i)); --RJS. *** Single FORALL BULK DELETE statement.
EXIT WHEN cur_aor_ids%NOTFOUND;
END LOOP;
CLOSE cur_aor_ids;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('ERROR ENCOUNTERED IS SQLCODE = '|| SQLCODE ||' AND SQLERRM = ' || SQLERRM);
dbms_output.put_line('Number of INSERT statements that
failed: ' || SQL%BULK_EXCEPTIONS.COUNT);
End;
Easy right? -
Question on Creating Table From Insert statement
Hi,
I want to create a table using a DBlink from another database using the create/insert statement. Will it also transfer the constraints or do I have to do it manually afterwards? Thanks.
Create table T1
SELECT a,b,c from T2 from DB@dblink;As discussed above, the constraints, indexes, triggers are not copied. Only NOT NULL constraints are copied.
Look at this thread Re: Copying table structure.
for copying triggers/indexes from source table to destination table.
Thanks,
Navaneeth
Maybe you are looking for
-
For some reason, my Windows Media Player started messing up. I tried to place it in my trash and get rid of it, and it won't go away. It keeps saying that all of these files, with an htm extension are locked. I can't seem to figure out how to unlock
-
Hi Expert, We have following requirement a) Vendor to acknowledge a newly placed purchase order from my client. b) system prompt if the PO is not acknowledge by vendor within x days I know, we have confirmation tab in PO. Could you pl tell me, how to
-
Custom USSD via GSM Modem_SMS Session
Hi, My aim is to create an sms session between 2 phones via labview. I've heard of network service providers using the USSD protocal for achieving this. Is there any way i can create a custom USSD session for my application? Or is there any other way
-
Charging icon problem...
When I plug in my 8110 to charge, it is not showing the plug symbol. I think it may actually be still charging, but the little icon is not showing up. Anyone know what's going on??? Thanks... "We're all in the gutter, but some of us are looking at th
-
No stacktrace after stderr redirection
Hi I'd like to redirect all stderr output from the JVM to a file. Without redirection the normal error output is shown in case of an exception (JVM started in an exe file in the Windows console). But after redirection with the following command: