I have a folder in the server
/home/test/pictures
There are multiple .jpg files inside this pictures folder.
I want to delete these files from this pictures using plsql.
Is there a utility for this ?
you can use UTL_FILE.FREMOVE function this function will remove files from a directory, here is the parameters for the function UTL_FILE.FREMOVE (location IN VARCHAR2,filename IN VARCHAR2)
location should be in ALL_DIRECTORIES view
so calling a function would be like this:
begin
UTL_FILE.FREMOVE('C:\','TEXT.TXT');--this will remove text.txt from C drive
end;
you can read this article https://docs.oracle.com/cd/B28359_01/appdev.111/b28419/u_file.htm#BABEGHIG
Related
I need to delete many folders with an exempt list which has a list of folders and files that I should not delete. So I tried delete activity and tried to use if function of Add dynamic content to check whether the file or folder name is the same of the specified ones. But I do not have what should be the parameters #if(). In other words, to use these functions, how do we get the file name or folder name?
It is difficult to get all files and folders by using GetMetadata activity.
As workarounds, you can try these ways:
1.create a Delete activity and select List of files option. Then create a file filled with those path of files and folders need to be deleted.(relative path to the path configured in the dataset).
2.using blob SDK to do this thing.
I have a folder with the structure: /home/test/test123
Inside this I have another BlobFi named directory with jpg images and in test123 I have a txt file. I want to zip the contents of test123 that is BlobFi and the txt file into one folder.
Is there any PL/SQL method which can compress this test123 to test123.zip ?
I Tried referring to THIS but dont know how will I use it for my condition.
What i want do, is to generate a .log file that describes all my error, start time, end time, and so one. I found a way to have something like that but not in corect way.
I want to generate that file automaticaly, without being required to define it manually.
From what i have understood, is that UTL_FILE.FOPEN, when is not found that file, create one.
My app. is working. The question is, HOW TO GENERATE A FILE IN PLSQL (.log file) without create it manually.
create or replace procedure read_files(input varchar2) as
begin
declare
F2 UTL_FILE.FILE_TYPE;
F2 := UTL_FILE.FOPEN('FOLDER',input||'.log','w');
UTL_FILE.put_line(F2,'Start processing file at : ' || systimestamp);
UTL_FILE.put_line(F2,'End processing file at :'||systimestamp);
-- Close file
UTL_FILE.FCLOSE(F2);
END; --end begin
I found the probleme ! Where I stored my files, I had no right to create files / folders. THANKS all !
I have a file in my D: drive of my computer and I want to copy this file to an SAP application server so that I am able to see my file with transaction AL11.
I know that I can create a file with AL11 but I want do this in ABAP.
Of course in my search I find this code but I cannot solve my problem with it.
data: unixcom like rlgrap-filename.
data: begin of tabl occurs 500,
line(400),
end of tabl.
dir =
unixcom = 'mkdir mydir'. "command to create dir
"to execute the unix command
call 'SYSTEM' id 'COMMAND' field unixcom
id 'TAB' field tabl[].
To upload the file to the application server, there are three steps to be followed. To open the file use the below statement:
Step1: OPEN DATASET file name FOR INPUT IN TEXT MODE ENCODING DEFAULT.
To write into the application server use.
Step2: TRANSFER name TO file name.
Dont forget to close the file once it is transferred.
Step3: CLOSE DATASET file name.
Plese mark with correct answer, if it helps! :)
If you want to do this using ABAP you could create a small report that uses the function module GUI_UPLOAD to get the file from your local disk into an internal table and then write it to the application server with something like this:
lv_filename = '\\path\to\al11\directory\file.txt'.
OPEN DATASET lv_filename FOR OUTPUT IN TEXT MODE ENCODING UTF-8.
LOOP AT lt_contents INTO lv_line.
TRANSFER lv_line TO lv_filename.
ENDLOOP.
CLOSE DATASET lv_filename.
I used CG3Z transaction and with this transaction I was able to copy a file in the application server directory.
I am trying to write to a local file from a PL/SQL script. In order to do this, I am attempting to use the TEXT_IO package in PL/SQL.
DECLARE
file_out text_io.file_type;
len number;
blob_file blob;
my_var RAW(50);
bstart NUMBER := 1;
bytelen NUMBER := 50;
BEGIN
SELECT xxx
INTO blob_file
FROM yyy
WHERE zzz
dbms_lob.read(blob_file, bytelen, bstart, my_var);
file_out := text_io.fopen('local_file_path', 'w');
text_io.put_raw(file_out, my_var);
text_io.fflush(file_out);
text_io.fclose(file_out);
END;
/
quit
However, when I run this script I get the error,
PLS-00201: identifier 'TEXT_IO.FILE_TYPE' must be declared
Does anyone know how I can fix this error, and how I can write the contents of the blob to a file as I am attempting to do?
Thanks,
ktm
TEXT_IO exists only in Oracle Forms which had (in the old client/ server days) a client-side PL/SQL interpreter. If you are using SQL*Plus to execute PL/SQL, as it appears you are doing here, the TEXT_IO package will not be available and you will not be able to write to a file on the client machine (barring the odd setup where the server mounts a drive that your client is exposing and then proceeds to write to that mount).
Now, you can generally use SQL*Plus to directly write to a local file using the SPOOL command. Unfortunately, it's probably unlikely that you could do this for a BLOB in the general case.
If you want to create a file on the server UTL_FILE is a good choice.
This package can write files in any DIRECTORY specified in the database. A DIRECTORY is created in Oracle using CREATE DIRECTORY and can be linked to any writable directory accessible by the DBMS (server-side).
The general approach is: write a file on the server and download it. Or event better, don't write it down, just stream it. Quite complicated, yes.