I have two questions.
(1) how to make move text file from folder:
C:\Data\inbox\test.txt
to target Folder?
C:\Data\outbox\test.txt
(2) how to make get list of directory files in Folder?
C:\Data\inbox\
Thank you...
Oracle provides a package of utilities for working with files, UTL_FILE. Since 9i this has included the FRENAME() procedure, which works like the unix mv command. We can use it to rename the file and/or its directory. Note that the Oracle os account must have read and write privileges on both directories. Also this procedure uses DIRECTORY objects, rather than explicit paths.
As for getting a list of files in a directory, there is no Oracle built-in. One solution is to use a Java Stored Procedure. Tom Kyte has an example of this. Find it here. There is another way of doing it since 11.1.0.7, which is to use an external table pre-processor file. Adrian Billington wrote a nice article on this. The executed file is platform dependent.
Have a look at UTL_FILE?
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_file.htm
Where you say:
2-) Question Two
Folder: C:\Data\inbox\
how to make get directory files list ?
Tom Kyte has a nice solution shown here
begin
UTL_FILE.FCOPY (
'EMPLOYEE' , -- THIS IS A ORACLE DIRECTORY
'EmpInfo.TXT' , --FILE NAME
'PROM_INCR' , -- THIS IS A ORACLE DIRECTORY
'EmpInfo.TXT' ); -- DESTINATION FILE
end;
try this
Related
How can I find the directory in which oracle stores it's table space files?
When I do: select * from dba_data_files; or select * from v$datafile; then I get some paths like that:
+DATA01/fu/datafile/bar_ts01_data.260.264360912
But what means +DATA01? And where is that exactly in the file system?
+DATA01/fu/datafile/bar_ts01_data.260.264360912
Yes this is correct file path. It means you use ASM disk.
After you login to OS with "grid" user [usually Oracle Grid Infrastructure installation user is named like that], run following command to browse files on ASM disk.
export ORACLE_HOME=/u01/app/11.2.0/grid --this is also usual installation dir, may differ on your case
export ORACLE_SID=+ASM
cd $ORACLE_HOME/bin
./asmcmd -p
ASMCMD>ls
+DATA01
+DATA02
ASMCMD>cd +DATA01
In that table, the file_name field should give the full path to the datafile.
Also, try select * from v$datafile; and that view should help as well.
I am recovering Stata following a Windows upgrade. I have a list of my packages generated from ado dir in the following format:
[1] package mdesc from http://fmwww.bc.edu/RePEc/bocode/m
'MDESC': module to tabulate prevalence of missing values
[2] package univar from http://fmwww.bc.edu/RePEc/bocode/u
'UNIVAR': module to generate univariate summary with box-and-whiskers plot
[3] package tabmiss from http://www.ats.ucla.edu/stat/stata/ado/analysis
tabmiss. Shows tabulation of number of missing and non-missing values
I have many packages and would like to reinstall them without having to designate each directory/url via net cd. While using net cd along with net install or ssc install along with package names in a loop is trivial (as below), it would seem that an automated method for this task might be available.
net cd http://www.ats.ucla.edu/stat/stata/ado/analysis
local ucla tabmiss csgof powerlog ldfbeta
foreach x of local ucla {
net install `x'
}
To my knowledge, there is no built-in or automated method of tracking and managing your installed packages outside of what is available through ado or net.
I would also tend to agree with #Nick Cox that this task seems strange and I can't imagine how a new Stata install or reinstall could know what was installed previously, but I find the question interesting for other reasons.
The main reason being for users who have Stata installed on multiple machines who need the same packages on both machines. I faced a similar issue when I purchased a new computer and installed Stata but wanted all of the packages I use to be available as well. Outside of moving the ado directory or selected contents I'm not aware of any quick solution.
Here it would be possible to use the output of ado dir on one machine to determine what you need to install on a second machine with a new Stata install.
The method you propose using a foreach loop could save you time from having to type in or copy/paste a lot of packages and URLs. At the same time however, this is only beneficial if you have many packages from only a few repositories because you will need to net cd to the URL each time as you show in your example.
An alternative solution is the programmatic solution. As you know, ado dir will list each installed package, the URL and a short description of the package. Using this, a log file, and the built in I/O functionality, a short program could be written to automate the process and dynamically build a do file that contains the commands to install the already installed packages.
The code below generates a do file containing commands (in this case, net describe package, from(url)) for each package I have installed on my computer.
clear *
tempfile log1
log using "`log1'", text name(mylog)
ado dir
log close mylog
tempname logfile
file open `logfile' using "`log1'", read
file read `logfile' line
file open dfh using "path/to/your/dofile.do", write replace
local pckage "package"
while r(eof) == 0 {
if `: list pckage in line' {
local packageName : word 3 of `line'
local dirName : word 5 of `line'
di "`packageName' `dirName'"
file write dfh "net describe `packageName', from(`dirName')"
file write dfh _newline
}
file read `logfile' line
}
file close `logfile'
file close dfh
In the above code, I create a temp file to write a .txt log file to and store the contents of ado dir in that file.
Then, I open the log file using file open and read it line by line in the while loop.
Above the loop, I'm creating a do file at /path/to/your/dofile.do to hold the output of the loop - the dynamically created commands relating to the installed packages on my machine.
The loop will iterate so long as r(eof) = 0, where r(eof) is an end of file marker. I use an if statement to sort out lines of the log file which contain the word package, as I'm only interested in those lines with the package name and URL in them.
Inside of the if block, I parse the local macro line to pull the package name and the URL/directory name.
this is important: this section of code assumes that the 3rd and 5th words in the macro will always be the package name and URL respectively - Confirm this from the output of ado dir before executing.
You will also need to change the command that is being written to the file handle dfh inside of the loop to what you want (net install, etc) when you are ready to execute.
For more help on using file, locals, and tempfiles execute any of the following in Stata:
help file
help extended_fcn
help macrolists
There may be nicer ways to parse the contents of ado dir but this has worked for me. And of course I'd always advise that you take the time to understand what the code is doing so that you can make any necessary tweaks to fit your particular situation.
Is it possible to tell ASDF that it should produce only one fas(l) file for entire system? This file should be concatenation (in right order) of all compiled files of the system, including all files of systems on which target system depends.
Yes, with compile-bundle-op (ASDF 3.1): http://common-lisp.net/project/asdf/asdf/Predefined-operations-of-ASDF.html
edit: Actually, monolithic-compile-bundle-op seemes to be asked for (as shown in other answers).
If you have to predict the extension, use uiop:compile-file-type.
And/or you can just call (asdf:output-files 'asdf:monolithic-compile-bundle-op :my-system) to figure out what is actually used.
Option monolithic-compile-bundle-op will create single compiled file which includes all dependencies, while compile-bundle-op creates a file for every system.
Example of use:
(asdf:operate 'asdf:monolithic-compile-bundle-op :my-system)
This command will create file my-system--all-systems.fas(l) in output directory of target project, as well as "bundle" files for every system, named like my-system--system.fas(l).
I'm using JDBC to create a directory object in the database.
i.e create or replace directory "dir" as 'c:\temp';
My question is:
I want to pass the path at runtime
Or at least specify path relative to current one. I mean : create or replace "dir" as './../tempdir'
Is there a way to do this or is specifying absolute path the only way out.
From Oracle Doc:
path_name Specify the full path name of the operating system directory
of the server where the files are located.
I think this is because there is no such thing as "current directory". (You are in database, not in command line :) )
You can post a question with your problem and you'll get help from community.
which function windows is calling to list the files in a directory ?
thanks
You can use this functions to do a directory listing with the WIN32 API.
FindFirstFile, FindNextFile and FindClose
A full example can be found here
Listing the Files in a Directory WIN32 API
For a portable approach check this post:
"Get list of files in a directory using c/c++"
Didn't exactly get your question but won't using "dir" as system command do the job?
Correct me if I am wrong, coz the question itself wasn't very clear to me.
Edit - Hi John, this is the source code for listing directories.
http://msdn.microsoft.com/en-us/library/aa365200(VS.85).aspx
Hope this helps.