SQL Loader - adding column values
Hi everybody,
Is it possible to have a column value in SQL Loader control file that is a function of two other columns. For example I have table of 3 columns c1, c2, c3
and data file is having c1, c2 and I want to specify c3 as c1+c2 in the control file, so that it's populated in the table while loading data file. I tried this on date column but it gave me error ora-00981.
Can you tell me exact sysntax if possible.
LOAD DATA
INFILE 'C:\SQLLOADER\AREA.TXT'
APPEND INTO TABLE AREA
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
(c1,
c2,
c3 ":c2+:c1"
kuljeet pal singh
Similar Messages
-
Error: SQL Loader-466 column not exist ???
dear all.
i have a problem with sql loader.
The error is:
SQL*Loader-466: Column NUM_PAQ does not exist in table PLANELEC.file
i saw desc table:
SQL> DESC PLANELEC.file
Nombre ¿Nulo? Tipo
num_paq NOT NULL CHAR(8)
formulario NOT NULL CHAR(4)
norden NOT NULL NUMBER(38)
cod_docide_dec NOT NULL NUMBER(38)
num_docide_dec NOT NULL VARCHAR2(11)
num_correl_a NOT NULL NUMBER(38)
cod_docide_aseg NOT NULL NUMBER(38)
num_docide_aseg NOT NULL VARCHAR2(15)
cod_cat_tra NOT NULL NUMBER(38)
cod_tipo NOT NULL NUMBER(38)
fec_ini_perlab NOT NULL DATE
fec_fin_perlab DATE
cod_extincion CHAR(2)
ind_envio NUMBER(38)
fec_envio DATE
num_ctl CHAR(6)
my ctl file is:
Load DATA
INFILE file.UNL
INSERT
INTO TABLE PLANELEC.file
fields terminated by '|'
TRAILING NULLCOLS
NUM_PAQ,FORMULARIO,NORDEN,COD_DOCIDE_DEC,NUM_DOCIDE_DEC,NUM_CORREL_A,COD_DOCIDE_ASEG,
NUM_DOCIDE_ASEG,COD_CAT_TRA,COD_TIPO,FEC_INI_PERLAB,FEC_FIN_PERLAB,COD_EXTINCION,
IND_ENVIO,FEC_ENVIO,NUM_CTL
and the first line of the file.unl is:
00000000|0601|2000043|6|20100066603|1|1|90000001|1|20|01/02/2002|||0||613954|
what could be the problem with that?
thanks a lot !
cesar
ORACLE 10GR2
RHEL AS V4.0Hi ThinkingEye,
Please check the definition of the control file. Did you for instance inclose the file name in quotes?
That's usually the reason for the 466 error with SQL*Loader.
Also check column definitions and column formats that are in the definition.
Cheers, Patrick
ps Is this thread related to the other 2 you have with the same target table STG_GEM_EVENT_ITS? -
Sql Loader INFILE name value in table column Value
Hi,
Here is my Sql Loader Script
LOAD DATA
infile '%1'
APPEND INTO TABLE XX_SUPPLIER_UPD
FIELDS TERMINATED BY ";" OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS
ACTION Char
,ADDRESS_TYPE Char
,REGION Char "LTRIM(RTRIM(:REGION))"
,PO_BOX Char
,,WWW_ADDRESS Char
,status Char "NVL(:status,'X')"
,filename Char "replace(:infile,'\"','')"
I am getting the infile name as the parameter and i want to insert that parameter value in the column name fillename. Can any one guide me to how to do.
Cheers!
Jayaraj.SIf you were to use external tables instead of SQL*Loader, you can dynamically change the location of the external table (i.e. the filename) using a simple ALTER TABLE statement.
External tables also mean that all the control is inside the database rather than relying on external utilities and external scripts.
;) -
SQL*Loader and timestamp values
I'm loading timestamp values (among other data) from a text file into Oracle using SQL*Loader.
The data I load is formatted like the following:
2008/11/13 23:55:21.366
2008/11/13 23:55:22.782
2008/11/13 23:55:25.879
Hence my control file look like this:
TSTAMP TIMESTAMP "YYYY/MM/DD HH24:MI:SS.FF",
The timestamp data in the input file are in UTC, however I load into a column that is of type "TIMESTAMP(3)", i.e. in server time. This is on purpose. I do not want the data to be in UTC when I look at them.
Therefore after the load I have to manually do
UPDATE mytable
SET tstamp = tstamp + (tstamp - sys_extract_utc(tstamp));
This update-after-loading actually takes quite some time due to the amount of records. I would like to avoid it and instead do it as part of the load. Is this possible somehow?
I'm on Oracle 10.2.
Thanks.Hi
What about setting a special Time Zone in your database?
You have two options when setting which time zone the database belongs to. You can either qualify it as a displacement from GMT/UTC in the format of 'hh:mm' or you can specify it as a name that has an entry in the V$TIMEZONE table.
select tzname,tzabbrev from V$TIMEZONE_NAMES;
select DBTIMEZONE from dual;
ALTER database SET TIME_ZONE = 'Denmark/Copenhagen';
select SESSIONTIMEZONE from dual;
select CURRENT_TIMESTAMP from dual;
See that link
http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/create.htm#sthref319
Edited by: Hub on Dec 7, 2008 3:58 PM -
SQL LOADER. Numeric values loaded as Varchar2 characters
Dear all,
please I need your help in this little problem . I am loading using SQL Loader a data file where a field X has a numeric value, and in the Control file it is defined as numeric value as well in the database table but the strange thing is that its values are loaded with the character "E15" at the end of each value.
The data files are extacted from AS400 , cobol system and loaded using SQL LOADER in he Oracle database 10g.
What could be the reason?
I appreciate your help very much , regardsWe can not guess as to what you data looks like nor can we guess as to what your control file indicates.
Post sufficient information for someone to help you.
PS: 10g is not a database version ... post the operating system and version information too:
SELECT * FROM v$version; -
Please Help - SQL Report long column value required in a separate cell
Hi.
I need to create a SQL report with the structure like below:
Country State City Vertical Business Details (detail desc)
US MA Quincy Healthcare
This is a detail desc value that needs to displayed in a different cell.
This is a detail desc value that needs to displayed in a different cell.
This is a detail desc value that needs to displayed in a different cell.
This is a detail desc value that needs to displayed in a different cell.
US MA Braintree IT
This is a detail desc value that needs to displayed in a different cell.
This is a detail desc value that needs to displayed in a different cell.
This is a detail desc value that needs to displayed in a different cell.
I came through a solution where you can hide/display the long column value in a different cell. But my requirement is that it should be displayed when the page opens and user don;t want to click on a button to see the value. This is mainly for their presentations and printing. so its very annoying for them to click on so many buttons to see the detail desc value for every record. I am new to Java script, Please helpI'm not sure I understand your requirements--are you showing us 2 lines of data, 7 lines, or 9? Do you want the long detail description on the same row, or underneath it?
I'm going to go on the assumption that you're showing us two rows, and that the long descriptions in this example happen to be 3-4 lines long, and that you want the long descriptions underneath the details. In which case, I suggest using "named column" templates. They're a lot easier to use than they appear when you first look at them, so bear with me.
Under "Shared Components", select "Templates", and then click on the yellow Create> button. You're creating a report template, from scratch. On the final page of the wizard, select "Named Column (row template)" for the template type. This will create a rather generic (and useless) template, which you'll have to edit; I don't know why they chose to not send you straight into the editor. When you edit it, you'll see that the only field with a value in it is "Row Template 1", and it's set to:
<tr><td>#1#</td><td>#2#</td><td>#3#</td><td>#4#</td><td>#5#</td></tr>For meeting your requirements with basic functionality, change it to something along the lines of:
<tr><td>#COUNTRY#</td><td>#STATE#</td><td>#CITY#</td><td>#VERT#</td></tr>
<tr><td colspan="4">#DETAILS#</td></tr>Then you'll probably want to put something under Column Heading Template, like:
<tr><td>Country</td><td>State</td><td>City</td><td>Vertical Business</td></tr>
<tr><td colspan="4">Details</td></tr>Apply whatever CSS styles you want to it, of course.
Using the template is straightforward: if your report, chose the template, and make sure your SQL returns values using the column names you specified in your template. Otherwise, you'll see literal "#COUNTRY#" text in your report.
You can get fancy with these, of course, such as applying different styles to alternating rows, but I'll leave this as good enough to get you started (I hope).
-David -
SQL*Loader - Skipping columns in the source file.
Hi
I have a comma delimted source file with 4 columns. I however only want to load columns 2 and 3 into my table using SQL*Loader. This seems like something that should be fairly simple but I can't seem to find any doc or examples of this.
Any guidance would be appreciated.
Thanks
DaveHello Dave,
Here is a sample of what you'll need to have in your control fileLOAD DATA
APPEND
INTO TABLE <target_table>
FIELDS TERMINATED BY ','
( column_1 FILLER
, column_2
, column_3
, column_4 FILLER
)Hope this helps,
Luke -
Hallo,
I have the following problem. I have 2 tables which I created the following way:
CREATE TYPE gemark_schluessel_t AS OBJECT(
gemark_id NUMBER(8),
gemark_schl NUMBER(4),
gemark_name VARCHAR2(45)
CREATE TABLE gemark_schluessel_tab OF gemark_schluessel_t(
constraint pk_gemark PRIMARY KEY(gemark_id)
CREATE TYPE flurstueck_t AS OBJECT(
flst_id NUMBER(8),
flst_nr_zaehler NUMBER(4),
flst_nr_nenner NUMBER(4),
zusatz VARCHAR2(2),
flur_nr NUMBER(2),
gemark_schluessel REF gemark_schluessel_t,
flaeche SDO_GEOMETRY
CREATE TABLE flurstuecke_tab OF flurstueck_t(
constraint pk_flst PRIMARY KEY(flst_id),
constraint uq_flst UNIQUE(flst_nr_zaehler,flst_nr_nenner,zusatz,flur_nr),
flst_nr_zaehler NOT NULL,
flur_nr NOT NULL,
gemark_schluessel REFERENCES gemark_schluessel_tab
Now I have data in the gemark_schluessel_tab which looks like this (a sample):
1 101 Borna
2 102 Draisdorf
Now I wanna load data in my flurstuecke_tab with SQL*Loader and there I have problems with my ref column gemark_schluessel.
One data record looks like this in my file (it is without geometry)
1|97|7||1|1|
If I wanna load my data record, it does not work. The reference (the system generated OID) should be taken from gemark_schluessel_tab.
LOAD DATA
INFILE *
TRUNCATE
CONTINUEIF NEXT(1:1) = '#'
INTO TABLE FLURSTUECKE_TAB
FIELDS TERMINATED BY '|'
TRAILING NULLCOLS (
flst_id,
flst_nr_zaehler,
flst_nr_nenner,
zusatz,
flur_nr,
gemark_schluessel REF(CONSTANT 'GEMARK_SCHLUESSEL_TAB',GEMARK_ID),
gemark_id FILLER
BEGINDATA
1|97|7||1|1|
Is there a error I made?
Thanks in advance
TigI am sure, on rereading the OPs email, you will see a disconnect between what was written and your response.
The maximum size of a VARCHAR2 columns is always 4000 bytes. The maximum size of a VARCHAR2 PL/SQL variable is always 32K bytes.
If someone is trying to load the text from an email that may exceed 4K into a table they must use a CLOB column if they wish it to be searchable as text. -
SQL Loader for Enclosed values.
i have a data file having '|' seperated values:
|1|ABC|XYZ||123|891|11|8|9|WELL|
all values are enclosed in |. some values can be null.
the control file looks like,
LOAD DATA
INFILE contact.dat
append INTO TABLE Contact
FIELDS TERMINATED BY '|'
ADDRESSID,
FNAME,
LNAME,
NOTES,
PHONENUM,
PHONEEXT,
CONTACTINT,
RESPCODE,
SEQNUMBER,
TITLE
this script is not inserting any values in table. kindly help!looks fine on 10.2.0.1
SQL> create table contact (
2 addressid varchar2(10)
3 ,fname varchar2(10)
4 ,lname varchar2(10)
5 ,notes varchar2(10)
6 ,phonenum varchar2(10)
7 ,phoneext varchar2(10)
8 ,contactint varchar2(10)
9 ,respcode varchar2(10)
10 ,seqnumber varchar2(10)
11 ,title varchar2(10)
12 )
13 /
Table created.
SQL> !sqlldr test/test control=contact.ctl
SQL> select * from contact;
ADDRE FNAME LNAME NOTES PHONENUM PHONEEXT CONTACTINT RESPCODE SEQNUMBER TITLE
1 ABC XYZ 123 891 11 8 9
SQL> spool off;What about a contact.log file, is there any reason specified why no rows were inserted?
Perhaps you are trying to insert a character into column where number is expected.
Ants -
SQL Developer - Pulling column value from previous row
I am using Oracle SQL developer and trying to pull a value from a column from the previous row.
Currently this is an example from the code im using.
Select CD1.nbr_dw, CD1.SEQ_DW, CD1.CDL_NET_PAID, CD1.UNITS_ALLOW,CD1.ALLOW_AMT, CD1.UNIT_PRICE, CD1.BACKED_OUT,
case
When CD1.NET_PAID = 0 then 0
****NEW CODE*****
Else CD1.ALLOW_AMT / CD1.UNIT_PRICE
end as NEW_UNITS
From Table_A CD1
join (Select nbr_dw, DET_DW, SEQ_DW
From Table_B
) CD2
on CD1.nbr_dw = CD2.nbr_dw
I need to add another when statement that says when CD1.BACKED_OUT = 'Y' populated the NEW_UNITS field with the previous rows value of CD1.UNIT_PRICE. Note, the CD1.SEQ_DW can be used to determine the previous row. Any ideas?Hi,
Welcome to the forum!
The analytic LAG function can return a value from the previous row:
LAG (cd1.unit_price) OVER ( -- PARTITION BY x -- if needed
ORDER BY cd1.seq_dw
)It's unclear if you need a PARTITION BY clause or not.
"PARTITION BY x" means that you want the value from the last row that has the same value of x as the current row.
If you omit the PARTITION BY clause, it means you want the last row regardless of what any other columns are.
Whenever you have a problem, it ehlps if you post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data.
Explain how you get those results from that data.
Always say what version of Oracle you're using. -
Hi all,
I have a requirement which looks like below.
my table looks like this.
id value
1 6
2 10
3 14
4 8
5 9
6 20
now i need output in the below format.
id value
1 6
2 16
3 30
4 38
5 47
6 67
please help.The analytic SUM function will fo that. Somethign like:
SQL > with t as (
2 select 1 id, 6 value from dual union all
3 select 2, 10 from dual union all
4 select 3, 14 from dual union all
5 select 4, 8 from dual union all
6 select 5, 9 from dual union all
7 select 6, 20 from dual)
8 select id, sum(value) over(order by id) running_sum
9 from t;
ID RUNNING_SUM
1 6
2 16
3 30
4 38
5 47
6 67John -
Adding column values in query designer
Hi,
I have requirement to add value in query designer the values should look like this
Column A Column B
10 10
20 30
30 60
40 100
the first values of column B will be same as Column A 10. The second value of column B = column A 1st value +Column A second value similarly Third value of column B = 1st + 2nd + 3rd values of column a. So on and so forth
Any help will be highly appriciated.
Regards,
rayHi
Just create the formula and go to the properties of that formula and go to the calculattion tab and in the "CALCULATE SINGLE VALUE AS " select the option the additive ( not sure but once check that will perform additive operation plz once check it) and select the cumulative check box.
I think u can get it , because in one of my project i did that calculation.
Hope u got it,
Thanx & Regards,
RaviChandra -
SQL Loader, concatenating columns
Is it possible to concatenate several columns in a comma-delimited input file into one column in the database.
For example:
INPUT FILE:
1234,Description 1,Description2
DATABASE FILE (has 2 columns)
1.
Product Number (to be populated from '1234' in the input file)
2.
Description (to be populated from 'Description 1 Description 2' in the input file)
Please let me know how to do this. I was trying column object but it doesn't work.reference23 position(183:183) CHAR,
SOURCE position(183:194) CHAR NULLIF SOURCE=BLANKS,If you see the position for source column it should be 184 and not 183. I think it is a typo or you missed to spot it or I could be wrong. Just a thought
Regards
Raj
Message was edited by:
s.rajaram -
How to load date column using sql loader
Hi,
I am trying to load a file using sql loader. my date value in the file is '2/24/2009 8:23:05 pm',
In control file for this column i specified like this
rec_date date ''mm/dd/yyyy hh:mi:ss pm"
But i am getting following error
not avalid month.
Thanks
sudheerHi,
Use this example as reference:
CTL file:
LOAD DATA
INFILE 'test.txt'
BADFILE 'test.bad'
truncate INTO TABLE T3
FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '|' TRAILING NULLCOLS
dt_date DATE "mm/dd/yyyy hh:mi:ss pm")DAT file:
2/24/2009 8:23:05 pm
C:\ext_files>sqlldr hr/hr control=test.ctl
SQL*Loader: Release 10.2.0.1.0 - Production on Wed Jul 1 20:35:35 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Commit point reached - logical record count 1
Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
Connected as hr
SQL> desc t3;
Name Type Nullable Default Comments
DT_DATE DATE Y
SQL> select to_char(dt_date, 'mm/dd/yyyy hh24:mi:ss') from t3;
TO_CHAR(DT_DATE,'MM/DD/YYYYHH2
02/24/2009 20:23:05
SQL> Regards,
Edited by: Walter Fernández on Jul 1, 2009 8:35 PM - Adding example...
Edited by: Walter Fernández on Jul 1, 2009 8:38 PM
Edited by: Walter Fernández on Jul 1, 2009 8:41 PM - Fixing some information... -
제품 : ORACLE SERVER
작성날짜 : 2002-04-25
Advanced SQL*LOADER
====================
PURPOSE
Q&A를 통한 SQL*LOADER 사용 방법에 대해 알아보도록 한다.
Explanation
1) Carriage returns, linefeeds, EOL character를 load 하는 방법
2) Delimiter 를 사용한 경우 특정 field 를 skip 할수 있나?
3) "FIELD IN DATA FILE EXCEEDED MAXIMUM SPECIFIED LENGTH" 메세지
해결 방법
4) Blob 이나 raw data 는 어떻게 사용하나?
5) Error LDR-510은 어떻게 처리하나?
6) EBCDIC Characterset data file 은 어떻게 load 하나?
7) Control file 에 WE8EBCDIC500 characterset 을 사용하였는데도
SQL*Loader-266 가 발생하는 경우
8) Decimal data는 어떻게 load 하는가?
9) Trailing signs 이 있는 숫자는 어떻게 load 하는가?
10) Zoned number는 무엇인가?
11) Packed Decimal Number는 무엇인가?
12) NULLIF 는 어떻게 사용하나 ?
13) 한개의 single column을 위해 여러 개의 nullif는 사용가능한가?
14) SQL*Loader 가 NULL 로 여기는 column 을 blank space 로
여기도록 만들려면 ?
15) WHEN 절은 어떻게 사용하나?
16) WHEN 절에 OR 를 사용할수 있는가?
17) Delimiter 로 ','를 사용하였는데 data 에 ','가 포함된 경우는?
18) 어떻게 하면 commit 을 덜 사용할 수 있나?
1) carriage returns, linefeeds, EOL character를 load 하기
SQL*Loader 는 이들을 통해 서로 다른 physical record 로 인식한다.
이들을 load 하기 위해 사용되는 option 은
- concatenate
- continueif
- file processing option: FIX (PRE: 1012555.6 PRS: 2060647.6)
- file processing option: VAR (PRE: 1011372.6 PRS: 2059405.6)
예제1) concatenate 사용하기
Control File: test.ctl
load data
infile 'test.dat'
truncate
concatenate (2)
into table test
(col1 char(2000))
Data File: 'test.dat'
This is a test \n
this is the second Line.
This is a new record\n
this is the second line of the second record
결과:
SQL> select * from test;
COL1
This is a test \nthis is the second Line.
This is a new record\nthis is the second line of the second record
예제2) continueif 를 사용하기
Control File: test.ctl
load data
infile test.dat
truncate
continueif this (1) = '*'
into table test
(col1 char(64000))
Data File: 'test.dat'
*11111111111
*22222222222
*33333333333
*44444444444
*55555555555
66666666666
*77777777777
*88888888888
999999999999
*aaaaaaaaaaa
*bbbbbbbbbbb
cccccccccccc
*ddddddddddd
*eeeeeeeeeee
*fffffffffff
*ggggggggggg
*hhhhhhhhhhh
결과 :
SQL> select * from test;
COL1
11111111111222222222223333333333344444444444555555555556666666666
777777777778888888888899999999999
aaaaaaaaaaabbbbbbbbbbbccccccccccc
dddddddddddeeeeeeeeeeefffffffffffggggggggggghhhhhhhhhhh
2) delimiter 를 사용한 경우 특정 field 를 skip 할수 있나 ?
: 불가능하다 (RTSS Bulletin: 103235.426)
3): 모든 column 에 해당 column 에 해당하는 length 를 지정하였는데
다음과 같은 error message 를 접한 경우 :
"FIELD IN DATA FILE EXCEEDED MAXIMUM SPECIFIED LENGTH"
:255 자 이상의 char/varchar2/long field 를 load 하려한 경우
이 경우는 CHAR data type 의 buffer size 를 증가 시켜야 한다.
이의 default 는 255 이다.
예제)
load data
into table
(col1 char(64000))
이 경우 buffer 를 64K 로 증가시켜 col1 에 load 해야 한다.
<주의> 64K 는 sql*loader 에서 사용 가능한 maximum record length이다.
이는 1 record 를 여러개의 buffer 를 통해 load 하지 못하는 문제이다.
최대 buffer 는 64k 이다.
64 K 이상을 원하는 경우
a) 여러개의 작은 chunk 로 나누거나,
b) SQL*Loader 를 사용하지 못한다.
4) blob 이나 raw data 는 어떻게 사용하나 ?
: RAW datatype 을 사용하고 length를 부여한다.
예제)
LOAD DATA
INFILE xx.dat "VAR"
REPLACE
INtO TABLE test
(BLOB raw (32767) )
xx.dat 는 load 하고자 하는 전체 file 이다.
이는 bit mapped files 이나, 그외 file type 을 DB 에 load 시
사용 가능한 option 이다.
5) error LDR-510은 어떻게 처리한가 ?
: LDR-510은 data file 안의 physical record가 최대값인 64K 를
넘은 경우이다.
SQL*Loader 에서는 physical record 가 연속적이어야 하며, 이는
최대인 64k 를 넘지 못하는 제한이 있기 때문이다.
(여러 buffers 를 통해 load 불가능)
이는 위의 1번과 같으므로 physical record 를 여러 logical record 로
나누어야 한다.
6) EBCDIC Characterset data file 은 어떻게 load 하나 ?
: control file 에 characterset 을 명시한다.
많이 사용되는 EBCDIC character set 은 WE8EBCDIC500 이다.
예제)
load data
characterset we8ebcdic500
infile *
replace
into table for_load
(x)
begindata
B
Z
X
SQL> select * from for_load;
X
a
i
이는 ASCII 의 경우도 같다.
7) control file 에 WE8EBCDIC500 characterset 을 사용하였는데도
SQL*Loader-266 가 발생하는 경우
환경변수인 ORA_NLS 가 맞게 설정되었는지를 check 한다.
(PRE: 1012552.6 PRS: 2060644.6)
8) decimal data 는 어떻게 load 하는가?
: data 를 조작하는 방법밖에 없다.즉 decimal point 가 들어가게
data 를 조작한다.
예제)
load data
infile *
truncate
into table test
(col1 integer external(5) ":col1/100")
begindata
12345
10000
24983
SQL> select * from test;
COL1
123.45
100
249.83
9) trailing signs 이 있는 숫자는 어떻게 load 하는가?
예제)
load data
infile *
truncate
into table loadnums
(col1 position(1:5),
col2 position(7:16) "to_number(:col2,'99,999.99MI')")
begindata
abcde 1,234.99-
abcde 11,234.34+
abcde 45.23
abcde 99,234.38-
abcde 23,234.23+
abcde 98,234.23+
SQL> select * from loadnums;
COL1 COL2
abcde -1234.99
abcde 11234.34
abcde -99234.38
abcde 23234.23
abcde 98234.23
<주의> 이경우 log file 에 다음의 error message 를 볼수있다.
Record 3: Rejected - Error on table LOADNUMS, column COL2.
ORA-01722: invalid number
이 error message 는 당연한 것이다.
왜냐면 control file 에 number datatype 에 mask 를 주었기 때문에
모든 number 는 mask 를 가져야 한다.
이때 Record 3은 trailing sign 이 없기 때문에 reject 된 것이다.
10) zoned number는 무엇인가?
이는 decimal digit 의 string 으로 1byte 에 1 string 이 해당된며,
부호가 맨 마지막byte 에 포함되는 경우이다.
예제)
LOAD DATA
infile *
append
INTO TABLE test
(col1 position(1:3) zoned(3),
col2 position(4:6),
col3 position(7:8))
begindata
12J43323
43023423
SQL> select * from test;
COL1 COL2 COL3
-121 433 23
430 234 23
2 rows selected.
다음은 zoned values의 map 이다:
{ABCDEFGHI}JKLMNOPQR0123456789
++++++++++----------++++++++++
{ABCDEFGHI}JKLMNOPQR
01234567890123456789
11) Packed Decimal Number는 무엇인가 ?
: packed decimal format은 bytes 로 이루어진 1 string 의 모음인데
각각은 2 digit (2 nibbles) 을 가진다.
이중 마지막 byte 는 1 digit 와 sign 으로 이루어진다.
이 sign 은 보통 0x0a, 0x0b, ..., 0x0f: usually 0x0c/a/e/f for +ve,
0x0d/b for -ve 로 이루어져 있다.
예를 들어 +123 의 packed decimal 표현은 다음과 같다.
[12] [3C] 이고 이때 [12] 는 nibbles 0x01 and 0x02를 포함하는
byte 이다. [3C]의 경우도 같다.
The kernel 은 sing nibble 의 여부를 ttcp2n() 을 통해 check한다.
만일 0x0a, ..., 0x0f 중의 하나가 아니면 ORA-1488 error 를 발생시킨다.
<주의> BUG:296890:
이는 bug 는 아니며, SQL*Loader 는 COBOL 에서 발생시키는 UNSIGNED
packed decimal 을 support 하지 않는다.
즉 SQL*Loader 는 packed decimal을 load 시 마지막 byte 가 반드시
1 digit와 ,sign 이 포함되어지는지 check 한다.
12) NULLIF 는 어떻게 사용하나 ?
예제)
load data
infile *
truncate
into table test
fields terminated by ','
(col1 date "mm/dd/yy" nullif col1='0', col2)
begindata
0,12345
11/11/95,12345
0,12345
11/11/95,12345
SQL> select * from test;
COL1 COL2
12345
11-NOV-95 12345
12345
11-NOV-95 12345
13) 한개의 single column을 위해 여러 개의 nullif 는 사용가능한가 ?
: 불가능하다. 그러나 workaround 로는
예제)
load data
infile *
truncate
into table test
fields terminated by ',' optionally enclosed by '"'
(col1,col2 "decode(:col2,'X',NULL,'Y',NULL,'Z',NULL,:col2)",col3)
begindata
12345,"X",12345
12345,"A",12345
12345,"Y",12345
12345,"Z",12345
12345,"B",12345
SQLDBA> select * from test;
COL1 COL2 COL3
12345 12345
12345 A 12345
12345 12345
12345 12345
12345 B 12345
5 rows selected.
14) SQL*Loader 가 NULL 로 여기는 column 을 blank space 로 여기도록
만들려면 ?
: PRESERVE BLANKS를 사용하지 않으면 loader 는 blank 들을 null 로
인식한다.
이 경우 workaround 로는
예제)
load data
infile *
into table test
fields terminated by ','
(col1 position(1:5) integer external,
col2 position(15:20) char "nvl(:col2,' ')",
col3 position(25:30) integer external)
begindata
12345 rec1 12345
12345 23453
23333 rec3 29874
98273 98783
98723 rec5 234
SQL> select * from test yields;
COL1 COL2 COL3
12345 rec1 12345
12345 23453
23333 rec3 29874
98273 98783
98723 rec4 234
5 rows selected.
15) WHEN 절은 어떻게 사용한가 ?
예제)
load data
infile *
truncate
into table t1
when col1 = '12345'
(col1 position(1:5) integer external, col2 position(7:12) char)
into table t2
when col1 = '54321'
(col1 position(1:5) integer external, col2 position(7:12) char)
begindata
12345 table1
54321 table2
99999 no tab
12345 table2
54321 table2
SQL> select * from t1;
COL1 COL2
12345 table1
12345 table2
SQL> select * from t2;
COL1 COL2
54321 table2
54321 table2
16) WHEN 절에 OR 를 사용할수 있는가 ?
: 불가능하다 그러나 workaround 로는
예제) 만일 where (col1=12345 OR col1=54321) AND col2='rowena'경우에
data 를 insert 하고자 하면
load data
infile *
truncate
into table test
when col1 = '12345' and col2='rowena'
(col1 position(1:5) integer external, col2 position(7:12) char)
into table test
when col1 = '54321' and col2='rowena'
(col1 position(1:5) integer external, col2 position(7:12) char)
begindata
12345 rowena
43234 rowena
54321 rowena
(즉, OR를 갖지 못하나, 같은 table 에 두개의 when 은 가질수있다.)
SQLDBA> select * from test;
COL1 COL2
12345 rowena
54321 rowena
2 rows selected.
17) delimiter 로 ','를 사용하였는데 data 에 ','가 포함된 경우는 ?
: 두 번 지정한다.
예제)
load 할 data 가 col1, rowena, rowena, col3 이고
datafile 이 다음과 같은 경우
col1, rowena,, rowena, col3
select * from table:
COL1 COL2 COL3
col1 rowena, rowena col3
18) 어떻게 하면 commit 을 덜 사용할 수 있나 ?
: rows 나 bindsize를 사용한다.
그러나 bindsize 가 적은 경우 bindsize는 rows 를 많이 적재할 수
있으므로 항상 1 bindsize 에 몇 개의 rows 가 set 되었는지에 관계
없이 bindsize에 commit 이 수행된다.
Reference Document
------------------hi,
pls take a look at this document
http://www.petefinnigan.com/weblog/archives/00000020.htm
regards,
Maybe you are looking for
-
How do i use new apple id on iphone 5c
My new iphone asks me for "Apple ID password" for an email account that I don't use. I can't get in.
-
Will Lion run on macbook pro 1.1 2006 running snow leopard
Trying to find out if lion will run on 2006 macbook pro 1.1 running snow leopard , trying to sync my i5 to itunes 10.7 as i get an error message when i plug i5 in saying i need version 10.7 . laptop recognises i5 as camera Anu ideas
-
Reverting to 1.0, controlling aspect ratio, coping with choices
'm relatively content now that I've downgraded to 1.0. Streaming is back to what Apple TV should be, and I don't really miss rentals (thanks, Netflix) or any of the other new Take 2 features much at all. One problem, though. The movies I'm encoding w
-
Just install ios5, and bookmarks are not syncing
-
Alligning output in Excel output and missing logo
Hi All, My BI publisher report gives an output in Excel but the alignment specified in RTF are not reflected in the output. The required alignments are: Numbers(eg: Voucher Number, Invoice Amount etc) - Left Align Varchar2 (eg: Invoice Number, Vendor