Home » RDBMS Server » Server Utilities » decimal value in control file
decimal value in control file [message #634420] |
Tue, 10 March 2015 01:30  |
 |
mist598
Messages: 1195 Registered: February 2013 Location: Hyderabad
|
Senior Member |
|
|
Hi ,
I want to insert data into the table , in the control file(.ctl file)
item_rate CHAR NULLIF item_rate = BLANKS "RTRIM(:item_rate )"
But in the item_rate value are like 1.234, 0.456 so is the above code is correct or not?
Thanks
|
|
|
|
|
|
|
Re: decimal value in control file [message #634525 is a reply to message #634466] |
Wed, 11 March 2015 03:24   |
 |
mist598
Messages: 1195 Registered: February 2013 Location: Hyderabad
|
Senior Member |
|
|
Hi,
Quote:
What is the control file?
Options(errors=10000,skip=3)
LOAD DATA
REPLACE
INTO TABLE sampl_table
fields terminated by ','
optionally enclosed by '"'
trailing nullcols
(
customer_name CHAR NULLIF customer_name = BLANKS "RTRIM(:customer_name)",
customer_no CHAR NULLIF customer_number = BLANKS "RTRIM(:customer_number)",
item_no CHAR NULLIF item_number = BLANKS "RTRIM(:item_number)",
valid_amount_month1 CHAR TERMINATED BY WHITESPACE NULLIF valid_amount_month1 = BLANKS "to_number(:valid_amount_month1 , '999,999,999.99')" ,
valid_unit_month1 CHAR TERMINATED BY WHITESPACE NULLIF valid_unit_month1 = BLANKS "to_number(substr(:valid_unit_month1,instr(:valid_unit_month1,'$')+1),'999,999,999.99')",
valid_rate CHAR NULLIF valid_rate = BLANKS "RTRIM(:valid_rate)"
)
Record 12: Rejected - Error on table SAMPL_TABLE, column VALID_AMOUNT_MONTH1.
ORA-01722: invalid number
Quote:
What is the table description?
ITEM_NO VARCHAR2(240 BYTE),
ITEM_DESCRIPTION VARCHAR2(240 BYTE),
CUSTOMER_NAME VARCHAR2(240 BYTE),
CUSTOMER_NO VARCHAR2(240 BYTE),
VALID_AMOUNT_MONTH1 NUMBER,
VALID_UNITS_MONTH1 NUMBER,
VALID_BUDGET_AMOUNT_MONTH1 NUMBER,
VALID_BUDGET_UNITS_MONTH1 NUMBER,
VALID_RATE NUMBER
Quote:
What is the content of the data file?
Category CustName Cust # Item No Amount - Month 1 Units - Month 1 Budget - Month 1 Budget -Unit- Month 1 attribute1
------------ ------ ------- -------- --------------- ---------------- --------------- --------------------- --------------
abc Rynu abc123 D 34 1234
What is the Oracle version?
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
|
|
|
|
|
|
Re: decimal value in control file [message #634533 is a reply to message #634527] |
Wed, 11 March 2015 04:24   |
 |
mist598
Messages: 1195 Registered: February 2013 Location: Hyderabad
|
Senior Member |
|
|
Hi Michel ,
create table SAMPL_TABLE
(
ITEM_CATEGORY VARCHAR2(30 BYTE),
ITEM_NO VARCHAR2(240 BYTE),
ITEM_DESCRIPTION VARCHAR2(240 BYTE),
CUSTOMER_NAME VARCHAR2(240 BYTE),
CUSTOMER_NO VARCHAR2(240 BYTE),
VALID_AMOUNT_MONTH1 NUMBER,
VALID_UNITS_MONTH1 NUMBER,
VALID_BUDGET_AMOUNT_MONTH1 NUMBER,
VALID_BUDGET_UNITS_MONTH1 NUMBER,
VALID_RATE NUMBER
);
Please check the below attached File
Thanks
-
Attachment: Sheet1.csv
(Size: 0.58KB, Downloaded 459 times)
|
|
|
Re: decimal value in control file [message #634535 is a reply to message #634533] |
Wed, 11 March 2015 04:34   |
 |
Michel Cadot
Messages: 68417 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
Using your table and control file I get:
SQL> create table SAMPL_TABLE
2 (
3 ITEM_CATEGORY VARCHAR2(30 BYTE),
4 ITEM_NO VARCHAR2(240 BYTE),
5 ITEM_DESCRIPTION VARCHAR2(240 BYTE),
6 CUSTOMER_NAME VARCHAR2(240 BYTE),
7 CUSTOMER_NO VARCHAR2(240 BYTE),
8 VALID_AMOUNT_MONTH1 NUMBER,
9 VALID_UNITS_MONTH1 NUMBER,
10 VALID_BUDGET_AMOUNT_MONTH1 NUMBER,
11 VALID_BUDGET_UNITS_MONTH1 NUMBER,
12 VALID_RATE NUMBER
13 );
Table created.
SQL>
SQL> host sqlldr michel/michel control=E:\t4.ctl data=E:\t4.txt
SQL*Loader: Release 11.2.0.1.0 - Production on Mer. Mars 11 10:33:45 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
SQL*Loader-403: Referenced column CUSTOMER_NUMBER not present in table SAMPL_TABLE.
|
|
|
Re: decimal value in control file [message #634537 is a reply to message #634535] |
Wed, 11 March 2015 04:43   |
 |
mist598
Messages: 1195 Registered: February 2013 Location: Hyderabad
|
Senior Member |
|
|
Sorry Michel that is printing mistake, now check it again
Options(errors=10000,skip=3)
LOAD DATA
REPLACE
INTO TABLE sampl_table
fields terminated by ','
optionally enclosed by '"'
trailing nullcols
(
customer_name CHAR NULLIF customer_name = BLANKS "RTRIM(:customer_name)",
customer_no CHAR NULLIF customer_number = BLANKS "RTRIM(:customer_no)",
item_no CHAR NULLIF item_number = BLANKS "RTRIM(:item_no )",
valid_amount_month1 CHAR TERMINATED BY WHITESPACE NULLIF valid_amount_month1 = BLANKS "to_number(:valid_amount_month1 , '999,999,999.99')" ,
valid_unit_month1 CHAR TERMINATED BY WHITESPACE NULLIF valid_unit_month1 = BLANKS "to_number(substr(:valid_unit_month1,instr(:valid_unit_month1,'$')+1),'999,999,999.99')",
valid_rate CHAR NULLIF valid_rate = BLANKS "RTRIM(:valid_rate)"
)
|
|
|
|
Re: decimal value in control file [message #634542 is a reply to message #634539] |
Wed, 11 March 2015 04:56   |
 |
mist598
Messages: 1195 Registered: February 2013 Location: Hyderabad
|
Senior Member |
|
|
Hi Michel please check it now and added new 2 columns to the Table
create table SAMPL_TABLE
(
ITEM_CATEGORY VARCHAR2(30 BYTE),
ITEM_NO VARCHAR2(240 BYTE),
ITEM_DESCRIPTION VARCHAR2(240 BYTE),
CUSTOMER_NAME VARCHAR2(240 BYTE),
CUSTOMER_NO VARCHAR2(240 BYTE),
VALID_AMOUNT_MONTH1 NUMBER,
VALID_UNITS_MONTH1 NUMBER,
VALID_BUDGET_AMOUNT_MONTH1 NUMBER,
VALID_BUDGET_UNITS_MONTH1 NUMBER,
ATTRIBUTE1 VARCHAR2(240 BYTE),
ATTRIBUTE2 VARCHAR2(240 BYTE),
VALID_RATE NUMBER
);
CTL File
--------
Options(errors=10000,skip=3)
LOAD DATA
REPLACE
INTO TABLE sampl_table
fields terminated by ','
optionally enclosed by '"'
trailing nullcols
(
customer_name CHAR NULLIF customer_name = BLANKS "RTRIM(:customer_name)",
customer_no CHAR NULLIF customer_number = BLANKS "RTRIM(:customer_no)",
item_no CHAR NULLIF item_number = BLANKS "RTRIM(:item_no )",
valid_amount_month1 CHAR TERMINATED BY WHITESPACE NULLIF valid_amount_month1 = BLANKS "to_number(:valid_amount_month1 , '999,999,999.99')" ,
valid_unit_month1 CHAR TERMINATED BY WHITESPACE NULLIF valid_unit_month1 = BLANKS "to_number(substr(:valid_unit_month1,instr(:valid_unit_month1,'$')+1),'999,999,999.99')",
valid_budget_units_month1 CHAR TERMINATED BY WHITESPACE NULLIF valid_budget_units_month1 = BLANKS "to_number(:valid_budget_units_month1, '999,999,999.99')" ,
valid_budget_amount_month1 CHAR TERMINATED BY WHITESPACE NULLIF valid_budget_amount_month1 = BLANKS "to_number(trim(substr(:valid_budget_amount_month1,instr(:valid_budget_amount_month1,'$')+1)),'999,999,999.99')" ,
valid_rate CHAR NULLIF valid_rate = BLANKS "RTRIM(:valid_rate)"
)
|
|
|
Re: decimal value in control file [message #634547 is a reply to message #634542] |
Wed, 11 March 2015 05:04   |
 |
Michel Cadot
Messages: 68417 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
SQL> create table SAMPL_TABLE
2 (
3 ITEM_CATEGORY VARCHAR2(30 BYTE),
4 ITEM_NO VARCHAR2(240 BYTE),
5 ITEM_DESCRIPTION VARCHAR2(240 BYTE),
6 CUSTOMER_NAME VARCHAR2(240 BYTE),
7 CUSTOMER_NO VARCHAR2(240 BYTE),
8 VALID_AMOUNT_MONTH1 NUMBER,
9 VALID_UNITS_MONTH1 NUMBER,
10 VALID_BUDGET_AMOUNT_MONTH1 NUMBER,
11 VALID_BUDGET_UNITS_MONTH1 NUMBER,
12 ATTRIBUTE1 VARCHAR2(240 BYTE),
13 ATTRIBUTE2 VARCHAR2(240 BYTE),
14 VALID_RATE NUMBER
15 );
Table created.
SQL> host sqlldr michel/michel control=E:\t4.ctl data=E:\t4.txt
SQL*Loader: Release 11.2.0.1.0 - Production on Mer. Mars 11 11:03:22 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
SQL*Loader-403: Referenced column CUSTOMER_NUMBER not present in table SAMPL_TABLE.
You are boring in the end.
[Updated on: Wed, 11 March 2015 05:04] Report message to a moderator
|
|
|
|
|
Re: decimal value in control file [message #634569 is a reply to message #634550] |
Wed, 11 March 2015 06:50   |
 |
mist598
Messages: 1195 Registered: February 2013 Location: Hyderabad
|
Senior Member |
|
|
Options(errors=10000,skip=3)
LOAD DATA
INFILE '/home/appltest/Sheet1.csv'
BADFILE 'sample.bad'
DISCARDFILE 'sample.dsc'
REPLACE
INTO TABLE sampl_table
fields terminated by ','
optionally enclosed by '"'
trailing nullcols
(
customer_name CHAR NULLIF customer_name = BLANKS "RTRIM(:customer_name)",
customer_no CHAR NULLIF customer_no = BLANKS "RTRIM(:customer_no)",
item_no CHAR NULLIF item_no = BLANKS "RTRIM(:item_no )",
valid_amount_month1 CHAR TERMINATED BY WHITESPACE NULLIF valid_amount_month1 = BLANKS "to_number(:valid_amount_month1 , '999,999,999.99')" ,
valid_units_month1 CHAR TERMINATED BY WHITESPACE NULLIF valid_units_month1 = BLANKS "to_number(substr(:valid_units_month1,instr(:valid_units_month1,'$')+1),'999,999,999.99')",
valid_budget_units_month1 CHAR TERMINATED BY WHITESPACE NULLIF valid_budget_units_month1 = BLANKS "to_number(:valid_budget_units_month1, '999,999,999.99')" ,
valid_budget_amount_month1 CHAR TERMINATED BY WHITESPACE NULLIF valid_budget_amount_month1 = BLANKS "to_number(trim(substr(:valid_budget_amount_month1,instr(:valid_budget_amount_month1,'$')+1)),'999,999,999.99')" ,
valid_rate CHAR NULLIF valid_rate = BLANKS "RTRIM(:valid_rate)"
)
Please check the below attached File
|
|
|
Re: decimal value in control file [message #634577 is a reply to message #634569] |
Wed, 11 March 2015 09:38   |
 |
Michel Cadot
Messages: 68417 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
Take the first error:
Quote:Record 1: Rejected - Error on table SAMPL_TABLE, column VALID_AMOUNT_MONTH1.
ORA-01722: invalid number
Check the value for this row:
REYNU,1001,ABC001,ABC Renyu,ABC,,,,,82,61,1
Error on column AMOUNT_MONTH1.
Column AMOUNT_MONTH1 is fourth one in the control file.
Fourth value in the row is "ABC Renyu".
This is indeed not a number.
So either the data are wrong, either the control file is wrong.
Do the same thing for all errors.
And try to think: is "123,456" one number or 2 numbers?
Waiting for your answer...
|
|
|
Re: decimal value in control file [message #634607 is a reply to message #634577] |
Thu, 12 March 2015 00:12   |
 |
mist598
Messages: 1195 Registered: February 2013 Location: Hyderabad
|
Senior Member |
|
|
Hi Michel , check the modified code please
Options(errors=10000,skip=3)
LOAD DATA
INFILE '/home/appltest/Sheet1.csv'
BADFILE 'sample.bad'
DISCARDFILE 'sample.dsc'
REPLACE
INTO TABLE sampl_table
fields terminated by ','
optionally enclosed by '"'
trailing nullcols
(
customer_name CHAR NULLIF customer_name = BLANKS "RTRIM(:customer_name)",
customer_no CHAR NULLIF customer_no = BLANKS "RTRIM(:customer_no)",
item_no CHAR NULLIF item_no = BLANKS "RTRIM(:item_no )",
item_description CHAR NULLIF item_description = BLANKS "RTRIM(:item_description )",
item_category CHAR NULLIF item_category = BLANKS "RTRIM(:item_category )",
valid_amount_month1 CHAR TERMINATED BY WHITESPACE NULLIF valid_amount_month1 = BLANKS "to_number(:valid_amount_month1 , '999,999,999.99')",
valid_units_month1 CHAR TERMINATED BY WHITESPACE NULLIF valid_units_month1 = BLANKS "to_number(substr(:valid_units_month1,instr(:valid_units_month1,'$')+1),'999,999,999.99')",
attribute1 CHAR NULLIF attribute1 = BLANKS "RTRIM(:attribute1)",
attribute2 CHAR NULLIF attribute2 = BLANKS "RTRIM(:attribute2)",
valid_budget_units_month1 CHAR TERMINATED BY WHITESPACE NULLIF valid_budget_units_month1 = BLANKS "to_number(:valid_budget_units_month1, '999,999,999.99')",
valid_budget_amount_month1 CHAR TERMINATED BY WHITESPACE NULLIF valid_budget_amount_month1 = BLANKS "to_number(trim(substr(:valid_budget_amount_month1,instr(:valid_budget_amount_month1,'$')+1)),'999,999,999.99')",
valid_rate CHAR NULLIF valid_rate = BLANKS "RTRIM(:valid_rate)"
)
Quote:
And try to think: is "123,456" one number or 2 numbers?
Waiting for your answer...
2 number's ,can you please explain clearly at which column has these types of values getting
|
|
|
|
Re: decimal value in control file [message #634616 is a reply to message #634610] |
Thu, 12 March 2015 03:19   |
 |
mist598
Messages: 1195 Registered: February 2013 Location: Hyderabad
|
Senior Member |
|
|
1 select value
2 from nls_session_parameters
3* where parameter = 'NLS_NUMERIC_CHARACTERS'
SQL> /
VALUE
------------------------------------------------
.,
I altered the above vale and try with the below code(.ctl code)
Options(errors=10000,skip=3)
LOAD DATA
INFILE '/home/appltest/Sheet1.csv'
BADFILE 'sample.bad'
DISCARDFILE 'sample.dsc'
REPLACE
INTO TABLE sampl_table
fields terminated by ','
optionally enclosed by '"'
trailing nullcols
(
customer_name CHAR NULLIF customer_name = BLANKS "RTRIM(:customer_name)",
customer_no CHAR NULLIF customer_no = BLANKS "RTRIM(:customer_no)",
item_no CHAR NULLIF item_no = BLANKS "RTRIM(:item_no )",
item_description CHAR NULLIF item_description = BLANKS "RTRIM(:item_description )",
item_category CHAR NULLIF item_category = BLANKS "RTRIM(:item_category )",
valid_units_month1 "to_number(:valid_units_month1, '999,999,999.99')",
valid_amount_month1 "to_number(substr(:valid_amount_month1,instr(:valid_amount_month1,'$')+1),'999,999,999.99')",
attribute1 CHAR NULLIF attribute1 = BLANKS "RTRIM(:attribute1)",
attribute2 CHAR NULLIF attribute2 = BLANKS "RTRIM(:attribute2)",
valid_budget_units_month1 "RTRIM(:valid_budget_units_month1)",
valid_budget_amount_month1 "trim(substr(:valid_budget_amount_month1,instr(:valid_budget_amount_month1,'$')+1))",
valid_rate CHAR TERMINATED BY WHITESPACE "RTRIM(:valid_rate)"
)
So 3 record are inserted into the Table so it is fine
I treid with all columns (86 columns) getting below error
Record 61: Rejected - Error on table SAMPL_TABLE, column VALID_BUDGET_AMOUNT_MONTH1.
ORA-01722: invalid number
Record 2162: Rejected - Error on table SAMPL_TABLE, column VALID_BUDGET_UNITS_MONTH1.
ORA-01722: invalid number
Total logical records skipped: 3
Total logical records read: 2162
Total logical records rejected: 1039
Why some of the rows of columns are inserted why another values are rejected?
[Updated on: Thu, 12 March 2015 03:20] Report message to a moderator
|
|
|
|
|
|
|
Re: decimal value in control file [message #634624 is a reply to message #634621] |
Thu, 12 March 2015 03:56   |
 |
mist598
Messages: 1195 Registered: February 2013 Location: Hyderabad
|
Senior Member |
|
|
Quote:It is possible that what you think it does or it should do (for you) is not what it actually does.
I showed you how to analyze the issue.
Ok.
................
................
valid_budget_amount_month1 "trim(substr(:valid_budget_amount_month1,instr(:valid_budget_amount_month1,'$')+1))",
valid_code CHAR TERMINATED BY WHITESPACE NULLIF valid_code = BLANKS "RTRIM(:valid_code)",
valid_rate CHAR TERMINATED BY WHITESPACE NULLIF valid_rate = BLANKS "RTRIM(:valid_rate)"
)
VALID_CODE
---------
1,USD
1,USD
1,USD
I tried with the above code , valid_code to the control and data file in the same positions , but the both values are inserted into the only one column wht is wrong in my code?
|
|
|
|
Re: decimal value in control file [message #634626 is a reply to message #634625] |
Thu, 12 March 2015 05:30   |
 |
mist598
Messages: 1195 Registered: February 2013 Location: Hyderabad
|
Senior Member |
|
|
Quote:I showed you how to analyze the issue.
Yes Thank you
.....
.....
valid_budget_amount_month1 CHAR "to_number(trim(substr(:valid_budget_amount_month1,instr(:valid_budget_amount_month1,'$')+1)),'999,999,999.99')",
Getting problem with the above column
1) In the Table 1st row is inserted 2,3 is rejected what is the code need to be change in the ctl file??
Record 2: Rejected - Error on table SAMPL_TABLE, column VALID_BUDGET_AMOUNT_MONTH1.
ORA-01722: invalid number
Record 3: Rejected - Error on table SAMPL_TABLE, column VALID_BUDGET_AMOUNT_MONTH1.
ORA-01722: invalid number
select to_number(substr(146,instr(146,'$')+1),'999,999,999.99') from dual
o/p: 146
select to_number(substr(1469,instr(1469,'$')+1),'999,999,999.99') from dual
Error: ORA-01722: invalid number
can you please help me how to do resolve this error?
|
|
|
Re: decimal value in control file [message #634648 is a reply to message #634626] |
Thu, 12 March 2015 09:32   |
cookiemonster
Messages: 13904 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
SQL> select to_number(substr('1,469',instr('1,469','$')+1),'999,999,999.99') from dual;
TO_NUMBER(SUBSTR('1,469',INSTR
------------------------------
1469
SQL> select to_number(substr(1469,instr(1469,'$')+1),'999999999.99') from dual;
TO_NUMBER(SUBSTR(1469,INSTR(14
------------------------------
1469
SQL>
|
|
|
|
|
Goto Forum:
Current Time: Wed Mar 22 22:50:00 CDT 2023
|