Possibility of capturing data file name in SQL * Loader
Hi,
I have a requirement to capture the data file name in the staging table, is there a way that i can capture it in SQL * Loader or any other way of doing it.
Need experts suggestion please.
Thanks,
Genoo
Hi Genoo.
how do we capture the file name and stores in the temporary table
You may use the above command mentioned in my previous post (if Linux) to populate the Test.csv file with the available file name in the directory, i.e:
ls /some/path/*.dat | xargs -n1 basename > /home/oracle/Test.csv
1. Ensure to first load the Test.csv file as for eg:
1,aaa
2,bbb
3,ccc
2. Create a control file to load these records into temporary tables,for eg:
load data
infile '/home/oracle/Test.csv'
into table file_name_upload
fields terminated by ","
( id, file_name )
3. Create the respective table in the database:
create table file_name_upload
id number,
file_name varchar2(20)
4. Load the data into temporary table
sqlldr test/test control=/home/oracle/sqlldr_test.ctl
Please refer notes:
SQL*Loader - How To Load A Date Column With Fractions Of Second (Doc ID 1276259.1)
Script To Generate SQL*Loader Control File (Doc ID 1019523.6)
SQL*Loader performance tips (Doc ID 28631.1)
How To use the Sequence Function of SQL*Loader (Doc ID 1058895.6)
How to Get Data from Existing Table to Flat File Usable by SQL*Loader (Doc ID 123852.1)
Also see link:
10 Oracle SQLLDR Command Examples (Oracle SQL*Loader Tutorial)
Thanks &
Best regards,
Similar Messages
-
Can We rename BAD File name in SQL Loader
Hi All,
Can we rename BAD File name in SQL loader?
If yes, how?
Thanks in Advance,
SHi,
You can rename the bad file before running SQL*Loader, or specify the name of the bad file using the BADFILE clause followed by a filename. If you do not specify a name for the bad file, the name defaults to the name of the datafile with an extension or file type of .bad
Specifying the Bad File
http://download.oracle.com/docs/cd/B28359_01/server.111/b28319/ldr_control_file.htm#i1005085
Regards,
Hussein -
Is it possible to know the file name of images loaded?
Hi:
I have a folder containing some images named 01_image_name.jpg, 02_image_name.jpg, 03_image_name.jpg, ... wich names I read with a PHP script. Then I loop loading each image and waiting until all are loaded to display them
1. The PHP script reads file names and returns a string with names separated by a "|" char, then I use the split method to store them in imagesNames array and sort it
2. I loop trough imagesNames array loading images
3. Anytime a new image arrives I push it in imagesContainer array and check if all images are loaded to show them
The problem is there's no guarantee they arrive in the same order they were requested. So, how I sort the imagesContainer array by file name, i.e. in the same order they are in imagesNames array?
Thanks in advanceif you know when a new image arrives and you can retrieve that new image file name ...
Well, that's precisely my doubt, how can I know the file name? Is there a property/method for it?
function loadImages() {
for (var i:int=0; i<imagesNames.length; i++) {
var imgLoader:Loader=new Loader;
imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,imgLoaded);
imgLoader.load(new URLRequest(imgPath + imagesNames[i]));
function imgLoaded(par:Event):void {
trace(par.target,par.target.content,par.target.content.name);
Output window:
[object LoaderInfo] [object Bitmap] instance160
[object LoaderInfo] [object Bitmap] instance159
[object LoaderInfo] [object Bitmap] instance161 -
Insert data file name into table from sql loader
Hi All,
I have a requirement to insert the data file name dynamically into table using sql loader.
Example:
sqlldr userid=username/passwword@host_string control=test_ctl.ctl data=test_data.dat
test_ctl.ctl
LOAD DATA
FILED TERMINATED BY ','
INTO TABLE test
(empid number,
ename varchar2(20),
file_name varchar2(20) ---------- This should be the data file name which can be dynamic (coming from parameter)
test_data.dat
1,test
2,hello
3,world
4,end
Please help..
Thanks in advance.
Regards
Anujyou'll probably have to write your control file on the fly, using a .bat or .sh file
rem ===== file : test.bat ========
rem
rem ============== in pseudo speak =============
rem
rem
echo LOAD DATA > test.ctl
echo FILED TERMINATED BY ',' >> test.ctl
echo INTO TABLE test >> test.ctl
echo (empid number, >> test.ctl
echo ename varchar2(20), >> test.ctl
echo file_name constant %1% >> test.ctl
echo ) >> test.ctl
rem
rem
rem
sqlldr userid=username/passwword@host_string control=test.ctl data=test_data.dat
rem =============== end of file test.bat =======================
http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/ldr_field_list.htm#i1008664 -
Want To Capture The File name Using the SQL Loader
Hi,
I Am loading The Data To Staging Table Using The SQL*developer, The File That need to be Loaded Will be One Of The Input To the SQL*Loader Concurrent Program.
In One Of The Column Of My staging Table I want To Put The File name.
Can We do the Same.
thanks,
AnkitNot unless you generate the loader controlfile dynamically.. try this.. pass file name as $1 first parameter. Use the below example and modify as per your requirement
1) create table with following table structure
create table temp_table (x varchar2(20),file_name varchar2(30));
2) create data file - test.dat (contains only values for x)
abc
def
geh
ggg
fff
3) create a host file host file - test.sh with following content:
echo "load data
infile $1
append
into table temp_table
fields terminated by ','
(x,
file_name constant "$1")" > test.ctl
sqlldr <usr>/<pwd>control=test.ctl
4) run the host file from unix prompt with data file name as parameter (ensure test.sh has execute permissions)
test.sh test.dat
Hope this helps
Regards,
Bhadri -
SQL*Loader to insert data file name during load
I'd like to use a single control file to load data from different files (at different times) to the same table. I'd like this table to have a column to hold the name of the file the data came from. Is there a way for SQL*Loader to automatically do this? (I.e., as opposed to running an update query separately.) I can edit the control file before each load to set a CONSTANT to hold the new data file name, but I'd like it to pick this up automatically.
Thanks for any help.
-- HarveyHello Harvey.
I've previously attempted to store a value into a global/local OS variable and use this within a SQL*Loader control file (Unix OS and Oracle versions between 7.3.4 and 10g). I was unsuccessful in each attempt and approach I could imagine. It was very easy to use a sed script to make a copy of the control file, changing a string within it to do this however.
Do you really want to store a file name on each and every record? Perhaps an alternative would be to use a relational model. Create a file upload log table that would store the file name and an upload # and then have the SQL*Loader control file call a function that would read that table for the most recent upload #. You'll save some disk space too.
Hope this helps,
Luke -
Sql loader:loading data file name to one of the tabe column.
Hi,
I want to load the data file name also to one of the table column.
Table structure:
File_Name varchar2
Name varchar2
Age number
Data File Format:
Vijay|24
Anandh|24
Senthil|26
In the above eg how to write a control file to load the data file name to the File_Name column of the table.
Note:
The shell script will first pick up the data files to be loaded and calls the control file.
Thanks,
Vijay.From a unix load perspective this is what we have done :
Create a control file (say load_data.ctl) something like
LOAD DATA
append
Into table file_name_age
File_Name constant '<FILENAME>',
Name CHAR TERMINATED BY '|'
Age INTEGER EXTERNAL TERMINATED BY '|' )
in a unix loop do the following
for i in `ls $LOADDIR` ; do
#Replace <FILENAME> with actual filename and create a temp ctl file
sed s/\<FILENAME\>/${1}/g < ${CTLDIR}/load_data.ctl > ${TMPDIR}/load_data_${1}.ctl
#load using temp file
sqlldr / CONTROL=${TMPDIR}/load_data_${1}.ctl
DATA=$i
#remove temp
rm ${TMPDIR}/load_data_${1}.ctl
done
Where
${TMPDIR}=your temp directory
${CTLDIR}=where your main directory for ctl files
$LOADDIR=Your data directory -
How to store data file name in one of the columns of staging table
My requirement is to load data from .dat file to oracle staging table. I have done following steps:
1. Created control file and stored in bin directory.
2. Created data file and stored in bin directory.
3. Registered a concurrent program with execution method as SQL*Loader.
4. Added the concurrent program to request group.
I am passing the file name as a parameter to concurrent program. When I am running the program, the data is getting loaded to the staging table correctly.
Now I want to store the filename (which is passed as a parameter) in one of the columns of staging table. I tried different ways found through Google, but none of them worked. I am using the below control file:
OPTIONS (SKIP = 1)
LOAD DATA
INFILE '&1'
APPEND INTO TABLE XXCISCO_SO_INTF_STG_TB
FIELDS TERMINATED BY ","
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
COUNTRY_NAME
,COUNTRY_CODE
,ORDER_CATEGORY
,ORDER_NUMBER
,RECORD_ID "XXCISCO_SO_INTF_STG_TB_S.NEXTVAL"
,FILE_NAME CONSTANT "&1"
,REQUEST_ID "fnd_global.conc_request_id"
,LAST_UPDATED_BY "FND_GLOBAL.USER_ID"
,LAST_UPDATE_DATE SYSDATE
,CREATED_BY "FND_GLOBAL.USER_ID"
,CREATION_DATE SYSDATE
,INTERFACE_STATUS CONSTANT "N"
,RECORD_STATUS CONSTANT "N"
I want to store file name in the column FILE_NAME stated above. I tried with and without constant using "$1", "&1", ":$1", ":&1", &1, $1..... but none of them worked. Please suggest me the solution for this.
Thanks,
AbhayPl post details of OS, database and EBS versions. There is no easy way to achieve this.
Pl see previous threads on this topic
SQL*Loader to insert data file name during load
Sql Loader with new column
HTH
Srini -
Date, File name, User Stamp
I've looked for hours for a script that will work in Illustrator CS4 that will put a text block on the page identifying:
Date, File Name and the User's name on the document (art board)
I am not versed in scripting. Can anyone help me out?Hi Y'all This post is where scripting all started for me. At the time I didn't know anything and Muppet Mark kindly helped me out. Since then I have learned Applescript and written my slug script in that. This has the advantage of being able to access system information. Here it is:
-- captures the user's first name from the system for use in dialog boxes
set myName to (long user name of (system info))
set sp to (offset of " " in myName)
set myFirstName to text 1 thru (sp - 1) of myName
-- captures the user's short name from the system for use in the slug
set myShortName to (short user name of (system info))
set myInitials to text 1 thru 2 of myShortName
tell application "Adobe Illustrator" to set myDocCount to count of documents
if myDocCount > 0 then
tell application "Adobe Illustrator"
try
set myPath to file path of document 1 as alias -- if the document is not saved this will cause an error
on error
display dialog "You haven't saved document yet " & myFirstName & "." buttons {"Cancel", "Save"} default button 2
-- brings up Save As dialog box
tell application "System Events" to tell process "Adobe Illustrator"
click menu item "Save As..." of menu 1 of menu bar item "File" of menu bar 1
tell application "Finder"
set filesavepath to "/Volumes/Server/Folder" -- put your own file path in here
end tell
delay 0.2
tell window "Save As"
keystroke "g" using {command down, shift down}
repeat until exists sheet 1
delay 0.5
end repeat
tell sheet 1
keystroke filesavepath
click button "Go"
end tell
end tell
end tell
-- end Save As dialog box
return
end try
set myFile to name of document 1
set myFolder to myPath as string
-- this section looks at the file info to get the file version information
set myFileVersion to my getVersion(myPath)
set AppleScript's text item delimiters to "Created"
set myFileVersion to text item 1 of myFileVersion
if myFileVersion is "Saved As v.15 " then
set myFileVersion to "Illustrator CS5"
else if myFileVersion is "Saved As v.14 " then
set myFileVersion to "Illustrator CS4"
else if myFileVersion is "Saved As v.13 " then
set myFileVersion to "Illustrator CS3"
else if myFileVersion is "Saved As v.12 " then
set myFileVersion to "Illustrator CS2"
end if
set AppleScript's text item delimiters to {""}
-- end of file info
set AppleScript's text item delimiters to ":"
set clientFolder to text item 3 of myFolder -- always picks out the client folder on our server
set AppleScript's text item delimiters to {""}
if clientFolder contains "_" then
set clientFolder to my cleanName(clientFolder) -- to format the client names properly
else
set clientFolder to clientFolder
end if
-- find the current date. This is the date when the file was last edited but this method enables you to run the script before saving
tell application "Finder"
set myDate to (current date) as string
end tell
set myDate to (word 2 of myDate) & " " & (text 1 thru 3 of word 3 of myDate) & " " & (word 4 of myDate) as string
-- end find date
-- checks for the correctly named frames and then populates with the correct information
if exists (text frame "titleblock-software" of document 1) then
set contents of text frame "titleblock-software" of document 1 to myFileVersion
end if
if exists (text frame "titleblock-client" of document 1) then
set contents of text frame "titleblock-client" of document 1 to clientFolder
end if
if exists (text frame "titleblock-file" of document 1) then
set contents of text frame "titleblock-file" of document 1 to myFile
end if
if exists (text frame "titleblock-path" of document 1) then
set contents of text frame "titleblock-path" of document 1 to myPath as string
end if
if exists (text frame "titleblock-date" of document 1) then
set contents of text frame "titleblock-date" of document 1 to myDate
end if
if exists (text frame "titleblock-editor" of document 1) then
set contents of text frame "titleblock-editor" of document 1 to myInitials
end if
if exists (text frame "titleblock-version" of document 1) then
set versionCount to get contents of text frame "titleblock-version" of document 1
set versionCount to (versionCount + 1)
set contents of text frame "titleblock-version" of document 1 to versionCount
end if
-- end populating named frames
end tell
end if
-- this handler is to get the version of the file
on getVersion(added_item)
set myFileVersion to long version of (info for added_item)
end getVersion
-- this handler converts every 'odd' character to an underscore, modify as needed
on cleanName(newName)
set chars to every character of newName
repeat with i from 1 to length of chars
if item i of chars as text is equal to "_" then
set item i of chars to " "
end if
end repeat
return every item of chars as string
end cleanName -
How to Capture the File Names of any extension using ssis
Hello,
Can you please let me know on how to Capture the File Names of any extension(EG : xls,text,.csv etc) at a time and stores in excel file using SSIS?
Any help would be appreciated.
Thanks,
Vinay sIf you need to act differently on each file type separately or if not all types of files are wanted, i.e. the Filespecifier cannot be *.* in the Foreach loop:
In the ssis package
make 3 variables:
to store the file extension, e.g. User::CurrentExtension of type string
to store the filename found in the directory: @CurrentFilename
to store the name of the directory where the files reside e.g. User::CurrentDirectory
make a foreach loop of type Foreach Item enumerator:
in the items list you add each file extension that you need
txt
csv
xls
xlsx
As Variable mappings map the CurrentExtension to Index 0
Inside this foreach loop add another foreach loop of type Foreach File enumerator, in the collection Expressions
add Expression Directory , set to @[User::CurrentDirecotry]
add Expression FileSpec, set to "*." + @[User::CurrentFileExtension]
In the Variable mappings, map Variable user::CurrentFilename to Index 0
Inside this loop use Execute SQL Task to insert the filename in a Excel connection.
Jan D'Hondt - SQL server BI development -
Is it possible to know flat files names loading using particular info pack
hi experts ,
is it possible to know flat files names loading using particular info package ??
in our project we hav flat file extraction manually ...as i am replacing old sap bi consultant i must contine pending loads ..
as ther s no document about loads i must check and ensure about loads left out ..'
for every flatfile they used load with differnt name ... if am able to get those files name i can list out pending ones
and can load
is it possible to those details ??
pls help me .....
relative answer will rearded with points ............
thanks in advance
regards
harryI AM REALLY THANK FUL FOR ALL.. your people are really quick .and giving relavtive answers ...
they loaded from desktop only ....not from application server ..
i got details from info cube mange screen .they used to load data monthly wise ,so i hav given month in selection and viewed data..
Regards ,
Harry -
Loading the data from a packed decimal format file using a sql*loader.
Hi ,
In one of the project i'm working here i have to load the data into oracle table from a file using a Sql*loader but the problem is the data file is in the packed decimal format so please let me know if there is any way to do this....I search a lot regarding this ..If anybody faced such type of problem ,then let me the steps to solve this.
Thanks in advance ,
Narasingarao.declare
f utl_file.file_type;
s1 varchar2(200);
s2 varchar2(200);
s3 varchar2(200);
c number := 0;
begin
f := utl_file.fopen('TRY','sample1.txt','R');
utl_file.get_line(f,s1);
utl_file.get_line(f,s2);
utl_file.get_line(f,s3);
insert into sampletable (a,b,c) values (s1,s2,s3);
c := c + 1;
utl_file.fclose(f);
exception
when NO_DATA_FOUND then
if utl_file.is_open(f) then utl_file.fclose(f); ens if;
dbms_output.put_line('No. of rows inserted : ' || c);
end;SY. -
In mini bridge, is it possible to view the file name and the rating at the same time?
Hello,
In mini bridge, is it possible to view the file name and the rating at the same time?
Thank you.if you know when a new image arrives and you can retrieve that new image file name ...
Well, that's precisely my doubt, how can I know the file name? Is there a property/method for it?
function loadImages() {
for (var i:int=0; i<imagesNames.length; i++) {
var imgLoader:Loader=new Loader;
imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,imgLoaded);
imgLoader.load(new URLRequest(imgPath + imagesNames[i]));
function imgLoaded(par:Event):void {
trace(par.target,par.target.content,par.target.content.name);
Output window:
[object LoaderInfo] [object Bitmap] instance160
[object LoaderInfo] [object Bitmap] instance159
[object LoaderInfo] [object Bitmap] instance161 -
Is it possible to show data from two different sql tables?
Is it possible to show data from two different sql tables? Either to show combined data by using a join on a foreign key or showing a typical master detail view?
I have one table With data about a house, and another table With URL's to images in the blob. Could these two be combined in the same Gallery?
Best regards Terje F - NorwayHi Terje,
If you have a unique key, you could use one of the following functions for your scenarios:
If you only have one image per house, you can use LookUp:
http://siena.blob.core.windows.net/beta/ProjectSienaBetaFunctionReference.html#_Toc373745501
If you have multiple images per house, you can use Filter:
http://siena.blob.core.windows.net/beta/ProjectSienaBetaFunctionReference.html#_Toc373745487
Thanks
Robin -
SQLLoader: Uploading data file name along with data
I am using Oracle SQLLoader to upload my data from CSV files into a single table. My current CTL file is as follows:
LOAD DATA
INFILE 'trace_metals100.csv'
INFILE 'trace_metals101.csv'
APPEND
INTO TABLE TRACE_METALS
FIELDS TERMINATED BY ','
(STATION_NO, METAL_NAME, METAL_WT)
Just for my record I want to upload the data file name also along with the data into a fourth column. How should I do it using SQLLoader??
Regards,
MoizDo two loads using two separate control files:
LOAD DATA
INFILE 'trace_metals100.csv'
APPEND
INTO TABLE trace_metals
FIELDS TERMINATED BY ','
TRAILING NULLCOLS
(station_no,
metal_name,
metal_wt,
fourth_column_name CONSTANT trace_metals100.csv)
LOAD DATA
INFILE 'trace_metals101.csv'
APPEND
INTO TABLE trace_metals
FIELDS TERMINATED BY ','
TRAILING NULLCOLS
(station_no,
metal_name,
metal_wt,
fourth_column_name CONSTANT trace_metals101.csv)
Maybe you are looking for
-
Hi, Finally set up my Mail client and I can't get my to-do's to show up automatically in iCal. Not sure what i am doing wrong...i set a date and choose a calendar but nothing comes up. Any suggestions much appreciated! Thanks
-
Hello, I have a BlackBerry 9300 and i have contact problems with my phone. I tried to sync my contacts with Funambol but, when the sync is done, I can't read or delete my contacts. My BB's OS version is 5.0. So, I upgraded my BB to 6.0, then I didn't
-
Abstract Portal Component and javascript
Hi I'd written a Portal Abstract Component class in which i'm getting some values from a file and displaying the content as HTML in response.write() I'm getting a xml and with xslt i'm converting it into HTML. so in my html, there are some HREF links
-
Get PDF Display Page Number Acrobat Reader
Hi, I am working on some automation in that I used Acrobat Reader XI to view PDF. I want to get display page number of opened PDF. I used app.doc.pageNum(); It is giveing me the page number when I used this code in Acrobat Debuger manually. But I am
-
My phone is trying to send an email that it can't send. The message is in the Outbox. I would like to delete the message but as long as the message is trying to send it, I am unable to. Is there any way to tell it to stop sending so that I can delet