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
Similar Messages
-
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 -
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; -
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 for empty field at the end of the line
Hi,
I have following data file for sql loader. I am using Oracle 11.2. The table structure is table_a(id number, name varchar2(32), nbr number).
1, zzzz, 123
2, bbb,
3, ccc, 33
4, ddd,
Currently, I am using "TERMINATED BY ',' " in the control file for SQL loader. However row2 and row4 were thrown into the bad file. Any suggestion for me to load row2 and row4 into the table as well?
Thanks,Two of three columns in your table are named with reserved words.
My first suggestion is to run this query:
SELECT keyword
FROM v$reserved_words
ORDER BY 1;My second suggestion is that your read the FAQ and learn how to use tags to post listings to these forums so we can read what you post.
My third suggestion is that you go to my SQL*Loader Demos page of my website:
http://www.morganslibrary.org/reference/sqlloader.html
and look up "TRAILING NULLCOLS." -
Download SQL Loader for client
Hi, I have been searching for a download of SQL Loader which will work from a client machine. Can someone post a link to the most recent version please?
Edited by: 934989 on May 17, 2012 5:36 AM934989 wrote:
Hi, I have been searching for a download of SQL Loader which will work from a client machine. Can someone post a link to the most recent version please?Oracle Database 11g Release 2 Client (11.2.0.1.0) for Microsoft Windows (x64)
http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-win64soft-094461.html
Oracle Database 11g Release 2 Client (11.2.0.1.0) for Microsoft Windows (32-bit)
http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-win32soft-098987.html
Thanks,
Hussein
Edited by: MarkP on May 22, 2012 10:59 AM - Please don't link directly to download files since license acceptance is required. -
SQL Loader for mainframe platform
Hi all,
Is there any utility on mainframe platform that corresponds to SQL*Loader in Windows/Unix?
Thanks
Edited by: Valli on Feb 25, 2010 11:38 AMPl specify which mainframe version/OS. Pl see if this link helps
http://download.oracle.com/docs/cd/B19306_01/server.102/b25396/tools.htm#sthref261
HTH
Srini -
SQL queries for finding values in 4 different tables
I need to have certain queries to find specific data in this table, this is just an example table, but I will use the same ideas for my actual website and database.
customers (customerID: integer, fName: string, lName: string)
items (itemID: integer, description: string, price: float)
orders (orderID: integer, itemID: integer, aID: integer, customerID: integer, date: date)
addresses (aID: integer, housenum: integer, streetName: string, town:string, state: string, zip:integer)
Values I need to find are
List the town, first name, and last name of any customer who has shipped an item to the same town as another customer.
Return the average amount of money each customer spent in March of 2013. (Note that the answer will be a single number
List the first and last names of all customers who have had the same item shipped to at least two different addresses.
List the top two states that have generated the most total revenue and the revenue they generated
I did try a few different queries, for #3 I tried
SELECT customers.fName,
customers.lName,
COUNT(orders.itemID) AS `total items with diff address >= 2`
FROM customers
JOIN (SELECT customerID,itemID,
COUNT(DISTINCT aID) AS diff_address
FROM orders
GROUP BY orders.itemID
HAVING diff_address >= 2
) AS orders
ON orders.customerID = customers.customerID
but I only got 1 result, and I do not think thats correct.
Thanks for the help and I appreciate you taking the time to help meWhy not post the sample data + desired result? Always state what version you are using.
SELECT lname,A.aID,COUNT(*) cnt FROM customers C JOIN orders O ON c.Customerid=O.Customerid
JOIN address A ON A.aID=O.aID
GROUP BY lname,aID
Sorry cannot test it right now...
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Pl/sql expression for default value
I'm trying to run this simple script as a default value using pl/sql expression, but I keep getting this error. THe select statement itself works fine as a sql statement source value, but will not work as a pl/sql exression as a default value. This (:P33_SYSUSERID_CREATED_BY ) is the field name on the form. Any ideas?
begin
select a.id || ', ' || A.NAME_LAST into :P33_SYSUSERID_CREATED_BY from S_USERSV a where a.name_last = 'HAMMAKER';
end;
Error ERR-9132 Error in PLSQL expression for item default code, item=P33_SYSUSERID_CREATED_BY
OK
ORA-06550: line 1, column 27: PLS-00103: Encountered the symbol "BEGIN" when expecting one of the following: ( - + case mod new not null avg count current exists max min prior sql stddev sum variance execute forall merge time timestamp interval date pipeSudha,
For a default value type of PL/SQL Expression, you could create a function that accepts an input and returns a value. If the function (not a procedure) is named GET_REFNO, you would call it using an expression in the default value field like:
get_refno(:P3_REFTYPE)
For a default value type of PL/SQL Function Body, you could call your existing procedure with a default value like:declare
l_value varchar2(32767);
begin
get_refno(:P3_REFTYPE, l_value);
return l_value;
end;Scott -
SQL query for updating values in same cell of a table
Hi All,
I'm stuck with a problem and it stands as follows:
Table name: Track
Part1 Part2 Part3
NULL NULL NULL
I've a table called Track, which has three columns named Part1, Part2 and Part3. I want all values of Part1 to be separated by a comma (,); it should not be overwritten, neither they should appear in separate row, in fact they should look like this:
Part1 Part2 Part3
1,2,3 5 SUBM1
The new values of Part1 should appear in next row only when value of Part3 changes, so if Part3 changes from SUBM1 to SUBM2, it should look like this:
Part1 Part2 Part3
1,2,3 5 SUBM1
1,2,3 5 SUBM2
Count of values in Part1 never exceeds the value of Part2, so if Part2 is 5, then Part1 will look like 1,2,3,4,5. So in other words loop will run only up to the value of Part2.
Please advise how this could be achieved?
Kind regards,
Aniruddha JagdaleI've a table called Track, which has three columns named Part1, Part2 and Part3. I want all values of Part1 to be separated by a comma (,);
No, don't go there.
This breaks a fundamental point for relational databases: no repeating groups. A cell should hold an atomic value. And this is not only a matter of purism. Relational databases are designed from this principle, and breaking this means that you will need
to write complex and higly inefficient code.
The values in Part1 should be in a separate table, with one value per row.
Erland Sommarskog, SQL Server MVP, [email protected] -
Error loading large field with sql loader for 8i
I want to load a large field (30K) to a database, where I use "long" datatype for it. But I can't because it loads hexadecimal characters, or it get stuck in a loop and does not load anything. I have tried using clob and long in the database and using char(40000), char, and log varraw in the control file. Any idea or suggestion?
Thanks a lot.Hi,
from what I see you are running sqllldr in Windows and your database server is on AIX. Is it a remote server or a local network server?
The ORA-12170 error can be raised for many reasons: firewall issue, database down, listener down, bad sqlnet.ora parm, network trouble, etc
If your network is slow maybe that is the reason. You may post also SQLNET.ORa configuration and try to reconfigure parameters SQLNET.INBOUND_CONNECT_TIMEOUT, SQLNET.SEND_TIMEOUT, SQLNET.RECV_TIMEOUT in sqlnet.ora to larger values.
If your problem is not solved, please post your SQLNET.ORA configuration.
You can check here for details about setting it: Profile Parameters.
Regards.
Al -
SQL Query for max values!!
Hi to all,
I have four tables
Tbl_one
Tbl_two
Tbl_three
Tbl_four
the relation between these tables is
Tbl_one.SEQ = Tbl_two.SEQ)
and tbl_two.case_SEQ = Tbl_four.SEQ
AND Tbl_two.ORDER_SEQ = tbl_three.SEQ))
I want a query like this
Select tbl_one.com_name, tbl_three.test_date,tbl_four.order_date
from Tbl_one,Tbl_two,Tbl_three,Tbl_four
where Tbl_one.SEQ = Tbl_two.SEQ)
and tbl_two.case_SEQ = Tbl_four.SEQ
AND Tbl_two.ORDER_SEQ = tbl_three.SEQ))
and tbl_three.test_date in (select max(test_date) from tbl_three)
and tbl_four.order_date in select(max(order_date from tbl_for)
and max(test_date)> Max(order_date)
any way it is possible?
the real problem is there are multiple test_dates and
multiple order_date for same seq in tbl_one.seq.
eg: -
name (indian) which has three or more test_date and each test_date have more than one order_date
indian (name) 01/01/2009(test_date) has ---- 01/10/2009, 01/20/2009 and 01/21/2009) order_dates
india(name) 02/02/2009 (test_date) has ----- 02/10/2009, 02/20/2009 and 02/30/2009 (order_dates)
india(name) 03/03/2009 test_date has ----- 03/10/2009, 03/20/2009 , 03/25/2009 (order_dates).
japan has the same situation and so on
what i wanted from the query is
max(test_date)= 03/03/2009 > max(order_date)=03/25/2009
ans: -
name
india(name) 03/03/2009 (test_date) 03/25/2009(order_date)
etc. etc . etc.
thanks!!
Edited by: pl/sql baby on Mar 24, 2009 10:45 AM
Edited by: pl/sql baby on Mar 24, 2009 10:47 AM
Edited by: pl/sql baby on Mar 24, 2009 10:51 AM
Edited by: pl/sql baby on Mar 24, 2009 10:57 AMPlease use tags either side of code / data (to preserve the formatting and spacing).
I don't understand your requirement... 03/03/2009 is not greater than 03/25/2009 ?
Could you please be clearer in your input/output samples and explain more about how to generate the output? -
SQL Query for take values on excle sheet
i have the query `select EmpId,AttenDate,status from dbo.Attendance`
it will give me this
1500011 2014-09-01 00:00:00.000
A
1500011 2014-09-02 00:00:00.000
A
1500011 2014-09-03 00:00:00.000
A
1500011 2014-09-04 00:00:00.000
A
1500011 2014-09-05 00:00:00.000
A
1500011 2014-09-06 00:00:00.000
P
1500011 2014-09-07 00:00:00.000
A
upto 2014-09-31 00:00:00.000
A
68 2014-08-01 00:00:00.000
A
68 2014-08-02 00:00:00.000
P
68 2014-08-03 00:00:00.000
A
68 2014-09-07 00:00:00.000 A
upto 2014-09-31 00:00:00.000
A
Now i want to print it into the excel sheet
with is format
Empid 1
2 3
4 5
6 7
8 upto 31
1500011 A A A
A A
P A
A upto A
68 A
A P
....................upto A
Please suggest me??
Hi SachinDholess,
Based on my understanding, you want to merge the attendance records for each EmpID into one row as below snapshot rather than in rows, right?
According to your description, I created and populate the attendance records of September for EmpID
1500011 and records of August and September for EmpID 68
to simulate your scenario. In this scenario, the Stored Procedure
procGetEmpAtt would help you to get the data like above snapshot during a given period. Please see the below code.
USE TestDB;
IF OBJECT_ID('dbo.Attendance') IS NOT NULL
DROP TABLE dbo.Attendance;
GO
CREATE TABLE Attendance
EmpID INT,
AttenDate DATETIME,
[status] VARCHAR(99)
GO
--Create and Populate the Nums Auxiliary Table
SET NOCOUNT ON;
SET ROWCOUNT 0;
IF OBJECT_ID('dbo.Nums', 'U') IS NOT NULL
DROP TABLE dbo.Nums;
CREATE TABLE dbo.Nums(n INT NOT NULL PRIMARY KEY);
DECLARE @max AS INT, @rc AS INT;
SET @max = 1000;
SET @rc = 1;
INSERT INTO dbo.Nums(n) VALUES(1);
WHILE @rc * 2 <= @max
BEGIN
INSERT INTO dbo.Nums(n) SELECT n + @rc FROM dbo.Nums;
SET @rc = @rc * 2;
END
INSERT INTO dbo.Nums(n)
SELECT n + @rc FROM dbo.Nums WHERE n + @rc <= @max;
GO
--Insert records of September for EmpID 1500011
INSERT INTO Attendance VALUES(1500011,'2014-09-01 00:00:00.000', 'A');
INSERT INTO Attendance
SELECT EmpID, DATEADD(DAY,n,AttenDate), [status] FROM Attendance join nums ON nums.n<30
WHERE EMPID=1500011;
--Insert records of September and August for EmpID 68
INSERT INTO Attendance VALUES(68,'2014-08-01 00:00:00.000', 'A');
INSERT INTO Attendance
SELECT EmpID, DATEADD(DAY,n,AttenDate), [status] FROM Attendance join nums ON nums.n<61
WHERE EMPID=68;
DROP TABLE dbo.Nums;
IF (OBJECT_ID('procGetEmpAtt', 'P') IS NOT NULL)
DROP PROC procGetEmpAtt
GO
CREATE PROC procGetEmpAtt(@startDT DATETIME, @endDT DATETIME)
AS
DECLARE @DynamicPivotQuery AS NVARCHAR(MAX);
DECLARE @ColumnName AS NVARCHAR(MAX);
DECLARE @Columns AS NVARCHAR(MAX);
--Get distinct values of the PIVOT Column
SELECT @ColumnName= ISNULL(@ColumnName + ',','')+ 'ISNULL('+QUOTENAME(dt)+',''Not Recored'') AS '+QUOTENAME(dt),
@Columns=ISNULL(@Columns + ',','')+QUOTENAME(dt)
FROM (SELECT DISTINCT CONVERT(varchar(12) , AttenDate, 112 ) as dt FROM Attendance WHERE AttenDate BETWEEN @startDT AND @endDT ) AS A ;
--Prepare the dynamic PIVOT query
SET @DynamicPivotQuery =
N'SELECT EmpID, ' + @ColumnName + '
FROM Attendance
PIVOT(MAX([status])
FOR AttenDate IN (' + @Columns + ')) AS PVTTable ORDER BY EmpID DESC' ;
--Execute the dynamic Pivot Query
EXEC sp_executesql @DynamicPivotQuery ;
GO
Test example
SET NOCOUNT ON;
SET ROWCOUNT 0;
EXEC procGetEmpAtt
@startDT='2014-08-29',
@endDT='2014-09-15'
The key in this Stored Procedure is the dynamic Pivot statement, click
here for more details.
By the way, I didn’t quite get your point until I copied your description into a Word document. Kindly mind the format of the description you post, a better formatted one would lead to a much quicker response.
If you have any question, feel free to let me know.
Best Regards,
Eric Zhang -
How to load a default value in to a column when using sql loader
Im trying to load from a flat file using sql loader.
for 1 column i need to update using a default value
how to go about this?Hi!
try this code --
LOAD DATA
INFILE 'sample.dat'
REPLACE
INTO TABLE emp
empno POSITION(01:04) INTEGER EXTERNAL NULLIF empno=BLANKS,
ename POSITION(06:15) CHAR,
job POSITION(17:25) CHAR,
mgr POSITION(27:30) INTEGER EXTERNAL NULLIF mgr=BLANKS,
sal POSITION(32:39) DECIMAL EXTERNAL NULLIF sal=BLANKS,
comm POSITION(41:48) DECIMAL EXTERNAL DEFAULTIF comm = 100,
deptno POSITION(50:51) INTEGER EXTERNAL NULLIF deptno=BLANKS,
hiredate POSITION(52:62) CONSTANT SYSDATE
)-hope this will solve ur purpose.
Regards.
Satyaki De.
Maybe you are looking for
-
Using iPhone as an iPod (not activated)
I am planning on selling my iPhone to a friend that doesn't have att. I am selling my iphone to get the new 3g iPhone. since my friend doesn't have att he was going to use it as an ipod after i remove my sim card. I'm wondering if he will be able to
-
Help please. Need to access apps that are beyond the last pge so I can put them back in folders. My kids accidently reset the home page and all the apps I use as an slp are scattered or can only be accessed if I can recall the name of the app. I t
-
Anyone know how to dynamically change the border of UILoader Component
Hi All I am loading multiple instances of UI loader containing external SWFs on my stage. When user double clicks on the video thumbnail, an instance of UIloader will be placed on the main stage.The user can place as many UIloader instances on the ma
-
Hi Experts, I am facing an issue in HCM P&F wokflow. I am working on Employee Transfer scenario. So I copied the standard Process ORG_CHANGE and made the changes in Workflow, Form scenario and Form according to my reqirement . But when the Reciever m
-
Image displaying improperly on Safari
While surfing the web, certain images are being displayed with a negative effect. The rest of the page is displayed properly, but the images are shown with a negative/X-ray Effect. I took a screen shot on the ipad, but im unable to upload the image h