File name in UTL_FILE
I'll have to open files for reading from Unix
and parse them and Update the DB in Oracle 8i.
I am using
V_file := UTL_FILE.FOPEN(V_dir, V_fileName, 'r');
BUT, the quistion is I'll have date ant time in my file name like
file_name_date_time.
How CAN I USED WILD CARD FOR FILE NAMES, LIKE
FILE_NAME_*
AND USED IT IN
V_file := UTL_FILE.FOPEN(V_dir, V_fileName, 'r');
Thanks a lot
An alternative option could be by using a Unix Shell script. You could create a shell script that will find your file(s) and then invoke your procedure via SQL*Plus using the file as an input parameter. I had a similar scenario and had the possibility that many files could reside in the utl_file_dir and used this example..
-David
Similar Messages
-
How to upload data using utl_file when you dont know the exact file name
Hi
i want to upload data from a flat file to a table.
i dont know the exact file name. i want to make a search for filename. like i want to make a search on file (say test*) which will give me all the files with test.
i want to upload data using these files.
how can i do this by using UTL_FILE.
Regards
ManishThank you very much.
Thing is previously we are using sqlloader and shell script for loading the data.
now i am creating a procedure (if possible without parameters).
Is there any other way i can do that.
can i make a wild card search using utl_file.
Thanks n Regards
Manish -
UTL_FILE & User Input: Case Sensitive File Names
Hi.
I'm trying to reduce problems due to the whether the user uses upper or lower case or combo of them in entering file names.
Scenario is:
Existing file to be read: Orig_File.Txt (file name changes daily)
Output to be saved into file: RESULTS_FILE.TXT
In response to PL/SQL commands (please see below), the user enters:
ORIG_FILE.TXT and Results_FILE.txt
as the Input & Output file names. The problem is that the input file has been saved using Upper and Lower case and I get back a file not found error.
Is there a way to call a file with is a different case than the input?
Thanks.
Current commands are:
In_File UTL__File.file_type;
Out_File UTL__File.file_type;
Curr_Line VarChar2(2000);
BEGIN
In_File := UTL__File.fopen('UTIL_FILE_DIR', '&input_file', 'R', 2048);
Out_File := UTL__File.fopen('UTIL_FILE_DIR', '&output_file', 'W', 2048);
LOOP
BEGIN
UTL__File.get_line(In_File, Curr_Line, 2048);
.......A shell script would typically issue something along the lines of
newfile=$(ls -C1 | grep -i "\<${filename}\>")although of course it is possible for this to match multiple filenames, so it would have to check for that scenario and report it as an error. possibly you could call a shell script like this from PL/SQL via Java or DBMS_SCHEDULER. Good luck with that though. -
Loading text files, but the file name is variable
I'm working on a project that will be converting loaded files to some format using an oracle table (external table or otherwise) the problem is that i need to trick the loader so that i dont specify the original file name. the already processed files shall be deleted basically. but how to tell the loader to grap the first file from directory (say using FIFO)wait until the load is done, spool the new format into another dir then load the second file. i was thinking of UTL_FILE in 9iR2 can RENAME a file. So, the external table could be based on
"current_file_to_process.dat" and you would frename a file to be "current".Hi Paras,
Based on your description, it is not the VS IDE issue, if it is related to the SSIS, I suggest you post the issue in this forum here:http://social.msdn.microsoft.com/Forums/sqlserver/en-US/home?forum=sqlintegrationservices
, and there you would get better response.
Best Regards,
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Reading from file where file name is not exactly known.
Hi,
I have to read a file using utl_file. But the file name is not exactly known.
The file name would be of the syntax uplldr_XXXX.CSV , where XXXX can be any thing like 1234. so file name would be uplldr_1234.csv in that location.
How can I search the file in the specified location and process the file with name begins with 'uplldr_' .
Hope I am clear to express my needs.
regds,
ajoyHi,
Yes I have to use in PLSQL UTL_FILE.
i.e.
utl_file.fopen(v_file_path,v_file_name, 'r');
and v_file_name is the name of file similar to name of 'uplldr_XXXX.csv', stored in the path v_file_path. Considering there is only one file in the specified path.
Regds,
ajoy -
Appending date and time to file created in UTL_FILE
I am trying to create a log file of database (9i) updates using PL/SQL code and I am able to create a file using UTL_FILE utility and in file name I give name as 'log-'||sysdate||'.txt' and it successfully cerates log-22-NOV-05.txt file.
My problem is adding time to it. I declared a varibale ws_var1 and capture time in it by below statement.
select to_char(sysdate,"HH24:MM:SS') into ws_var from dual.
SO when I try to add this to file name as 'log-'||sysdate||'-'||ws_var1||'.txt' the file that gets created is just two number such as 02.txt, 34.txt etc.
I am not sure where the problem is but any help to create file name with date+time information is apperciated.
ThxWhy not just:
'log-'||TO_CHAR(sysdate, 'DD-MON-YYYY-HH24MISS')||'.txt'
SQL> select 'log-'||TO_CHAR(sysdate, 'DD-MON-YYYY-HH24MISS')||'.txt' from dual ;
'LOG-'||TO_CHAR(SYSDATE,'D
log-22-NOV-2005-170813.txt
1 row selected.
SQL> -
CSV file reading using UTL_FILE at run time
Hi,
I have to read CSV file using UTL_FILE.
but Folder contains Many CSV files.
I dont know there name.So i have to read csv file at run time.
Please let me know how should we achieve this?
Thanksplace the following in a shell script, say "list_my_files.ksh"
ls -l > my_file_list.datthen run the shell script using dbms_scheduler;
begin
dbms_scheduler.create_program (program_name => 'a_test_proc'
,program_type => 'EXECUTABLE'
,program_action => '/home/bluefrog/list_my_files.ksh'
,number_of_arguments => 0
,enabled => true);
end;
/then open "my_file_list.dat" using UTL_FILE, read all file names and choose the one you require.
P; -
Creating dynamical flat file name in mapping?
Hi.
I know about the variations on how to use an input parameter and/or sysdate to create a dynamic output file name in a mapping.
My challenge is nearly the same, but I cannot make OWB generate the correct code.
Problem:
- got a one column table that holds an identifier in a string field
- got a function that reads and returns said identifier
- imported function into OWB
- trying to use the function call in the Flat File Operator's Target Data File Name, e.g. fixedfilename||fn_get_id()||sysdate||'.ext
OWB creates the code:
UTL_FILE.FOPEN(
'my_location',
'fixedfilename'||fn_get_id()||'_'||SYSDATE||'.ext',
'w',
32767
However, when compiling the package code, it returns the warning:
ORA-06550: PACKAGE BODY, line 2214, column 29: PLS-00201: identifier 'FN_GET_ID' must be declared
which results in an error when trying to execute the mapping.
I've tried substituting the function call in the FOPEN call:
myId := fn_get_id();
UTL_FILE.FOPEN(
'my_location',
'fixedfilename'||myId||'_'||SYSDATE||'.ext',
'w',
32767
and this works fine, the mapping creates a file with the desired filename. But obviously not a good solution rewriting the generated code all the time....
Anyone solved something similar?
Could I use an input parameter and the autogenerated function GET_<PARAMETER>?
But can I set the value of an input parameter inside the very same mapping?
Regards,
-Haakon-(It always helps writing out one's problems...)
I managed to get it working :-)
Added an input parameter to the mapping, and gave the outgroup variable a default value by calling my imported function.
Then concatenated the implicitly generated function (GET_PARAMETER) in the Target Data flat file name.
I now have a target file name that changes according to a departement id stored in a parameter table.
Regards,
-Haakon- -
Trying to delete file from trash but get this: The operation can’t be completed because the item “File name” is in use. All other files delete except this one. Please help
Maybe some help here:
http://osxdaily.com/2012/07/19/force-empty-trash-in-mac-os-x-when-file-is-locked -or-in-use// -
Would someone be able to explain to me the following issue with Iphoto?
I ordered 8 same calendars for my soccer team and received them fine. Although a couple of pictures on it are a little off (out of focus). I need to order two more of the same calendars but when I go thru the process ireceive an error message saying:
"Unable to to assemble calendar" There is a problem with the photo with the file name "(Null)" The full resolution version of this photo either cannot be located or is corrupt. Please replace this photo or delete it from your calendar.
How can I fine this "corrupt" photo? How did it go thru with the first batch of calendars but won't go thru now?
Thank you for your help.Apply the two fixes below in order as needed:
Fix #1
Launch iPhoto with the Command+Option keys held down and rebuild the library.
Since only one option can be run at a time start
with Option #4 and then #1 as needed.
Fix #2
Using iPhoto Library Manager to Rebuild Your iPhoto Library
1 - download iPhoto Library Manager and launch.
2 - click on the Add Library button, navigate to your Home/Pictures folder and select your iPhoto Library folder.
3 - Now that the library is listed in the left hand pane of iPLM, click on your library and go to the File ➙ Rebuild Library menu option.
4 - In the next window name the new library and select the location you want it to be placed.
5 - Click on the Create button.
Note: This creates a new library based on the LIbraryData.xml file in the library and will recover Events, Albums, keywords, titles and comments. However, books, calendars, cards and slideshows will be lost. The original library will be left untouched for further attempts at fixing the problem or in case the rebuilt library is not satisfactory.
OT -
I'm trying to organize my music files using iTunes 10.6.1.7 and I keep getting the error message "Copying files failed. The File name was invalid or too long."
I've got music folders by artist in both the iTunes Music folder and the iTunes Media/Music folder. When I add certain files by drag/drop they sometimes get lost and I don't want that to happen anymore. I used to just consolidate my music files using the File/Library/Organize Library option and that worked, however now when I do that, I get the error message.
I'm a novice and the only online stuff I see is both confusing and refers to earlier versions of iTunes.
My concern is that I have heard that people lose entire libraries of their music when they trry to fix things like this and I don't want that. If this is of any importance, I have several files called iTunes library and temp library. I have no idea what that all means but I'm scared to death of it.
Also, I can't get to the "re-organize library" link at all. It won't let me.
One thing that be of some interest is that when I pull up the properties of the music and media/music files they are marked "read only" I'm also afraid to touch that!
Please help and please know that I am a dummy. Be kind and be clear. Step by step would be great, with images even better. Thanks.Perhaps nobody knows the answer? We're fellow users here answering questions in our free time when we think we've something useful to contribute.
You can choose to *Consolidate selected tracks* with a right-click menu. Perhaps if you can identify a specific track that won't consolidate and examine the full path to the file & the path that iTunes would create when it consolidates the problem might become apparent. For example iTunes may not be able to move files if the source or destination path length exceeds 255 characters.
tt2 -
Thanks in advance for taking the time to read this and comment. Platform: Windows Server 2008 R2 Enterprise Edition SP1 (X64) Microsoft SQL Server 2008 R2 (SP1) - 10.50.2500.0 (X64) Jun 17 2011 00:54:03 Copyright (c) Microsoft Corporation
Standard Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)Problem Description: The file name recorded in the msdb.dbo.backupset (sans the extension) no longer matches the actual file name written to the backup media which is
in this case a NETAPP NAS storage share. Example:
Mohave_backup_2014_03_14_233001_1158878.bak (from NETAPP NAS filer)
Mohave_backup_2014_03_16_233001_4167237 (from MSDB.dbo.backupset), as you can see, the last 7 digits (chars) of the file name are different, although the date and time are identical. The
file names had previously been matching perfectly. The first occurance of this problem occured on 03/13/2014 at 5:00 AM MST. The error generated by the job was:
Date 3/14/2014 10:29:23 AM
Log Job History (Refresh - Restore Mohave_93_DEV AD HOC)
Step ID 1
Server OurDevServer
Job Name Refresh - Restore Mohave_93_DEV AD HOC
Step Name Restore Mohave_93_DEV
Duration 00:00:01
Sql Severity 0
Sql Message ID 50000
Operator Emailed
Operator Net sent
Operator Paged
Retries Attempted 0
Message
Executed as user: OurDomain\OurNetworkServiceLogin. Restore Mohave Prod to Mohave_93_DEV - ERROR: 3013 RESTORE DATABASE is terminating abnormally. [SQLSTATE 01000] (Message 50000). The step succeeded.Olaf:
Thanks for your reply. Sorry, my bad. I inadvertently copied wrong [name] form the msdb.dbo.backupset. On 3/13 and 3/14, the two file names did not match. In trying to select another example to show you this morning, I found that the names are now matching!
What I was doing was to create dynamic t-sql to retrieve the latest prod backup of the database, and then restore it with move to the development server. This is an ad-hoc job that the developers can run by themselves whenever they require a refresh. Unfortunately,
we only keep 3 days worth of backups for these databases, so the original disk file I was trying to use to restore no longer exists. Researching the original error, one of the error descriptions was that the restore could not find the file requested.
I thought this very strange since I get the file name directly from the backupset table. Further research did indeed show that the file names were different, but unfortunately, I failed to save the details of the file names. Anyway, in looking for a new example
to show you this morning, I have found that the file names are indeed matching exactly again. If this error pops up again, I will be sure to save all details and re-post.
Thanks, regards and best wishes to you and yours, -
How to create the logical file name
Hi All,
I have requirement where i need to post the Inventory Management data. for this i need to execute std. program RM07MMBL which is having logical file name in the selection screen. but i have placed my input file in application server.
Can any one tell how to create the Logical filename which refers the physical path. I also tried <b>t-code SF01 & Table - FILENAMEC</b>I and found that we need to add an entry in this table but i really dont know how we have to do since this table cannot be maintained in SM30 also..
Help Me.
Thanks in Advance!...
Regards,
RamkumarHi Ram,
Try using FILE transaction code...
Follow these steps to create:::
Double click on Logical file Path Definition
Click on New Entries,
Give Logical file Path name as Z_LOGICAL PATH and save it
now choose this path and double click on Assignemt of Physical path to Logical path
double click on the OS name
Give some description and give some Physical path name from AL11 transaction and save it
Now Double click on Logical File Name Definition,
Click on New Entries,
Give some logical file name: Z_LOGICAL_FILENAME
Physical file: test
Data Format: BIN
Logical Path: Z_LOGICAL PATH
Hope this helps
Regards,
Phani
Message was edited by:
Sivapuram Phani Kumar -
How to Get OHD's file name of last run?
Hi Experts,
I am currently generating a file, through a Process chain, from OHD that contains the BW system timestamp as part of its logical filename. There is a requirement to log the file name generated along with the number of rows..
Is there anyway of getting this informaiton.. Are there any logs that are created for OHDs when they are run that contain this info?
Thanks in advance.
Vjhi,
please see below threads
how to generate the open hub file format as .txt ?
Open HUB Destination
Open Hub Destination
hope this will be helpful to you
regards
laksh -
GET FILE NAME C:\temp\ADIBO.txt
Hi,
How to get file name?
I used Get_File_NAME, but I'am getting an error.
lv_lfilename is not the type LOGICAL_FILENAME
C:\temp\ADIBO.txt
I need to get ADIBO ??
tnh, Adibo..:)
I am using this code to download file and after that I need to get FILE_NAME:
DATA: lv_lfilename TYPE string.
PARAMETERS:
pa_lfile TYPE zlocalfile
DEFAULT 'C:temp'.
CONCATENATE pa_lfile ''INTO lv_lfilename.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = lv_lfilename
filetype = 'ASC'
TABLES
data_tab = it_billit_down.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.Hii..
You have to Maintain the Logical filenames and their Physical Paths in Tcode FILE.
Then create a program like this..
REPORT ZSEL_FILES1.
DATA : V_LOGFILE TYPE STRING.
DATA :V_PHYFILE TYPE STRING.
DATA : ITAB TYPE TABLE OF SCARR.
START-OF-SELECTION.
SELECT * FROM SCARR INTO TABLE ITAB.
**To get the Physical file based on the Logical file names - Maintained in Tcode FILE
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
CLIENT = SY-MANDT
LOGICAL_FILENAME = VlOGFILE
OPERATING_SYSTEM = SY-OPSYS
PARAMETER_1 = ' '
PARAMETER_2 = ' '
PARAMETER_3 = ' '
USE_PRESENTATION_SERVER = ' '
WITH_FILE_EXTENSION = ' '
USE_BUFFER = ' '
ELEMINATE_BLANKS = 'X'
IMPORTING
EMERGENCY_FLAG =
FILE_FORMAT =
FILE_NAME = V_PHYFILE
EXCEPTIONS
FILE_NOT_FOUND = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
**To download the file to PC.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
FILENAME = V_PHYFILE
FILETYPE = 'ASC'
APPEND = ' '
WRITE_FIELD_SEPARATOR = 'X'
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = ITAB
FIELDNAMES =
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
<b>reward if helpful</b>
Maybe you are looking for
-
Updating service order status in CRM from R3 after the invoice is created
Hi all ; I need to update the user status of an service order in CRM when the invoice related to it in R3 is created, so I have already know the service order no . How can i achieve this by sending BDOC from R3 to CRM? Which BDOC should i use?and is
-
How to preset the order of rows in the outer query of a correlated query ?
Good morning, I have the following simple query: select empno, ename, sal, sum(case when rn = 1 then sal else -sal end) over (order by sal, empno) as running_diff from ( select emp
-
Not able to delete inbound delivery.
Hi Gurus, Please help me delete inbound delivery. I have a ticket where user is not able to delete inbound delivery. I tried to delete this delivery and I'm also getting the same errors that user is getting. I have tried to insert real screen shots f
-
Why are excel charts copied to Illustrator CS 5.1 now coming in as pictures?
I've been creating charts in Excel 2004 for Mac for years and copying them into Illustrator. They have always previously pasted into Illustrator as vectors illustrations. I've created hundreds of charts in Excel before and copied them to Illustrator
-
Ios 5 install error message -4026366788
IOS 5 failed due to error message -4026366788.