Expert Help needed with Sql Loader !
Hello Friends...I am using one .dat file that contains several values in a
particular column and I need to load those values in different tables with
sqlloader.....For example: in column 3 there are values 0001, 0004, 0007, 9999
..> values 0001 and 0004 need to be loaded into table1 and value 0007 is
loaded into table2 and value 9999 needs to be loaded into table3.
I can successfully use the when clause to load one value at a time but
cannot load a range or multiple values during the sqlloader load. I can
call and run separate .ctl files but less complexity and fewer files would
be better. Tried everything I know but no luck, can't do loads in same
.ctl file......Does the when clause have limitations whereby only one value
at a time can evaluated as True or False ?
I would like to do a Not or InBetween evaluations if possible on that
single coulmn and then do the loads in the specific tables.
Any help would be appreciated as I can see my hair turn grayer by the
minute..My thanks in advance..
You're asking sql*load to perform an unnatural act.
Load in you dat file as-is. Create a pl/sql procedure to do the rest.
Your batch script calls sql*load, then sql*plus to run the proc.
Must simpler. sql*load is not a procedural language.
Similar Messages
-
Hi,
Am using SQL Loader to insert rows in a table.
I have 5 cols in table A. But the data is not present in all cols always.
Have used TRAILING NULLCOLS but with no help.. few rows are inserted and for many others it throws "ORA-01841: (full) year must be between -4713 and +9999, and not be 0" error
(because the value is null in that particular column position)
How do I handle such cases.Please help asap.
FYI -
CONTROL FILE
load data
infile '/home/krkanth/test_spam_20070513.dat'
BADFILE 'sample.bad'
DISCARDFILE 'sample.dsc'
into table spam_rule_stats
fields terminated by "\t"
optionally enclosed by '"'
TRAILING NULLCOLS
(MAIL_DATE date 'yyyymmdd hh24:mi:ss', METRIC_TYPE, HEURISTIC_TYPE, HEURISTIC_VALUE, REJECTION_COUNT,
RULE_START_DATE DATE 'yyyymmdd hh24:mi:ss',
RULE_END_DATE date 'yyyymmdd hh24:mi:ss',SOURCE)
Am getting error Rejected - Error on table SPAM_RULE_STATS, column RULE_END_DATE.
ORA-01841: (full) year must be between -4713 and +9999, and not be 0
SAMPLE DATA
20070513 RULE SENDER [email protected] 534 20070214 22:02:56
SnA_ALERTS
20070513 RULE SENDER [email protected] 6 20070503 21:19:36 200
70518 21:19:36 RULE_EXTENSIONS
20070513 RULE SENDER [email protected] 519 20061105 05:40:44 SnA
_ALERTS
20070513 RULE SENDER [email protected] 332 20070509 02:44:51 20070524 02
:44:51 JASD_HP_AUTOREJECT
20070513 RULE SENDER [email protected] 928 20070512 14:49:14 20070527 14:49:14 JAS
D_HP_AUTOREJECT
20070513 RULE SENDER [email protected] 19875 20070507 22:30:01 20070522 22
:30:01 RULE_EXTENSIONS
20070513 RULE SENDER [email protected] 3 20070509 09:08:38 20070524 09:08:38
JASD_HP_AUTOREJECT
20070513 RULE SENDER [email protected] 10 20070503 21:19:36 200
70518 21:19:36 RULE_EXTENSIONS
20070513 RULE SENDER [email protected] 4 20070506 04:39:48 20070521 04
:39:48 JASD_HP_AUTOREJECT
Thanks.not sure if this will work but you may want to give it a try:
change from:
(MAIL_DATE date 'yyyymmdd hh24:mi:ss'
to:
(MAIL_DATE date 'yyyymmdd'since the first data on your file does not have the timestamps -
Hi,
I am using oracle 8i for Windows release 8.1.7.
I have a data feed file 'XYZ.ctl' which contains numerous records.Each record is having various data. This data is subdivided into fields seprated by '~'.
Each field can be of variable length. Thus my data per line is represented as below:
1)A~BG~1223~023456~AW3456DF~001~desc1~002~desc2~~~~~~~~~~~~
2)A~MN~1423~073453~AW56DF~001~desc11~002~desc22~003~desc33~~~~~~~~~~~~~~~~~~
Here the point that is to be noted is each field ends with '~'.
Now I would like to push data from 'A' to 'AW3456DF' of 'record 1' to Table X and from there on i.e from '001' to 'desc2' to Table Y.
Similarly for record 2 I would like to push data from 'A' to 'AW56DF' to Table X and from there on i.e from '001' to 'desc33' to Table Y.
This has to be achieved through SQL*Loader. Can it be achieved? If not then is there another way? Actually much of the loading that is done in production is already present and working fine. We just need to implement
the above functionality.
Another point is that the numeric part i.e. '001' would go in column 'Col1'and the description part i.e 'desc1' would go in column 'Col2' of table Y.
Please let me know if anything could be done.
Thanking in advance.
RajeevUTL_FILE
With the UTL_FILE package, your PL/SQL programs can read and write operating system text files. UTL_FILE provides a restricted version of operating system stream file I/O.
UTL_FILE I/O capabilities are similar to standard operating system stream file I/O (OPEN, GET, PUT, CLOSE) capabilities, but with some limitations. For example, you call the FOPEN function to return a file handle, which you use in subsequent calls to GET_LINE or PUT to perform stream I/O to a file. When file I/O is done, you call FCLOSE to complete any output and free resources associated with the file.
http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96612/u_file.htm#ARPLS069
Joel P�rez -
Help needed in SQL Loader-Urgent..!
Hi All,
I am having a staging table with 4 columns, I have to insert
values in 3 of the columns from a CSV file using SQl Loader( The
CSV file has only 3 columns in it) and a default value has to be
inserted in to the 4th column.How can I attain this?? Can I have
this default
value logic written in the Control file used for the data insert? If
yes, Please tell me how..
Thanks,
Vidyadid you refer the doc before posting this question?
http://download.oracle.com/docs/cd/B10501_01/server.920/a96652/toc.htm -
Help Needed regarding SQL Loader Error
Hi,
I am trying to insert some records into two tables using same control file.
I am using the follwing command to load data
sqlload "$ORAUSER" CONTROL="$LDRFILE" DATA="$DATA_PATH/$DATA_FILE" BAD="$BAD_FILE" LOG="$LOG_FILE" DISCARD="$DISCARD_FILE" ERRORS="$MAX_ERRS"
I am getting the error: SQL-LOADER - 350: Illegal combination of non-alphanumeric characters
#!/bin/ksh
Please suggest me what I need to do.
Thanks,
Srinivas.it appears that you are using this line code in your korn shell script. if you try to do a manual run on the unix command line do you still get the same error?
also can you post a sample value for all the parameters you have. -
Expert help needed with tricky query
I have a query database with a real simple schema but a tricky requirement: i need to display records with a simple select but then filter the result based on the authority/access level of the user making the query.
The source data is held in a table with just the following columns:
SRCTABLE:
subject_ID
date
data_ID
data_item
All column types are text strings and the first 3 are a composite key. There are 10s of millions of records in the table.
The access authorization is held in another table with the following columns:
ACCTABLE:
data_ID
access1
access2
accessn
The ellipsis means there are as many (boolean type) access1...n columns as there are distinct access levels to the source data.
The table contains one row for each distinct data_ID appearing in the source table. On each row the TRUE values in the access1...n columns indicate authorization to see the data item and the filter should leave that row in the result set.
The question then is how to write the query statement? It is assumed that the access id (i.e. the relevant column) is known when the query is made.
Something like
SELECT data_item FROM SRCTABLE
WHERE subject_ID="xxx" AND date = "1/1/2000";
would do it except for the need to filter each row based on the access authorization of the user.
Any help would be appreciated.Thanks everybody for responding.
APC has a good point about really protecting every single item type separately. Unfortunately this is precisely the case. The security in this case is not oriented to increasing security in a levels oriented way. Rather each kind of item is protected by a need to know type security related to that particular item. Users are classified by their need to know a combination of the item types and those combinations are not in any sense consistent (and there will be new classes over time). This way access control necessarily becomes a matrix of item types vs access classes.
Fortunately this particular database does not exist yet so i am free to solve the problem in any way that fulfills the requirement. This is just the suggested form. I am not entirely happy with it hence the question on this forum in the first place.
So, i appreciate it should you have any further suggestions for optimal solution to handle the requirements. Again, those are:
1. A query that returns the data_items for a given ID and date (this is dead simple)
2. A filter (preferably in the query) that filters out those data_items the current user (his/her access class is known) is not authorized to see.
3. The plan calls for a table listing every possible item type with a column for each access class, enumerating the items allowed for that class. Any other solution to this issue would be acceptable provided it is capable to independently validate any single item type against any access class.
I hope this makes sense. -
I have to create a join of two tables with the following fields:
User_x
Full_Name
Login_Name
Group_List
Group_x
Group_name
Groupid
In User_x table grouplist comprises of list of groups a user belongs to separated by a semi colon. e.g. 12;78;65
Now I need to create a join where I get a list of all the users with the group they belong to.
The result set should look like this
User Groupname
Tom Group1
Peter Group2
Kathy Group2
and so on...
Actual SQL wil be appreciated.
ThanksHi
Try this:
select use_name, group_name
from user_x u, group_x g
where instr(group_list, ';'||group_id||';') <> 0
or substr(group_list, 1, instr(group_list, ';')-1) = group_id
or substr(group_list, instr(group_list, ';', -1)+1) = group_id;
Ott Karesz
http://www.trendo-kft.hu -
Help needed with sql long names
i need help bringing in column names as the short name. currently my select statment is bringing in the sql longname. is there a way to bring in the short name specified in my db2 database. my code for my connection is as follows:
driver =(Driver) Class.forName "com.ibm.as400.access.AS400JDBCDriver");
DriverManager.registerDriver(driver);
conn = DriverManager.getConnection("jdbc:as400://system;date format=iso;", props);Try setting the sys property on the properties object.
You can set a '.' or '/' for system or sql naming conventions! -
Expert help needed with HSlider
I am using HSlider to filter minimum/maximum product prices from an ArrayCollection and am having trouble with the slider thumbs:
The thumbs are supposed to appear at the extreme left and right ends of the slider. It works fine when I hardcode the prices in the 'values' property of the slider – say, like this:
values = "[5.00,100]".
But when I populate those values from AC data, like this,
values = "[minPrice,maxPrice]",
the thumbs both appear, one on top of the other at the extreme left, looking like there is only one thumb. When I drag the maxPrice thumb to the right, everything works as expected from then on, so I know the slider is getting the right data.
All I need is those thumbs appearing at both ends like they are supposed to.
Any ideas would be highly appreciated.
Regards,
CarlosThat did it, Peter. I had tried:
values = "[minPrice,maxPrice]",
values = "[{minPrice,maxPrice}]" and
values = "[{minPrice},{maxPrice}]",
following all the samples I had seen.
But I never thought of enclosing the whole expression with the curly brackets.
Thank you very much!
Carlos -
Hi,
i have a function like below. basically what it does is, check whether first 2 places of a column_name is *'N_'*. if yes then i am replacing column_name which has *'N_' to ''*
CASE WHEN SUBSTR(column_name,1,2) = 'N_' THEN
*':NEW.'||REPLACE(column_name,'N_','')*
i designed this based on the requirement. now i am facing a small issue. i have a column name 'RGN_ID'. so the above function replaces the RGN_ID as RGID as N_ comes in the middle of the column_name the above function accidentally replaces this as well. wherein i need to replace the first 2 position of column_name which starts like 'N_'
can you please suggest any solution for this?
Edited by: user13178284 on Jun 29, 2010 6:11 AMThanks!. But i am afraid if this would help.
there may be many column names having 'N_' at whatever position. for eg., TRAN_ID. here N_ comes at 4th and 5th position.
i understand i need to place some kind of check above this function.so that if 'N_' comes anywhere in between the column_name i shouldnt replace it instead i should just replace column_name starting wtih 'N_'.
any idea about this? -
Help needed with SQL to split huge data into two excel or text files.
Hi,
I have a table which has around 1850000 records. I want to split the data into two sets and import the data in .txt or execl file.
How can i break upthe records using rownum or any thing
select * from tablename where rownum<940000 fetched some records
but
when i gave select * from tablename where rownum>940000 it was not fetching records.
Guidemewhen i gave select * from tablename where rownum>940000 it was not fetching records.try this
select * from (select tablename.*, rownum rn from tablename) where rn >940000 -
Need help with SQL*Loader not working
Hi all,
I am trying to run SQL*Loader on Oracle 10g UNIX platform (Red Hat Linux) with below command:
sqlldr userid='ldm/password' control=issue.ctl bad=issue.bad discard=issue.txt direct=true log=issue.log
And get below errors:
SQL*Loader-128: unable to begin a session
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
Can anyone help me out with this problem that I am having with SQL*Loader? Thanks!
Ben PrusinskiHi Frank,
More progress, I exported the ORACLE_SID and tried again but now have new errors! We are trying to load an Excel CSV file into a new table on our Oracle 10g database. I created the new table in Oracle and loaded with SQL*Loader with below problems.
$ export ORACLE_SID=PROD
$ sqlldr 'ldm/password@PROD' control=prod.ctl log=issue.log bad=bad.log discard=discard.log
SQL*Loader: Release 10.2.0.1.0 - Production on Tue May 23 11:04:28 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL*Loader: Release 10.2.0.1.0 - Production on Tue May 23 11:04:28 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Control File: prod.ctl
Data File: prod.csv
Bad File: bad.log
Discard File: discard.log
(Allow all discards)
Number to load: ALL
Number to skip: 0
Errors allowed: 50
Bind array: 64 rows, maximum of 256000 bytes
Continuation: none specified
Path used: Conventional
Table TESTLD, loaded from every logical record.
Insert option in effect for this table: REPLACE
Column Name Position Len Term Encl Datatype
ISSUE_KEY FIRST * , CHARACTER
TIME_DIM_KEY NEXT * , CHARACTER
PRODUCT_CATEGORY_KEY NEXT * , CHARACTER
PRODUCT_KEY NEXT * , CHARACTER
SALES_CHANNEL_DIM_KEY NEXT * , CHARACTER
TIME_OF_DAY_DIM_KEY NEXT * , CHARACTER
ACCOUNT_DIM_KEY NEXT * , CHARACTER
ESN_KEY NEXT * , CHARACTER
DISCOUNT_DIM_KEY NEXT * , CHARACTER
INVOICE_NUMBER NEXT * , CHARACTER
ISSUE_QTY NEXT * , CHARACTER
GROSS_PRICE NEXT * , CHARACTER
DISCOUNT_AMT NEXT * , CHARACTER
NET_PRICE NEXT * , CHARACTER
COST NEXT * , CHARACTER
SALES_GEOGRAPHY_DIM_KEY NEXT * , CHARACTER
value used for ROWS parameter changed from 64 to 62
Record 1: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 2: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 3: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 4: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 5: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 6: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 7: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 8: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 9: Rejected - Error on table ISSUE_FACT_TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 10: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 11: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 12: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 13: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 14: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 15: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 16: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 17: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 18: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 19: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 20: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 21: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 22: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 23: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 24: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 39: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
MAXIMUM ERROR COUNT EXCEEDED - Above statistics reflect partial run.
Table TESTLD:
0 Rows successfully loaded.
51 Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.
Space allocated for bind array: 255936 bytes(62 rows)
Read buffer bytes: 1048576
Total logical records skipped: 0
Total logical records read: 51
Total logical records rejected: 51
Total logical records discarded: 0
Run began on Tue May 23 11:04:28 2006
Run ended on Tue May 23 11:04:28 2006
Elapsed time was: 00:00:00.14
CPU time was: 00:00:00.01
[oracle@casanbdb11 sql_loader]$
Here is the control file:
LOAD DATA
INFILE issue_fact.csv
REPLACE
INTO TABLE TESTLD
FIELDS TERMINATED BY ','
ISSUE_KEY,
TIME_DIM_KEY,
PRODUCT_CATEGORY_KEY,
PRODUCT_KEY,
SALES_CHANNEL_DIM_KEY,
TIME_OF_DAY_DIM_KEY,
ACCOUNT_DIM_KEY,
ESN_KEY,
DISCOUNT_DIM_KEY,
INVOICE_NUMBER,
ISSUE_QTY,
GROSS_PRICE,
DISCOUNT_AMT,
NET_PRICE,
COST,
SALES_GEOGRAPHY_DIM_KEY
) -
Sql@loader-704 and ORA-12154: error messages when trying to load data with SQL Loader
I have a data base with two tables that is used by Apex 4.2. One table has 800,000 records . The other has 7 million records
The client recently upgraded from Apex 3.2 to Apex 4.2 . We exported/imported the data to the new location with no problems
The source of the data is an old mainframe system; I needed to make changes to the source data and then load the tables.
The first time I loaded the data i did it from a command line with SQL loader
Now when I try to load the data I get this message:
sql@loader-704 Internal error: ulconnect OCISERVERATTACH
ORA-12154: tns:could not resolve the connect identifier specified
I've searched for postings on these error message and they all seem to say that SQL Ldr can't find my TNSNAMES file.
I am able to connect and load data with SQL Developer; so SQL developer is able to find the TNSNAMES file
However SQL Developer will not let me load a file this big
I have also tried to load the file within Apex (SQL Workshop/ Utilities) but again, the file is too big.
So it seems like SQL Loader is the only option
I did find one post online that said to set an environment variable with the path to the TNSNAMES file, but that didn't work..
Not sure what else to try or where to look
thanksHi,
You must have more than one tnsnames file or multiple installations of oracle. What i suggest you do (as I'm sure will be mentioned in ed's link that you were already pointed at) is the following (* i assume you are on windows?)
open a command prompt
set TNS_ADMIN=PATH_TO_DIRECTOT_THAT_CONTAINS_CORRECT_TNSNAMES_FILE (i.e. something like set TNS_ADMIN=c:\oracle\network\admin)
This will tell oracle use the config files you find here and no others
then try sqlldr user/pass@db (in the same dos window)
see if that connects and let us know.
Cheers,
Harry
http://dbaharrison.blogspot.com -
Problem with loading file with SQL loader
i am getting a problem with loading a file with SQL loader. The loading is getting
terminated after around 2000 rows whereas there are around 2700000 rows in the file.
The file is like
919879086475,11/17/2004,11/20/2004
919879698625,11/17/2004,11/17/2004
919879698628,11/17/2004,11/17/2004
the control file, i am using is like:-
load data
infile 'c:\ran\temp\pps_fc.txt'
into table bm_05oct06
fields terminated by ","
(mobile_no, fcal, frdate )
I hope, my question is clear. Please help, in solving the doubt.
regards.So which thread is telling the truth?
Doubt with SQL loader file wih spaces
Are the fields delimited with spaces or with commas?
Perhaps they are a mixture of delimiters and that is where the error is coming in? -
Ignoring constraints with SQL*Loader & triggers
When I load a table with SQL*Loader that has foreign key constraints and a before insert trigger, my foreign key constraints are ignored. The end result is a detail table that contains invalid rows (where some column values do not exist in the master table). If I drop the trigger and just load with SQL*Loader, the foreign key constraints are recognized. Any ideas why this is happening? The trigger simply populates the last updated date and user columns.
I found this from Asktom very nice. It will help u a lot.
http://asktom.oracle.com/pls/ask/f?p=4950:9:1988009758486146475::NO:9:F4950_P9_DISPLAYID:8806498660292
Maybe you are looking for
-
Contacts and calendars won't sync with Windows 7 PC
Just had to buy a new pc (only because my MacBook got stolen) and I set up the iCloud on the machine but my calendars and contacts will not sync with Outlook 2010. Bookmarks, pictures will, but contacts and calendars say they cannot start the operat
-
Mysql problem with german special characters
hi, I wrote a software and it worked quite good, but after I installed it on a new machine with j2se 1.4 I've problems with the german special characters. this code works good on the old machine (jdk 1.3.1) and prints the wanted characters like �,�,�
-
Can i get OS Lion if i'm using OS X 10.4?
Can i get OS Lion if i'm using OS X 10.4? I have an iMac with 10.4
-
Query on Web , Enhanced menu- Query properties- Transfer button not working
Hello to all experts, When We execute a query from query designer on to the web, if a user wants to go to Enhanced menu->Query properties and select any of the options existing there example "Tabular view, supress zeros ect ect " when he clicks on th
-
Problem with JPEG files from Leica M and GPS data
It seems there's a serious bug in Camera Raw 8, hosted in Bridge CS6 on an MS Windows machine, with regard to GPS metadata. When using a Leica M (Typ 240) with a multi-function handgrip then both the DNG files (DNG is Leica's native raw format) and t