SQL loader : how to populate a calculated feild of a table?
Hi All,
I have a table which has total 92 columns, among them 6 feilds are calculated using few other fields of the same table.
i have a csv file , which has only 86 feilds .
during upload data using sql loader, is it possible to calculate other 6 feilds and upload them along with 86 fields ?
Or any other method to populate the calculated values?
Thanks in advance,
Archana
Hi Archana,
You can have a script file with the required update commands and execute that script after the Loader loads the data to have them updated.
But it is not a good practice to store the calculated values in the fields.
Whenever required you can have them as a calculation in your select statements instead of storing them in the table.
Unfortunately if the base values get changed you would be forced to recalculate and store them if you have them in the table.
Regards,
S.Muthukumar.
Similar Messages
-
How to populate the calculated value into screen field.
I am doing one enhancement in QM.I have added one custom screen to notification transaction ( QM01/QM02/QM03) transaction tab strip control using the enhancement QQMA0001.The Details of the calling and called screens as shown bellow
The Calling screen: SAPLIQS0
Screen Number: 7790
Screen Area :USER0001
Called Screen: SAPLXQQM
Screen Number: 0101
I have developed the Custom Screen in screen 0101 and called in PBO of program SAPLIQS0 7790 screen.
The Screen in calling perfectly .The Custom screen having different fields like Raw cost, Intermediate cost, Finished cost, SCAR Cost and Sales Order Cost Etc... These fields are out put filed types. No input for these screens.. I have few doubts regarding this
How to populate the calculated values in Custom screen?
Where we wrote the code to populate the calculated values in custom screen?
You have any idea please guide me
Thanks & Regards,
SamantulaAs your screen fields should be global variables in SAPLXQQM, you may initialize them by implementing function module EXIT_SAPMIWO0_008 which also belongs to SAPLXQQM (Customer Exit: Transfer Notification Data to User Screen)
-
Sql loader how import a file with save the actual row number in a db field
Hey,
how can i save the row number for each row in a file into a database field i the same table with the sql loader (sqlldr)?
test data:
john doe
joe meier
table:
name surname line_number_in_file
john doe 1
joe meier 2
and so on ... an if an line is discarded because it is empty for example it should be as this:
test data:
john doe
joe meier
table:
name surname line_number_in_file
john doe 1
joe meier 3
thanks for helpinmg and excuse my very bad english :-)
Message was edited by:
user527827but if one of the when clause faild or some rows are
rejectet the sequence is not right.Did you read the link?
"If a record is rejected (that is, it has a format error or causes an Oracle error), the generated sequence numbers are not reshuffled to mask this. If four rows are assigned sequence numbers 10, 12, 14, and 16 in a particular column, and the row with 12 is rejected, the three rows inserted are numbered 10, 14, and 16, not 10, 12, and 14. This allows the sequence of inserts to be preserved despite data errors. When you correct the rejected data and reinsert it, you can manually set the columns to agree with the sequence."
also if you read multiple lines and they inserted in
the wrong order the number from the sequence is not
the line number...what do you mean with "reading multiple lines and wrong order?" -
How can i pass calculated value to internal table
Hi
i have to pass calculated value into internal table
below field are coming from database view and i' m passing view data into iznew1
fields of iznew1
LIFNR LIKE EKKO-LIFNR,
EBELN LIKE EKKO-EBELN,
VGABE LIKE EKBE-VGABE,
EBELP LIKE EKBE-EBELP,
BELNR LIKE EKBE-BELNR,
MATNR LIKE EKPO-MATNR,
TXZ01 LIKE EKPO-TXZ01,
PS_PSP_PNR LIKE EKKN-PS_PSP_PNR,
KOSTL LIKE EKKN-KOSTL,
NAME1 LIKE LFA1-NAME1,
NAME2 LIKE LFA1-NAME2,
WERKS LIKE EKPO-WERKS,
NETWR LIKE EKPO-NETWR,
KNUMV LIKE EKKO-KNUMV,
GJAHR LIKE EKBE-GJAHR,
and now i want to pass
one field ED1 which i has calculated separatly and i want to pass this value into iznew1
but error is coming that iznew1 is a table with out header line has no component like ED1.
so how can i pass calculated value to internal table iznew1,When you declare your internal table , make an addtion occurs 0
eg . data : begin of iznew occurs 0 ,
fields ...
add the field here ed1.
end of iznew.
now when you are calculating the value of ed1,
you can pass the corresponding value of ed1 and modify table iznew.
eg
loop at iznew.
iznew-ed1 = ed1.
modify iznew.
endloop. -
SQL*Loader - How to combine 2 controlfiles to one controlfile
I have several controllfiles which each import another table from another datafile, because I don't want execute every seperat or create a batch file.... I'm looking for a way to put they all in one single controlfile.
example:
1st ctl-file:
LOAD DATA
INFILE "t1.dat"
INTO TABLE t1 REPLACE
FIELDS TERMINATED BY " "
(c1,
c2 "to_number(:c2,'99999999999999999.99999999999999999','NLS_NUMERIC_CHARACTERS=''.,''')",
c3 date 'YYYY-MM-DD"T"HH24:MI:SS')
gQuqT 478.60636734965914 2006-12-05T11:00:49
ÜgQK 963.0277916962095 2006-12-30T08:03:00
üZfxN 465.15226622488257 2006-12-30T09:14:12
2nd ctl-file:
LOAD DATA
INFILE "t2.dat"
INTO TABLE t2 REPLACE
FIELDS TERMINATED BY " "
(c1,
c2 "to_number(:c2,'99999999999999999.99999999999999999','NLS_NUMERIC_CHARACTERS=''.,''')")
alvwxs 13.0
poeh 15.0
zpgiht 21.0
At the examples is everytime used a id column, to ident which row should import in which table.
But at my case i need something like a where condition from which file the data should be imported....how should it look?
Can someone give me an advice how a controlfile should look which import both tables in one controlfile?
BR
rolandIt is not possible to combine the last 3 columns as those columns are seperated by commas and in the SQL Loader control file you must ve specified COMMA as an delimiter. So u better have all the columns in the table plus add one more column which holds the concatenation of the 3 columns.
Vijay -
SQL*Loader: How to load multi-line report data?
Hi,
is it possible to use SQL*Loader to load data from a hierarchical structured fixed column ASCII file like this
001 scott
New York 01.01.2002 1234
Chicago 15.10.2001 9876
002 smith
Los Angeles 24.12.1999 5678
Washington 01.12.1999 0000
Chicago 01.01.2000 1111
into one database table:
id name city day code
001 scott New York 01.01.2002 1234
001 scott Chicago 15.10.2001 9876
002 smith Los Angeles 24.12.1999 5678
002 smith Washington 01.12.1999 0000
002 smith Chicago 01.01.2000 1111
The number of lines per name is unlimited, the next line starts after a separating ---- line.
We cannot change the format of the text file to import.
There is an example in the documentation that shows how to load a structure like the following via insert triggers:
001 scott New York 01.01.2002 1234
Chicago 15.10.2001 9876
002 smith Los Angeles 24.12.1999 5678
Washington 01.12.1999 0000
Chicago 01.01.2000 1111
But we have the name information on a separate header line, so I don't know if we can use a similar technique here.
regards
SvenTry enclosing your strings with e.g. a double-quote. To do so, the control file needs the following (example):
LOAD DATA
REPLACE
INTO TABLE test
FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
id1,
id2,
id3,
id4,
)of course this does mean that your data must change...
L. -
SQL*LOADER how to load blanks when data is null
I need to load data which contains null values into a table which cannot contains nulls. How can I tell SQL*LOADER to load blanks in a column when the input data is nulls?
I think something like this in your control file should work:
col1 char(10) nvl(col1,' ') -
SQL*Loader - How to load only a few columns from a .csv file to ora table
Hi there,
Could anyone please let me know how to load few columns from a .csv
file into a oracle table using SQL*Loader.
I know how to create a .dat and .ctl file and run the sql loader.
Suppose I have a .csv file with
col1, col2, col3, col4
and I only need to load col1 and col3 into col_a and col_b respectively
in table_a?
structure of table_ a
col_a,
col_b
Please adviceTry like..it i will work..
LOAD DATA
INFILE 'test.txt'
LOAD DATA
TRUNCATE INTO TABLE T1
FIELDS TERMINATED BY ','
(col1,
col2 FILLER,
col3,
col4 FILLER
) -
SQL Loader-How to insert -ve & date values from flat text file into coloumn
Question: How to insert -ve & date values from flat text file into coloumns in a table.
Explanation: In the text file, the negative values are like -10201.30 or 15317.10- and the date values are as DDMMYYYY (like 10052001 for 10th May, 2002).
How to load such values in columns of database using SQL Loader?
Please guide.Question: How to insert -ve & date values from flat text file into coloumns in a table.
Explanation: In the text file, the negative values are like -10201.30 or 15317.10- and the date values are as DDMMYYYY (like 10052001 for 10th May, 2002).
How to load such values in columns of database using SQL Loader?
Please guide. Try something like
someDate DATE 'DDMMYYYY'
someNumber1 "TO_NUMBER ('s99999999.00')"
someNumber2 "TO_NUMBER ('99999999.00s')"Good luck,
Eric Kamradt -
SQL Loader (how to cut data header)
Hi there,
[oracle 11g]
I got the following text file:
mod; DD.MM.YYYY; HH:MM:SS; aligned
src; "ptv "; "15.04.2012"; "10:47:49"
chs; "ISO8859-1"
ver; "V1.0"
ifv; "V1.0"
dve; "V1.0"
fft; "LIO"
tbl; MENGE_FGR
atr; BASIS_VERSION; FGR_NR; FGR_TEXT
frm; num[9.0]; num[5.0]; char[40]
rec; 122; 8; "VVZ"
rec; 123; 18; "VHZ"
rec; 124; 13; "VTZ" Now I am interested in the column TBL and ATR and follwing rawdata
Do you see a way to automatically create the table MENGE_FR with columns BASIS_VERSION; FGR_NR;FGR_TEST and column types num, num, char and insert the raw data below?
PS:OK, this is mysql ...so I need to convert this first to sql. So you should see num as number.
Thx in advance Thorsten
Edited by: Thorsten on 16.05.2013 07:30
Edited by: Thorsten on 16.05.2013 07:32There are various ways that you could do this. I have demonstrated one method below. I created a table with two columns, then used SQL*Loader to load the data from the text file into those two columns. Skipping the header rows is optional. You could also use an external table instead, if the text file is on your server, not your client. I then used some PL/SQL to create and execute "create table" and "insert" statements. This is just some starter code. You will need to make modifications to handle other data types and such that were not in the example that you provided, but it should give you the general idea.
SCOTT@orcl_11gR2> host type text_file.dat
mod; DD.MM.YYYY; HH:MM:SS; aligned
src; "ptv "; "15.04.2012"; "10:47:49"
chs; "ISO8859-1"
ver; "V1.0"
ifv; "V1.0"
dve; "V1.0"
fft; "LIO"
tbl; MENGE_FGR
atr; BASIS_VERSION; FGR_NR; FGR_TEXT
frm; num[9.0]; num[5.0]; char[40]
rec; 122; 8; "VVZ"
rec; 123; 18; "VHZ"
rec; 124; 13; "VTZ"
SCOTT@orcl_11gR2> host type test.ctl
options(skip=7)
load data
infile text_file.dat
into table tbl
(col1 terminated by ';',
col2 terminated by x'0a')
SCOTT@orcl_11gR2> create table tbl
2 (col1 varchar2(4),
3 col2 varchar2(60))
4 /
Table created.
SCOTT@orcl_11gR2> host sqlldr scott/tiger control=test.ctl log=test.log
SQL*Loader: Release 11.2.0.1.0 - Production on Thu May 16 13:44:24 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Commit point reached - logical record count 6
SCOTT@orcl_11gR2> select * from tbl
2 /
COL1 COL2
tbl MENGE_FGR
atr BASIS_VERSION; FGR_NR; FGR_TEXT
frm num[9.0]; num[5.0]; char[40]
rec 122; 8; "VVZ"
rec 123; 18; "VHZ"
rec 124; 13; "VTZ"
6 rows selected.
SCOTT@orcl_11gR2> declare
2 v_tab varchar2(30);
3 v_atr varchar2(32767);
4 v_frm varchar2(32767);
5 v_sql varchar2(32767);
6 v_cols number;
7 v_next varchar2(32767);
8 begin
9 select col2 into v_tab from tbl where col1 = 'tbl';
10 select col2 || ';' into v_atr from tbl where col1 = 'atr';
11 select col2 || ';' into v_frm from tbl where col1 = 'frm';
12 v_sql := 'CREATE TABLE ' || v_tab || ' (';
13 select regexp_count (col2, ';') + 1 into v_cols from tbl where col1 = 'atr';
14 for i in 1 .. v_cols loop
15 v_sql := v_sql || substr (v_atr, 1, instr (v_atr, ';') - 1) || ' ';
16 v_next := substr (v_frm, 1, instr (v_frm, ';') - 1);
17 v_next := replace (v_next, '[', '(');
18 v_next := replace (v_next, ']', ')');
19 v_next := replace (v_next, '.', ',');
20 v_next := replace (v_next, 'num', 'number');
21 v_next := replace (v_next, 'char', 'varchar2');
22 v_sql := v_sql || v_next || ',';
23 v_atr := substr (v_atr, instr (v_atr, ';') + 1);
24 v_frm := substr (v_frm, instr (v_frm, ';') + 1);
25 end loop;
26 v_sql := rtrim (v_sql, ',') || ')';
27 dbms_output.put_line (v_sql);
28 execute immediate v_sql;
29 for r in (select col2 from tbl where col1 = 'rec') loop
30 v_sql := 'INSERT INTO ' || v_tab || ' VALUES (''';
31 v_sql := v_sql || replace (replace (r.col2, ';', ''','''), '"', '');
32 v_sql := v_sql || ''')';
33 dbms_output.put_line (v_sql);
34 execute immediate v_sql;
35 end loop;
36 end;
37 /
CREATE TABLE MENGE_FGR ( BASIS_VERSION number(9,0), FGR_NR number(5,0),
FGR_TEXT varchar2(40))
INSERT INTO MENGE_FGR VALUES (' 122',' 8',' VVZ')
INSERT INTO MENGE_FGR VALUES (' 123',' 18',' VHZ')
INSERT INTO MENGE_FGR VALUES (' 124',' 13',' VTZ')
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> describe menge_fgr
Name Null? Type
BASIS_VERSION NUMBER(9)
FGR_NR NUMBER(5)
FGR_TEXT VARCHAR2(40)
SCOTT@orcl_11gR2> select * from menge_fgr
2 /
BASIS_VERSION FGR_NR FGR_TEXT
122 8 VVZ
123 18 VHZ
124 13 VTZ
3 rows selected. -
SQL LOADER: how to load CLOB column using stored function
Hi,
I am a newbie of sql loader. Everything seems to be fine until I hit a
road block - the CLOB column type. I want to load data into the clob
column using a stored function. I need to do some manipulation on the
data before it gets saved to that column. But I got this error when I
run the sql loader.
SQL*Loader-309: No SQL string allowed as part of "DATA" field
specification
DATA is my CLOB type column.
here is the content of the control file:
LOAD DATA
INFILE 'test.csv'
BADFILE 'test.bad'
DISCARDFILE 'test.dsc'
REPLACE
INTO TABLE test_table
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
codeid BOUNDFILLER,
reason BOUNDFILLER,
Checkstamp "to_date(:CHECKSTAMP, 'mm/dd/yyyy')",
"DATA" "GetContent(:codeid, :reason)"
All references are suggesting to use a file to load data on
CLOB column but I want to use a function in which it generates
the content to be saved into the column.
Any help is greatly appreciated.
Thanks,
Baldwin
MISICompany*** Duplicate Post ... Please Ignore ***
-
Sql loader, how to get decimals into the database?
oracle 10.2
we have data of the form
1.10
1.11
we are using "decimal external" in the control file.
The table is a straight number field
I did a test where I created a table with a number field and without and precision and did regular inserts. I got the decimal values.
so I did
create table x (y number);
insert into x values (1.10);
insert into x values (1.11);
and i got back
1.1
1.11
when we sql load we get
1
1Why use decimal external then? What's wrong with leaving the field as number?
-
SQL*Loader: How to use Sequence and REF together?
Hi,
I'm getting the following error:
SQL*Loader-418: Bad datafile datatype for column AREA_ID.
I attempt to upload one datafile into 4 different tables.
When executing sqlldr scott/tiger control=sqlldr_aj_new.ctl
1) Here is my Control file (sqlldr_aj_new.ctl):
load data
infile 'TST_MAIN_NEW.csv'
-- Loads table "TST_AREAS"
into table TST_AREAS
REPLACE
FIELDS TERMINATED by ','
(AREA_ID SEQUENCE,
AREA_NAME,
PRODUCT_ID,
PRIORITY_ID,
PLAN_ID,
CREATED_BY_ID,
AREA_DESC)
-- Loads table "TST_TEMPLATE_SCENS"
into table TST_TEMPLATE_SCENS
REPLACE
FIELDS TERMINATED by ','
(TEMPLATE_SCEN_ID SEQUENCE,
SCENARIO_NAME,
MODIFIED_BY_ID,
SCEN_TYPE_ID,
OWNER_ID,
PRIORITY_ID,
SCOPE_ID,
SCENARIO_DESC,
AREA_ID REF(CONSTANT 'TST_AREAS', AREA_ID))
2) Here is my data file(TST_MAIN_NEW.csv)
B/S,105,1,plan_id_1,2222,area_desc1,CCEMC_PR_001,1111,1,2222,2,1,scenario_desc_1
B/S,105,1,plan_id_2,2222,area_desc2,CCEMC_PR_002,1111,2,2222,2,2,scenario_desc_2
3) Here are the tables:
TST_AREAS
Name Null? Type
AREA_ID NOT NULL NUMBER(35)
AREA_NAME CHAR(64)
PRODUCT_ID NUMBER(35)
PRIORITY_ID NUMBER(35)
PLAN_ID NUMBER(35)
CREATED_BY_ID NUMBER(35)
AREA_DESC CHAR(1000)
TST_TEMPLATE_SCENS
Name Null? Type
TEMPLATE_SCEN_ID NOT NULL NUMBER(35)
SCENARIO_NAME CHAR(500)
MODIFIED_BY_ID NUMBER(35)
SCEN_TYPE_ID NUMBER(35)
OWNER_ID NUMBER(35)
PRIORITY_ID NUMBER(35)
SCOPE_ID NUMBER(35)
SCENARIO_DESC CHAR(1000)
AREA_ID NOT NULL NUMBER(35)
Please advise what is the reason for an error.
Thank you very much!
AndreyI don't think so.
SQL> create table t (
2 rowid number);
rowid number)
ERROR at line 2:
ORA-00904: : invalid identifierPlease post your version number and the DDL for the table.
Best practice in Oracle is to NEVER, EVER, store a ROWID: They can change.
After you have solved the first problem, that you've never actually built the table, the solution to the sequence use is to make the call in your DML.
INSERT INTO t (testcol) VALUES (<sequence_name>.NEXTVAL); -
SQL Loader: How to load binary files
Hi All,
I need to load a binary file into the database (BLOB) using SQL Loader. What I have are only two files. The first file is an attributes file that contains the file names, the file sizes, the file descriptions, etc. The second file is a binary file that contains ALL the files described in the attributes file. They are concatenated in the same order that the attributes file names them.
This data load is different from any other that I've encountered before because I am familiar with loads that have separate files.
I'm sorry if this is not the right board to post this question, but I'd greatly appreciate any help.
Regards,
mike sixCheck out following link. It might be of help.
http://www.oracle-base.com/forums/viewtopic.php?p=7680 -
SQL*Loader - How to combine Flat File 3 columns and put into one single column
Receive a flat file delimited by comma. Want to combine Flat File last 3 columns and put into one single column(Table).
e.g.
Flat File
100,239,30,20,30
While inserting into table want to combine last 3 columns and insert into invoice number column.
302030It is not possible to combine the last 3 columns as those columns are seperated by commas and in the SQL Loader control file you must ve specified COMMA as an delimiter. So u better have all the columns in the table plus add one more column which holds the concatenation of the 3 columns.
Vijay
Maybe you are looking for
-
Mail keeps crashing not sure what else to do now...
First of all, sorry for such a long post... but... PLEASE HELP ME..... A little over a week ago Mail started crashing every time i opened an email. If i click on an email what it does is open the email in the viewing pain and then i get the pinwheel.
-
In previous versions I have been able to drag the icon from the address bar to a Windows folder, producing a clickable link in that folder. I even have FAQ and Help files on various web sites advising people to do that as it is very useful to have li
-
External LG drive not showing up on my mac mini
I have a mini and bought an external LG dvd writer but it will not show up on desktop. Its mac compatible but not being recognized. Is there something I doing wrong?
-
I cannot get the accordion load event to fire when I have created the accordion and load event using actionscript . Here is some sample code: createClassObject(mx.containers.Accordion, "acc", getNextHighestDepth()); acc.createSegment(mx.containers.Sc
-
USERNAME(Login ID) on the base of PERNR (Employee Number)
Hi SAP Minds, I've Selected Employees in the GET PERAS Event. Now I want to provide them the authorization for some roles, to serve that purpose I need thier USERNAME(Login ID) , which i'can provide in SU01 to access his profile information as well t