INSERT INTO from 11g to a 10G
All,
Im getting an error when i execute this statement
INSERT INTO target_table@database_link( column_list )
SELECT list_of_columns
FROM tables_on_local_database
WHERE some_conditions.
The only thing that i've noticed is that im executing it on an 11g db to a 10g db.
Is that really the problem?
Thanks.
Yoy
Hi,
Apps Devel wrote:
Is that really the problem?
No.
Similar Messages
-
Record is not inserting into the Table thourgh forms 10g
Hi All,
I have the form built in 10g(10.1.2.0.2).
Basically the form has 2 blocks.
Block 1 with only one item, where we enter some value and hit enter(this will navigate to block2 and execute the query).
Block 2(tabular) will fetch the records. Now this block2 have 3 columns(caseid, userid, date).
Now when I insert a new record, I just need to enter the caseid only. And userid and date have to be automatically populated.
I can populate the USERID and DATE fields.
And when I enter some value in caseid item of block 2, and then do Control+S(to insert the record and Save the transaction),
i get the message saying FRM-40400: Transaction complete: 1 records applied and saved.
But when I query again for the same, I dont se the record inserted into the table.
Why is this happening?
Help please...@ Inol
There is no promary or foriegn key relation ship. The form is fetching records from just one table. As I said block1 has col1. and Block2 has col2,3,4.
@Andreas
Yes I did select * from table, select count(*) from table in SQL*Plus. Nothing is inserted.
And one thing I have to tall here is, I have a ON-INSERT trigger in block2.
The code in ON-INSERT trigger is
-- :BLOCK2.DATE := TO_DATE(:DATE,'DD-MON-YYYY') ;
/* commented since I was populating date by assigning $$DATETIME$$ to the Initial value property of the data item. */
:BLOCK2.SOURCE_CASE := :BLOCK1.SOURCE_CASEID;Forgot to tell you,
Since I was inserting the record from block2(3 columns), to the table which has 4 columns, there is another item in block 2 which has the visible property No.
So the block 2 has 4 columns. And the hidden column will hold the value that is in the item of block1. This is what i'm pushing in the ON-INSERT trigger.
Edited by: Charan on Sep 20, 2011 1:51 PM -
Error With Insert Into From Select
Hello,
I have a problem with this query in pl sql developer with oracle 10G:
insert into ca_nrj_rem(imsi,id_gamme_vente,domaine,date_topage,id_produit)
(select a1.* from (select d.imsi, 1, 4, trunc(sysdate - 1), 'NRJ003'
from ca_evenement_vsim a, ca_forfait b, ca_forfait c, ca_vsim_associe d
where a.id_action = 'CP1'
and bao.Lecture_Parametre_XML_V2(a.valeur_parametres, 'ancienCode') = b.code_forfait
and b.code_gamme = 2
and bao.Lecture_Parametre_XML_V2(a.valeur_parametres, 'nouveauCode') = c.code_forfait
and c.code_gamme = 6
and date_trace > sysdate - 6
and a.vsimid = d.vsimid
and d.date_fin is null
group by d.imsi, trunc(sysdate - 1)) a1, ca_nrj_rem n
where a1.imsi=n.imsi(+) and n.imsi is null);
The select statement return X (163) values but the insert statement inserts Y (540) values
Can you help me please ?
Thanks Youuser511447 wrote:
The select statement return X (163) values but the insert statement inserts Y (540) valuesNot possible if the select statements are identical.
You'll have to provide more evidence and example output (format it on the forum by putting {noformat}{noformat} before and after it), so we can see exactly what you are doing.
Are you sure that the table you are inserting into has no rows initially or that you are counting the rows correctly?
Show us exactly what you are doing. -
How can I INSERT INTO from Staging Table to Production Table
I’ve got a Bulk Load process which works fine, but I’m having major problems downstream.
Almost everything is Varchar(100), and this works fine.
Except for these fields:
INDEX SHARES, INDEX MARKET CAP, INDEX WEIGHT, DAILY PRICE RETURN, and DAILY TOTAL RETURN
These four fields must be some kind of numeric, because I need to perform sums on these guys.
Here’s my SQL:
CREATE
TABLE [dbo].[S&P_Global_BMI_(US_Dollar)]
[CHANGE]
VARCHAR(100),
[EFFECTIVE DATE]
VARCHAR(100),
[COMPANY]
VARCHAR(100),
[RIC]
VARCHAR(100),
Etc.
[INDEX SHARES]
NUMERIC(18, 12),
[INDEX MARKET CAP]
NUMERIC(18, 12),
[INDEX WEIGHT]
NUMERIC(18, 12),
[DAILY PRICE RETURN]
NUMERIC(18, 12),
[DAILY TOTAL RETURN]
NUMERIC(18, 12),
From the main staging table, I’m writing data to 4 production tables.
CREATE
TABLE [dbo].[S&P_Global_Ex-U.S._LargeMidCap_(US_Dollar)]
[CHANGE]
VARCHAR(100),
[EFFECTIVE DATE]
VARCHAR(100),
[COMPANY]
VARCHAR(100),
[RIC]
VARCHAR(100),
Etc.
[INDEX SHARES]
FLOAT(20),
[INDEX MARKET CAP]
FLOAT(20),
[INDEX WEIGHT] FLOAT(20),
[DAILY PRICE RETURN]
FLOAT(20),
[DAILY TOTAL RETURN]
FLOAT(20),,
INSERT
INTO [dbo].[S&P_Global_Ex-U.S._LargeMidCap_(US_Dollar)]
SELECT
[CHANGE],
Etc.
[DAILY TOTAL RETURN]
FROM
[dbo].[S&P_Global_BMI_(US_Dollar)]
WHERE
isnumeric([Effective Date])
= 1
AND
[CHANGE] is
null
AND
[COUNTRY] <>
'US'
AND ([SIZE] =
'L' OR [SIZE]
= 'M')
The Bulk Load is throwing errors like this (unless I make everything Varchar):
Bulk load data conversion error (truncation) for row 7, column 23 (INDEX SHARES).
Msg 4863, Level 16, State 1, Line 1
When I try to load data from the staging table to the production table, I get this.
Msg 8115, Level 16, State 8, Line 1
Arithmetic overflow error converting varchar to data type numeric.
The statement has been terminated.
There must be an easy way to overcome this, right.
Please advise!
Thanks!!
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.Nothing is returned. Everything is VARCHAR(100). the problem is this.
If I use FLOAT(18) or REAL, I get exponential numbers, which is useless to me.
If I use DECIMAL(18,12) or NUMERIC(18,12), I get errors.
Msg 4863, Level 16, State 1, Line 41
Bulk load data conversion error (truncation) for row 7, column 23 (INDEX SHARES).
Msg 4863, Level 16, State 1, Line 41
Bulk load data conversion error (truncation) for row 8, column 23 (INDEX SHARES).
Msg 4863, Level 16, State 1, Line 41
Bulk load data conversion error (truncation) for row 9, column 23 (INDEX SHARES).
There must be some data type that fits this!
Here's a sample of what I'm dealing with.
-0.900900901
9.302325581
-2.648171501
-1.402805723
-2.911830584
-2.220960866
2.897762349
-0.219640074
-5.458448607
-0.076626094
6.710940231
0.287200186
0.131682908
0.124276221
0.790818723
0.420505119
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it. -
Record not inserting into the table through Forms 10g
Hi all,
I have created a form in 10g(10.1.2.0.2) based on just one table that has 4 columns(col1, col2, col3, col4).
Here col1, col2 and col3 are VARCHAR2 and col4 is date and all the columns are not null columns(There are no primary and foriegn key constrains, which means duplicates are allowed).
My form contains 2 blocks where block 1 has one text item (col1) and 3 buttons (Delete, Save, Exit).
And block2 is a database block and has col2,col3,col4 which are in tabluar layout frame displaying 10 records.
When the form is opened the cursor has to be in block1.col1 for querrying. Here i enter a value in col1, and then when I click on col2 in the block2, then I put execute_query in new_block_instance of block2, which displays the records.
The block2 properties are not updatable, insertable and query is allowed.
Everything is working good until here. But here in the block2 when I want to insert another record into the table, by navigating all the way down to the last empty record and entering the new values for col2, col3 and col4 And then Ctrl+S will display the message "*FRM-40400: Transaction complete: 1 record applied and saved.*" But actually the record is not inserted into the table.
I also disabled the col4 by setting the Enabled property to No, since while inserting new record the date have to be populated into it and it shouldnt be changed by the user. And im populating the sysdate into the new record by setting Intial Value property to *$$DATE$$*.
And another requirement which I could not work arround here is that, the col3 also should be populated with the username of the user while inserting.
please help me...Hi Sarah,
I do not want to update the existing record. So I kept Udate Allowed to No in property palette for the items in block2.
Do I have to do this property at block level also?
I'm inserting a new record here.
Edited by: Charan on Sep 19, 2011 8:48 AM -
Hi David,
I would need to export 11G database tables and import them to 10G database. I have exported from 11G using exp command. The command I have used is:
exp scott/tiger file=emp.dmp tables=emp,dept;
Now I need to import emp.dmp in Oracle 10G. Would the imp command for Oracle 10G work in this case? Is the command I need to use as given below?
imp scott/tiger file=emp.dmp full=yes
Can you please help me in this regard.
Thanks as always,
ChDDavid,
Thanks. This has been helpful. I am having some questions working with AWM.
In my case I am having the following dimensions:
Positon Dim
Positon Dim Hierarchy (Nation--> Region--> District --> territory)
Product Dim
Product Dim Hierarchy (Market --> TA --> Brand --> Item)
Customer Dim.
Now in my reports I am shwing the Product and Positions from Hierarchies (not from the Dimensions). In this case do I need to specify aggregation based on the Position/Product Dims or on Position/Product Hierarchies only?
Again, I am having some reports based on the Customer Dim. But Customer Dim has no Hierarchy. So do I need to aggregate the data based on the Customer Dim at all?
Also please tell me whether I need to follow any specific order of dimensions in case of aggregation (or that is something AWM would itself take care)?
Lastly, there are a lot of Calculations in the Aggregation drop down. Should I use 'Sum' while aggregating in this case and rolling up data based on Hierarchies?
Thanks in advance.
ChD -
Easier INSERT INTO in 11g?
In Oracle, we can pass parameters to a procedure by name. Example:
procedure_name( param1 => 'some_value', param2 => 'some value', param3 => 'some value' );
Is there a similar way in the INSERT statement? Maybe something like:
INSERT INTO table_name (column1 = 'some values', column2 = 'some values', column3 = 'some values');
This way, it's easer to read INSERT statements, especially if there are more columns to be inserted (e.g more than 30 columns!). Any ideas if 11g has this similar feature now? Or maybe this exists already for previous versions as well?
Hmmm, actually, all I am asking is maybe INSERT should have something similar as UPDATE syntax?
Edited by: dongzky on Jun 30, 2010 3:06 PMYou should create your own procedure and work through.
create procedure insert_mytable(p_col1, p_col2...)
insert into mytable(col1,col2...) values (p_c1,p_c2...);
end;
exec insert_mytable(p_col1=>'text',p_col2=>'text'...)I'd say that's very good to have API like that for development to control all the insert.
Nicolas. -
WAY TO IMPORT DATA FROM 11G DATABASE TO 10G DATABASE?
Hi All,
I have a requirement to take an full export dump of an Oracle database and import it fully to a 10g database.
I have never touched 11G until now and would like to know whether the 11G expdp will be downward
compatible so that I can use the dump file(created by 11G expdp) to import it to 10G(using 10d impdp).
Or if it is not possible, can you please brief me the steps I should follow here?
Note: I have only 11G installed in this server.
Regards
SatishOracle's Data Pump (expdp) utility has a VERSION parameter. Here is an excerpt from the documentation:
VERSION
Default: COMPATIBLE
Purpose
Specifies the version of database objects to be exported. This can be used to create a dump file set that is compatible with a previous release of Oracle Database. Note that this does not mean that Data Pump Export can be used with versions of Oracle Database prior to 10.1. Data Pump Export only works with Oracle Database 10g release 1 (10.1) or later. The VERSION parameter simply allows you to identify the version of the objects being exported.
Syntax and Description
VERSION={COMPATIBLE | LATEST | version_string}
The legal values for the VERSION parameter are as follows:
* COMPATIBLE - This is the default value. The version of the metadata corresponds to the database compatibility level. Database compatibility must be set to 9.2 or higher.
* LATEST - The version of the metadata corresponds to the database version.
* version_string - A specific database version (for example, 11.1.0). In Oracle Database 11g, this value cannot be lower than 9.2.
Database objects or attributes that are incompatible with the specified version will not be exported. For example, tables containing new datatypes that are not supported in the specified version will not be exported.
Here is a link to the documentation.
Hope this helps! -
Error during dump file Import from 11g DB into XE database
Hi ,
I have a dump file exported from a 11g database. First i imported this dump file into another 11gdb test database and it worked fine.
Later i tried to import it into an XE database. But import completed with error message as shown below. This error message appeared only for few tables.
IMP-00015: following statement failed because the object already exists:
Note - I created a new schema in XE database and tried to import the dump into this schema. So there is no chance for the object to exist before the import operation.
Does anyone have any idea why import in XE fails? Is there any limitation/restriction in XE?
FYI - All the tables that failed to import contains LOB data in it. Is LOB datatype is not supported in XE? Does this cause the problem during import?
Regards,
Ashok Kumar.GGoing from 11g to XE(10g) is problematic for two reasons 1st - 11g exports not necessarily compatible with an earlier version and 2nd I have found that in some cases 11g exports can have problems when importing back into another 11g(11.1.0.7) instance due to stack overruns whereas an 10g export to 11g normally works fine..
./bob h. -
Move HR schema from 11g to 10g
I have oracle 10g installed on my sun box and I have oracle 11g installed on my other system. I would like to know how to move HR schema from 11g to my 10g.
please advise me in steps as I am new to oracle.Ok, didn't know that.
Why not take the file from your 11g installation and run it against your 10g?
If you don't want ro do that, you can use CTAS over dblink or look into COPY command from SQL*Plus.
Regards
Peter -
How to Insert data from an XML file into an Oracle 10g table
Hello,
Please can you help me as I have hit a brick wall with this problem.
We are running version 10g Oracle and we will start receiving XML files with employee data that needs loading into a table, this is the XML file:
<?xml version="1.0"?>
<RECRUITS>
<RECRUIT>
<FIRST_NAME>Gordon</FIRST_NAME>
<LAST_NAME>Brown</LAST_NAME>
<SHORT_NAME>GORDONBROWN</SHORT_NAME>
<APP_NO>00002</APP_NO>
<STATUS>M</STATUS>
<DATE_FROM>21-JUL-2006</DATE_FROM>
<RESOURCE_TYPE>P</RESOURCE_TYPE>
<TITLE>Mr</TITLE>
<DATE_OF_BIRTH>28-DEC-1983</DATE_OF_BIRTH>
<SOCIAL_SEC>AB128456A</SOCIAL_SEC>
<PARTTIME_PCT>1</PARTTIME_PCT>
<SEX>M</SEX>
<ADDRESS_TYPE>1</ADDRESS_TYPE>
<ADDRESS>A HOUSE SOMEWHERE HERE</ADDRESS>
<ZIP_CODE>PE3 LLL</ZIP_CODE>
<PLACE>BOROUGH</PLACE>
<COUNTRY_CODE>UK</COUNTRY_CODE>
<PROVINCE>UK</PROVINCE>
<EMAIL>[email protected]</EMAIL>
</RECRUIT>
(FYI - there may be more than 1 employee in each file so all of the above will be repeated X amount of times)
</RECRUITS>
To make things simple we have created a table which mirrors the XML file completely to load the data into, the SQL i have used is thus:
CREATE TABLE RECRUITMENT
FIRST_NAME VARCHAR2(30),
LAST_NAME VARCHAR2(30),
SHORT_NAME VARCHAR2(30),
APP_NO NUMBER,
STATUS VARCHAR2(1),
DATE_FROM DATE,
RESOURCE_TYPE VARCHAR2(1),
TITLE VARCHAR2(4),
DATE_OF_BIRTH DATE,
SOCIAL_SEC VARCHAR2(9),
PARTTIME_PCT NUMBER,
SEX VARCHAR2(1),
ADDRESS_TYPE VARCHAR2(1),
ADDRESS VARCHAR2(30),
ZIP_CODE VARCHAR2(8),
PLACE VARCHAR2(10),
PROVINCE VARCHAR2(3),
EMAIL VARCHAR2(20)
Every method we try from the numerous documents and so called "user guides" have failed, please can somebody show me the PL/SQL i need to get this files data into the above table?
We need to be able to do this purely through SQL*PLUS as we hope - if we ever get it working manually to create a procuedure that will encapsulate everything so it can be run over and over again.
The XML file is sitting in the XMLDIR and is called REC.XML.
Please help : (Hi, I have got some material for inserting data into oracle table from xml file, this might help you.
Create XML Document Table
create table XML_DOCUMENT_TABLE
FILENAME varchar2(64),
XML_DOCUMENT XMLTYPE
(This will be as per your record details).
Inserting record to Oracle Table
declare
XML_TEXT CLOB := '<smsnotification>
<messageid> 256427844 </messageid>
<protocolid> CO0NPS2KHQ </protocolid>
<notifiedon> 1156123007416 </notifiedon>
<status> 3PBI: Invalid </status>
<additionalinfo> Customer account not active </additionalinfo>
<carrierid> 1175 </carrierid>
</smsnotification>';
begin
insert into XML_DOCUMENT_TABLE values ('Receipt.xml',XMLTYPE(XML_TEXT));
end;
Select Statement
select extractValue(XML_DOCUMENT,'/smsnotification/messageid') Messageid,
extractValue(XML_DOCUMENT,'/smsnotification/status') Status,
extractValue(XML_DOCUMENT,'/smsnotification/carrierid') CarrierID
from XML_DOCUMENT_TABLE; -
Importing the dump into 10g which exported from 11g server
hi
can i import the dump into 10g which exported from 11g server?
thanks
nidhiknidhi wrote:
hi
can i import the dump into 10g which exported from 11g server?
thanks
nidhiHi Nidhi,
No, if you want to use an 11g export dump and import it using 10g utilities to a 10g database.
Yes, if you use 10g export utility to extract 11g database data, and use 10g import utility to import in 10g database.
For more information on export/import compatibility, please check:
http://download.oracle.com/docs/cd/B28359_01/server.111/b28319/exp_imp.htm#
HTH
Regards,
Z.K. -
How to insert data from APEX form into two tables
Hi,
I'm running APEX 4.1 with Oracle XE 11g, having two tables CERTIFICATES and USER_FILES. Some of the (useless) fields are cut to reduce information:
CREATE TABLE CERTIFICATES
CERT_ID NUMBER NOT NULL ,
CERT_OWNER NUMBER NOT NULL ,
CERT_VENDOR NUMBER NOT NULL ,
CERT_NAME VARCHAR2 (128) ,
CERT_FILE NUMBER NOT NULL ,
) TABLESPACE CP_DATA
LOGGING;
ALTER TABLE CERTIFICATES
ADD CONSTRAINT CERTIFICATES_PK PRIMARY KEY ( CERT_ID ) ;
CREATE TABLE USER_FILES
FILE_ID NUMBER NOT NULL ,
FILENAME VARCHAR2 (128) ,
BLOB_CONTENT BLOB ,
MIMETYPE VARCHAR2 (32) ,
LAST_UPDATE_DATE DATE
) TABLESPACE CP_FILES
LOGGING
LOB ( BLOB_CONTENT ) STORE AS SECUREFILE
TABLESPACE CP_FILES
STORAGE (
PCTINCREASE 0
MINEXTENTS 1
MAXEXTENTS UNLIMITED
FREELISTS 1
BUFFER_POOL DEFAULT
RETENTION
ENABLE STORAGE IN ROW
NOCACHE
ALTER TABLE USER_FILES
ADD CONSTRAINT CERT_FILES_PK PRIMARY KEY ( FILE_ID ) ;
ALTER TABLE CERTIFICATES
ADD CONSTRAINT CERTIFICATES_USER_FILES_FK FOREIGN KEY
CERT_FILE
REFERENCES USER_FILES
FILE_ID
NOT DEFERRABLE
What I'm trying to do is to allow users to fill out all the certificate data and upload a file in an APEX form. Once submitted the file should be uploaded in the USER_FILES table and all the fields along with CERT_ID, which is the foreign key pointing to the file in the USER_FILES table to be populated to the CERTIFICATES table. APEX wizard forms are based on one table and I'm unable to build form on both tables.
That's why I've created a view (V_CERT_FILES) on both tables and using INSTEAD OF trigger to insert/update both tables. I've done this before and updating this kind of views works perfect. Here is where the problem comes, if I'm updating the view all the data is updated correctly, but if I'm inserting into the view all the fields are populated at CERTIFICATES table, but for USER_FILES only the fields FILE_ID and LAST_UPDATE_DATE are populated. The rest three regarding the LOB are missing: BLOB_CONTENT, FILENAME, MIMETYPE. There are no errors when running this from APEX, but If I try to insert into the view from SQLDeveloper, I got this error:
ORA-22816: unsupported feature with RETURNING clause
ORA-06512: at line 1
As far as I know RETURNING clause in not supported in INSTEAD of triggers, although I didn't have any RETURNING clauses in my trigger (body is below).
Now the interesting stuff, after long tracing I found why this is happening:
First, insert is executed and the BLOB along with all its properties are uploaded to wwv_flow_file_objects$.
Then the following insert is executed to populate all the fields except the BLOB and it's properties, rowid is RETURNED, but as we know RETURNING clause is not supported in INSTEAD OF triggers, that's why I got error:
PARSE ERROR #1918608720:len=266 dep=3 uid=48 oct=2 lid=48 tim=1324569863593494 err=22816
INSERT INTO "SVE". "V_CERT_FILES" ( "CERT_ID", "CERT_OWNER", "CERT_VENDOR", "CERT_NAME", "BLOB_CONTENT") VALUES (:B1 ,:B2 ,:B3 ,:B4, ,EMPTY_BLOB()) RETURNING ROWID INTO :O0
CLOSE #1918608720:c=0,e=11,dep=3,type=0,tim=1324569863593909
EXEC #1820672032:c=3000,e=3168,p=0,cr=2,cu=4,mis=0,r=0,dep=2,og=1,plh=0,tim=1324569863593969
ERROR #43:err=22816 tim=1324569863593993
CLOSE #1820672032:c=0,e=43,dep=2,type=1,tim=1324569863594167
Next my trigger gets in action, sequences are generated, CERTIFICATES table is populated and then USER_FILES, but only the FILE_ID and LAST_UPDATE_DATE.
Finally update is fired against my view (V_CERT_FILES), reading data from wwv_flow_files it populates BLOB_CONTENT, MIMETYPE and FILENAME fields at the specific rowid in V_CERT_FILES, the one returned from the insert at the beginning. Last, file is deleted from wwv_flow_files.
I'm using sequences for the primary keys, this is only the body of the INSTEAD OF trigger:
select user_files_seq.nextval into l_file_id from dual;
select certificates_seq.nextval into l_cert_id from dual;
insert into user_files (file_id, filename, blob_content, mimetype, last_update_date) values (l_file_id, :n.filename, :n.blob_content, :n.mimetype, sysdate);
insert into certificates (cert_id, cert_owner, cert_vendor, cert_name, cert_file) values (l_cert_id, :n.cert_owner, :n.cert_vendor, :n.cert_name, l_file_id);
I'm surprised that I wasn't able to find a valuable source of information regarding this problem, only MOS note about running SQLoader against view with CLOB column and INSTEAD OF trigger. The solution would be to ran it against base table, MOS ID 795956.1.
Maybe I'm missing something and that's why I decided to share my problem here. So my question is how do you create this kind of architecture, insert into two tables with a relation between them in APEX ? I read a lot in the Internet, some advices were for creating custom form with APEX API, create a custom ARP, create two ARP or create a PL/SQL procedure for handing the DML?
Thanks in advance.
Regards,
SveThank you however I was wondering if there was an example available which uses EJB and persistence.
-
Insert into blob column from form6i
Dear all,
I have a question....
I need to develop an application with form6i which gets the filename and path from user and inserts the content of the file in a table with blob column...
the files may be in any format...How can I do it in oracle form 6i..our database is 10g...
If anybody has a sample please send me :[email protected]
ThanX
FarnazIf you want to insert a string and next convert to BLOB, you use the next SQL
PreparedStatement ps = connectionObject.prepareStatement("INSERT INTO TEST_BLOB(NO,STR) VALUES(?,TO_BLOB(?))");and next
ps.setInt(1, "1");
ps.setString(2,"sample string here"); -
How do i insert into more than one table from temp table?
Hi,
I have three tables such as temp,stck and stol
temp table contains data as below. It has 22 columns.
STOCK STOCKDESC ALIAS1 ALIAS2 ALIAS3 ALIAS4 ALIAS5 ALIAS6 ALIAS7 ALIAS8 ALIAS9 ALIAS10 ALIAS11 ALIAS12 ALIAS13 ALIAS14 ALIAS15 ALIAS16 ALIAS17 ALIAS18 ALIAS19 ALIAS20
bmg667691031 NOWE FINANSE LTD yy zz B282DV3 TESTICKER te te1 bmg667691031BM te 707943W ex IR-PRIME IR-ALTID IR-BLOOM NT-PRIME NT-ALTID NT-BLOOM AU-PRIME AU-ALTID AU-BLOOM mm
AA0098000181 UFACEX HOLDINGS VAR RT DUE 06-30-2010 kk yy mm TESTICKER aa ff AA0098000181GB bb 031969W cc IR-PRIME IR-ALTID IR-BLOOM NT-PRIME NT-ALTID NT-BLOOM AU-PRIME AU-ALTID AU-BLOOM ba
AC1350Z7M923 CDA GOVT TREAS BILLS CDS- 08-05-2010 ee ff gg TESTICKER hh ij AC1350Z7M923CA mn 1A1MTLU op IR-PRIME IR-ALTID IR-BLOOM NT-PRIME NT-ALTID NT-BLOOM AU-PRIME AU-ALTID AU-BLOOM op
stck table contains as below.It has six columns. But always first three columns will have values.
stock_id stock_code stock_description stock_type terriory_code preferred code
1185072 AED
1185073 ARA CURRENCY ARGENTINA PESO
1185074 ATS CURRENCY AUSTRIAN SCHS
stol table contains as below. It has 6 columns.Terriory_code is always empty.
stock_code territory_code stol_type stock_id stck_code_type sys_entry_date
AED 0 1185072 0 6/22/2007 3:59:13.000 PM
ARA 0 1185073 0 6/22/2007 3:59:13.000 PM
ATS 0 1185074 0 6/22/2007 3:59:13.000 PM
Now, i want to insert into stck and stol table based on temp table records. constraints to insert into stck and stol tables are as below
In temp table first column is called stock. This stock has to compare with stck table stock_code. If it is not present in stck table, then it has to insert into stck table with stock_id and stock_description. Here, I need to generate stock_id my self in the code.
In temp table, column 3 to column 22, i have alias. Each column has to check with stol table stock_code column. For instance, column3 check with stock_code column. Then column4 check with stock_code. If stock_code is not present in stol table, then i have to insert into stol table.
I need to generate stock,id in the code. How do i perform this insertion?
Edited by: user12852882 on Jun 12, 2010 2:37 AMIt can be done using SQL (no loops required)
insert into stock_table (stock_id,stock_code,stock_description)
select stock_id,get_stock_code,stockdesc /* get_stock_code is a function providing stock_code - usually a sequence value */
from (select t.stock stock_id,t.stockdesc,s.stock_id stock_stock_id
from temp_table t,stock_table s
where t.stock = s.stock_id(+)
where s.stock_id is null;
insert into stol_table (stock_code,sys_entry_date) /* not clear where other values to be inserted will come from */
select stock_code,sysdate
from (select t.stock_code,s.stock_code stol_stock_code
from (select distinct stock_code
from (select alias1 stock_code from temp_table union all
select alias2 from temp_table union all
select alias3 from temp_table union all
select alias4 from temp_table union all
select alias5 from temp_table union all
select alias6 from temp_table union all
select alias7 from temp_table union all
select alias8 from temp_table union all
select alias9 from temp_table union all
select alias10 from temp_table union all
select alias11 from temp_table union all
select alias12 from temp_table union all
select alias13 from temp_table union all
select alias14 from temp_table union all
select alias15 from temp_table union all
select alias16 from temp_table union all
select alias17 from temp_table union all
select alias18 from temp_table union all
select alias19 from temp_table union all
select alias20 from temp_table
) /* use unpivot instead if you are 11g */
where stock_code is not null
) t,stol_table s
where t.stock_code = s.stock_code(+)
where s.stock_code is null;
and think about damorgan's post, you'll never regret it (especially when you will not just think)
Regards
Etbin
Maybe you are looking for
-
Voice memo screen disappears right after I open it.
Voice memo screen disappears right after I open it. The last voice memos I recorded seem to have disappeared. iPhone 4 iOS 6.1.3
-
How can I remove the forced U2 songs from my iphone without synchronizing?
Hello. I have about 100 songs merely on my iPhone, nowhere else. Apple moved somehow these U2 songs on my iPhone without permission. Now it is like having an undesired cupboard standing in the middle of my living room and I cannot remove it. A synchr
-
Opening files from a Novell-Share takes about ten seconds
Hi there, first a few information about our environment: Windows 7 Enterprise SP1 Clients with Novell Client installed in latest version Windows Server 2008 R2 DCs Network-shares based on Novell Netware When accessing files on Novell-Shares for the f
-
Hi Guys, My environment is wl6.1sp2 and wli 2.1. I am trying to develop a bpm event plugin. I just copied the Event plugin files from the sample plugin and packaged them in my own package structure and am trying to deply this. I am not clear as to wh
-
How to fill the KNBW Customer master record (withholding tax types) in IDOC
Hi experts, The creation of a new customer (intern) with idoc has status 51 with error : No batch input data for screen SAPMF02D 0610. When à use the WE19 transaction, in background step by step, the batch-input stops in withholding tax types. But th