sql-loader

How to use to_number and nullif in sql-loader?

混江龙づ霸主 提交于 2019-12-01 22:54:44
问题 I've had a similar problem with dates (combination of to_date and nullif) here : How to use decode in sql-loader? And it was solved nicely. My problem is that a numeric field in my CSV file can have these formats : 999,999,999.99 or just a dot '.' for null values. This is working : MINQUANTITY "TO_NUMBER(:MINQUANTITY, '9999999999D999999', 'NLS_NUMERIC_CHARACTERS='',.''')" or MINQUANTITY NULLIF MINQUANTITY = '.' But it is not working when I'm trying to combine both : MINQUANTITY "TO_NUMBER(

Convert date from one format to another using SQL*Loader control file

核能气质少年 提交于 2019-12-01 19:20:57
The data from the infile is in the format MM/DD/YYYY how do I tell the control file to load it into the database as YYYYMM ? When you specify the columns in the INFILE declare just identify the format the data is held in. Like this load data infile 'whatever.csv' into table t23 fields terminated by ',' trailing nullcols ( col_1 integer , col_2 char , col_3 date "MM/DD/YYYY" , col_4 date "MM/DD/YYYY" , col_5 char ) Don't worry about the "to" date format. That is only for display purposes. Oracle stores dates in its own internal representation. Are you trying to load the MM/DD/YYYY data into a

Sqlldr to accept 1 type of date format

大憨熊 提交于 2019-12-01 12:28:48
I have a sql script file that dynamically generates a control file. It accepts date fields in date formats for mm/dd/yyyy. The sqlldr is loading the dates from the csv file, but it is also accepting date formats such as "mm\dd\yyyy" or "mm.dd.yyyy". How do i make it only accept MM/DD/YYYY? set echo off ver off feed off pages 0 accept fname prompt 'Enter Name of File: ' spool &fname..ctl select 'OPTIONS (SKIP=1)' || chr (10) || 'LOAD DATA'|| chr (10) || 'DISCARDMAX 99999' || chr (10) || 'APPEND'||chr (10)|| 'INTO TABLE MY_TABLE' || chr (10)|| 'FIELDS TERMINATED BY '',''' || chr (10)||

Sqlldr to accept 1 type of date format

醉酒当歌 提交于 2019-12-01 10:58:40
问题 I have a sql script file that dynamically generates a control file. It accepts date fields in date formats for mm/dd/yyyy. The sqlldr is loading the dates from the csv file, but it is also accepting date formats such as "mm\dd\yyyy" or "mm.dd.yyyy". How do i make it only accept MM/DD/YYYY? set echo off ver off feed off pages 0 accept fname prompt 'Enter Name of File: ' spool &fname..ctl select 'OPTIONS (SKIP=1)' || chr (10) || 'LOAD DATA'|| chr (10) || 'DISCARDMAX 99999' || chr (10) ||

Sql loader - second enclosure string not present

假装没事ソ 提交于 2019-11-30 20:37:45
问题 I am loading a .csv file data into oracle table through sql loader. One of the fields has a new line character (CRLF) in its data and so, am getting the below error: second enclosure string not present This is my control file load data characterset UTF8 infile 'C:\Users\lab.csv' truncate into table test_labinal fields terminated by ";" optionally enclosed by '"' TRAILING NULLCOLS ( STATEMENT_STATUS , MANDATORY_TASK , COMMENTS CHAR(9999) "SubStr(:Comments, 0, 1000)" ) The field COMMENTS has a

Skipping data fields while loading delimited data using SQLLDR

我的未来我决定 提交于 2019-11-30 15:54:35
问题 Consider below scenario: Table T1 (f1, f2, f3); Data files: a|b|c|d w|x|y|z I want to load this data skipping the second field as follow: f1 f2 f3 --- --- --- a d c w z y Would really appreciate your help or any pointer in constructing the control file to achieve this. 回答1: Define the column you want to skip as FILLER. Keep in mind the order of the columns in the control file is typically the order they are in the datafile. If the name matches a column in the table, that's where it will go. .

Skipping data fields while loading delimited data using SQLLDR

女生的网名这么多〃 提交于 2019-11-30 15:40:37
Consider below scenario: Table T1 (f1, f2, f3); Data files: a|b|c|d w|x|y|z I want to load this data skipping the second field as follow: f1 f2 f3 --- --- --- a d c w z y Would really appreciate your help or any pointer in constructing the control file to achieve this. Define the column you want to skip as FILLER. Keep in mind the order of the columns in the control file is typically the order they are in the datafile. If the name matches a column in the table, that's where it will go. ... ( f1 CHAR, -- 1st field in the file, goes to column named f1 in the table X FILLER, -- 2nd field in the

SQL Loader Error: “Variable length field exceeds maximum length.”

↘锁芯ラ 提交于 2019-11-30 14:58:56
问题 I have a SQL Loader Control file, LOAD DATA INFILE 'test.txt' INTO TABLE TEST replace fields terminated "|" optionally enclosed by '"' TRAILING NULLCOLS ( DOCUMENTID INTEGER(10), CUSTID INTEGER(10), USERID INTEGER(10), FILENAME VARCHAR(255), LABEL VARCHAR(50), DESCRIPTION VARCHAR(2000), POSTDATE DATE "YYYY-MM-DD HH24:MI:SS" NULLIF POSTDATE="", USERFILENAME VARCHAR(50), STORAGEPATH VARCHAR(255) ) and it's giving me an error when I run SQL Loader on it, Record 1: Rejected - Error on table TEST,

Disable and later enable all table indexes in Oracle

☆樱花仙子☆ 提交于 2019-11-30 13:15:19
问题 How would I disable and later enable all indexes in a given schema/database in Oracle? Note: This is to make sqlldr run faster. 回答1: Here's making the indexes unusable without the file: DECLARE CURSOR usr_idxs IS select * from user_indexes; cur_idx usr_idxs% ROWTYPE; v_sql VARCHAR2(1024); BEGIN OPEN usr_idxs; LOOP FETCH usr_idxs INTO cur_idx; EXIT WHEN NOT usr_idxs%FOUND; v_sql:= 'ALTER INDEX ' || cur_idx.index_name || ' UNUSABLE'; EXECUTE IMMEDIATE v_sql; END LOOP; CLOSE usr_idxs; END; The

Disable and later enable all table indexes in Oracle

你说的曾经没有我的故事 提交于 2019-11-30 06:24:23
How would I disable and later enable all indexes in a given schema/database in Oracle? Note: This is to make sqlldr run faster. Here's making the indexes unusable without the file: DECLARE CURSOR usr_idxs IS select * from user_indexes; cur_idx usr_idxs% ROWTYPE; v_sql VARCHAR2(1024); BEGIN OPEN usr_idxs; LOOP FETCH usr_idxs INTO cur_idx; EXIT WHEN NOT usr_idxs%FOUND; v_sql:= 'ALTER INDEX ' || cur_idx.index_name || ' UNUSABLE'; EXECUTE IMMEDIATE v_sql; END LOOP; CLOSE usr_idxs; END; The rebuild would be similiar. combining 3 answers together: (because a select statement does not execute the DDL