Get File name in script?

I'm currently running a script using the sqlplus @ command. I'm wondering if there's a way, in my .sql file to know the filename that this file is.... for instance, if i do: sqlplus test/[email protected] @test.sql
Is there a way, inside test.sql, to know that the file name is test.sql? I know it sounds stupid but it's because I'm logging the script name that was run against a database and I want to ideally be able to rename a script without needing to modify the log insertion command.

I do not know of anyway to know the name of the command file.
You could add a parameter like this
sqlplus test/[email protected] @test.sql test.sql
Now the 2nd test.sql becomes &1 in your script and you could have code in your script that says:
insert into log (process_name, timestamp, ...) values (&1, sysdate,...);
To bad you can not access the command file as arguement 0 (&0).
If you are new to parameters try this.
Create test.sql as
select '&1' as parm1 from dual;
sqlplus test/[email protected] @test.sql test.sql
Added URLs

Similar Messages

  • GET FILE NAME C:\temp\ADIBO.txt

    How to get file name?
    I used Get_File_NAME, but I'am getting an error.
    lv_lfilename is not the type LOGICAL_FILENAME
    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.
      pa_lfile TYPE zlocalfile
               DEFAULT 'C:temp'.
        CONCATENATE pa_lfile ''INTO lv_lfilename.
                  filename = lv_lfilename
                  filetype = 'ASC'
                  data_tab = it_billit_down.
        IF sy-subrc <> 0.

    You have to Maintain the Logical filenames and their Physical Paths in Tcode FILE.
    Then create a program like this..
    **To get the Physical file based on the Logical file names - Maintained in Tcode FILE
       CLIENT                        = SY-MANDT
        LOGICAL_FILENAME              = VlOGFILE
      OPERATING_SYSTEM              = SY-OPSYS
      PARAMETER_1                   = ' '
      PARAMETER_2                   = ' '
      PARAMETER_3                   = ' '
      WITH_FILE_EXTENSION           = ' '
      USE_BUFFER                    = ' '
      ELEMINATE_BLANKS              = 'X'
      EMERGENCY_FLAG                =
      FILE_FORMAT                   =
       FILE_NAME                     = V_PHYFILE
      FILE_NOT_FOUND                = 1
      OTHERS                        = 2
    IF SY-SUBRC <> 0.
    **To download the file to PC.
      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                       = ' '
      WK1_N_FORMAT                    = ' '
      WK1_N_SIZE                      = ' '
      WK1_T_FORMAT                    = ' '
      WK1_T_SIZE                      = ' '
      FILELENGTH                      =
        DATA_TAB                        = ITAB
      FIELDNAMES                      =
      FILE_WRITE_ERROR                = 1
      NO_BATCH                        = 2
      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.
    <b>reward if helpful</b>

  • Error in reciever file adapter , where i am getting file name dynamically

    hi all,
    error in reciever file adapter , where i am getting file name dynamically, please help me in this isssue , i am trying for a long time
    MP: Exception caught with cause Exception in XML Parser (format problem?):'java.lang.Exception: Message processing failed in XML parser: 'Conversion configuration error: Unknown structure 'ns0:MT_eINVOICE_RECV' found in document', probably configuration error in file adapter (XML parser error)': java.lang.Exception: Exception in XML Parser (format problem?):'java.lang.Exception: Message processing failed in XML parser: 'Conversion configuration error: Unknown structure 'ns0:MT_eINVOICE_RECV' found in document', probably configuration error in file adapter (XML parser error)'

    i am getting new error
    MP: Exception caught with cause Channel has not been correctly initialized and cannot process messages
    this is my strcuture
    and i have changed my structure
    i have given the recordset structure as

  • How to get file name of the form attachment?

    is there anybody who is able to help me with the following problem???
    I started my process from Workspace ES and as a first step I attached one locale file (IMG.JPG or IMG.TIF e.g.) as a form attachment. I used "Attachments" bookmark in the Workspace ES.
    I need to get file name of attached file in the process!!!
    I tried to use "getTaskAttachments" component to get file name of form attachment but without success. This component successfully obtained attached file an stored it in the variable (type list, subtype document) but didn't produce all file attribute informations such as basename or Content Type:
    Is there some possibility to obtain file name (including file extension) by using "standard" tools and components of ALC?
    Thanks for your suggestions.

    Hi LekomDev,
    I faced the same situation some time back and this is what I know.
    Based on the file type few of the attributes will or will not be populated. (This is what the official documentation says about Document attributes)
    The file name that you are looking for would mostly be in 'name' attribute of Document object. The 'wsfilename' attribute is the atrribute which gets used to show the file name into Attachments tab of the workspace.
    So, if you are just interested in knowing the filenames then 'name' attribute is the place that you are looking for.
    But if you are trying to solve an issue in which Attachments against a Task isn't showing the filenames properly then you would need to copy the 'name' attribute value into 'wsfilename' attribute and then the Attachmetns against a Task would have the correct names.
    Tip: Use the Record and Playback option of the workbench to inspect the Document variable and you would see all of the values for a Document variable at desired step in your orchestration.
    hope this helps,
    Parth Pandya

  • Need to get file name and directory back from file adapter - WRITE

    I am using the file adapter to write a file. I want to log the file name of the file we just created. Since we use a precise timestamp in the file name, I can't accurately guess.
    I have an invoke in my BPEL process to the file adapter. My first try was to assign the jca.file.FileName property to a variable, but it never comes back. I looked around and saw plenty of ways to SET the file name for a write and GET the file name for a read, but no GET file name for WRITE.
    Anyone have a solution?
    Thanks in advance!

    I think I got your point... You can tell FileAdapter the filename to write, but if you don't then FileAdapter can not tell you the filename that it wrote... I think it is pretty possible Oracle didn't implement the latter, as the write operation is probably asynchronous and the filename is calculated later on...
    If what you want is just log, you may achieve your requirement by increasing verbosity on Adapter logs... Have a look at the link bellow...
    Otherwise, the solution for you will be to calculate filename yourself, and that will be a little bit of reinventing the wheel... But at least you will know the filename...

  • Sharepoint 2010 -Script to get file name from Document Library

    can anybody send be script that works in "SharePoint 2010 management Shell" to get list of file names in document library.

    See my updated answer. The double quotes need to be removed. Also note that you need to use $item.File.Name
    and not $item.Name to get the name of the files.
    Blog | SharePoint Learnings CodePlex Tools |
    Export Version History To Excel |
    Autocomplete Lookup Field

  • Script: get file name

    i'm developing a script for fireworks mx.
    How can i get the open document file name?

    I do not know of anyway to know the name of the command file.
    You could add a parameter like this
    sqlplus test/[email protected] @test.sql test.sql
    Now the 2nd test.sql becomes &1 in your script and you could have code in your script that says:
    insert into log (process_name, timestamp, ...) values (&1, sysdate,...);
    To bad you can not access the command file as arguement 0 (&0).
    If you are new to parameters try this.
    Create test.sql as
    select '&1' as parm1 from dual;
    sqlplus test/[email protected] @test.sql test.sql
    Added URLs

  • Get file name/path of current .cfm file...

    i am going to make a "tracking" script for a website.  my idea is to add a <CFINCLUDE> to every .cfm file on the server (right at the end, so it would be easier to remove when im done), and have the script that is included add a record to a database that contains the file name/path of the .cfm file.  for example, index.cfm will include trackscript.cfm, and after the index.cfm is processed, a database will have a record in it containing the file name/path for index.cfm.
    i am new to coldfusion, but i think i have everything figured out, except how to get the name of the file that will be added to the database.  is there some kind of function or variable available that will give me the filename of the currently executing .cfm file?

    I don't think sticking a <cfinclude> call into every file is really a very good way of doing this.
    You should have a look at using onRequestEnd() for this sort of thing.
    There are various variables in the CGI scope which one can use to build the originating URL of the current request; CGI.script_name and CGI.query_string are probably the most helpful here.  One can resolve the underlying file system path form a URL using expandPath().

  • CS4: get file name after saving for web

    I am saving a file via "save for web" with a specific file name in a specific folder maybe with a specific resolution (width x height) entered directy within this dialog window.
    Is it possible to get this path and the optionally changed resolution via Adobe script (after saving the file; or starting the script just before "save for web")?
    Thanks a lot!

    I don't see anyway to get the user's options from the SaveForWeb dialog. The descriptors for both charIDToTypeID( "Expr" ) and charIDToTypeID( "Mn  " ) are empty.
    But you can use the DOM to sfw. Below is a function to save jpg using sfw.
    function SaveForWeb(saveFile,jpegQuality) {
    var sfwOptions = new ExportOptionsSaveForWeb();
       sfwOptions.format = SaveDocumentType.JPEG;
       sfwOptions.includeProfile = false;
       sfwOptions.interlaced = false;
       sfwOptions.optimized = true;
       sfwOptions.quality = jpegQuality; //0-100
    activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);
    Look up ExportOptionsSaveForWeb in the scripting guide for other formats.
    You would have to do the resize as an extra step when saving using the DOM.

  • Getting file name without adding asset

    Here's the set up-
    I use Watch Folders to compress videos for DVD, and I don't want to add the original files as assets. However, I want part of the watcher to be a script response that creates a text file with the same name as the original file. I haven't been able to pass the file name as a parameter- it keeps passing the MetaData field name. I've tried File Name and Title (I used quotes and brackets- can't show that on here, it makes it into links).
    I'm guessing I'm either using the wrong metadata field or this is impossible, because there is no metadata.
    Message was edited by: jamesnw

    I thought I had a solution for you, but upon testing it I discovered an unfortunate reality with the way FCSvr reports job status.
    You can subscribe to jobs and have that subscription feed the values of the job's fields to a script. The jobs don't track elapsed time, but they do stamp time for \[Updated] at the creation of the job, during the job, and at the close of the job.
    I tested this by creating one email response that will send me an email with the timestamp value of \[Updated] and a subject line of \[Job ID] \[Status] to tell them apart. I made two subscriptions, one that would fire upon the creation of a job that executes the response, and one that would fire on the modification of a job filtered for a status of "DONE".
    The problem is, the \[Updated] timestamp does not ever change in the metadata, it just gets updated in the GUI separately. More digging found the same is true for the \[Progress] field.
    You could have had two scripts, one that writes a timestamp to a file at the creation of a job with the first subscription that is filtered for the kind of thing you bill for based on whatever job field values, and another that finds the difference with the end timestamp at the close with the second subscription that is filtered for the kind of thing you bill for based on whatever job field values plus a \[Status] that equals "DONE". There would be a margin of error of a few seconds, but that just means you could round your billing up to the next minute.
    But alas, the job metadata never updates beyond the first values. In fact, if you open a job from the queue after it completes, the timestamp reverts to the initial value.
    Maybe you could have the script write a timestamp itself when it runs rather than trying to pull one from the job's metadata...

  • Get file name and received date & time

    Hello experts,
    We are loading around 10 source files(xml) on regular basis to Target table. I have to capture source filename & received datetime of those files and status of file whether it loaded successfully or not(I can care take care of status of file).  I want to automate this process using BODS and load filename, datetime and status data into one database table.
    For you information: File name looks like QAS_Wareneingang_20140328-190006-438.     ( from file name  ..190006-438 number is random number they are generating) and Date and time is constant for that day eg: 28.03.2014  19:00
    Could you please help me...
    Thanks & regards

    Thank you Arun for your kind help...
    I found a solution to find and move all related filenames with timestamp to  file_names.txt file using the batch script below.
    @echo on
    cd /D G:\BAUR
    dir /n Auslagerung* > G:\Dev_Users\BAUR\file_names.txt
    After that I used the above file as source and formatted using query transform in BODS.

  • Get file name from folder

    Hi all,
    how to find a .txt file in a particular folder. My text file comes with
    following name <fixed_name>.<mmddyy><hhmmss>, e.g., fn_fnprod.102806015605
    so how to get this file name. nd also tell me if there are multiple files
    then how to retrieve the oldest one first and so on....
    Thanks & Regards

    it's fine but how to know which is older file b'cpz
    this file comes every day with new date & time. so
    what if there a multiple file. nd i have proceed
    oldest first.
    pls help asapget each file last modifed, using file.lastModified() method and compare which file you would be needing. =)

  • Get File name from incoming IDoc

    HI All,
    I am in an IDOC to File scenario using Fcc. (R/3 --> XI --> 3rd party)
    I need to use the  idoc-number(EDI_DC40-Docnum) as my output file name. I planned using variable substitution but there it expects me to get the idoc number from payload which I do not have it in. (refer c ode below)
    As I understand, variable substitution can be used only on payload(the FINAL data set that we will be writing to the file).
    Can we use the data which is part of incoming IDOC and not part of payload(final data what we are writing to file).??
    Other idea was to map this IDOC no to a field in final file, but this field should not be written in the output file, so am confused about how to achieve this.
    *Incoming Data*
    Final data (Payload)
    As seen in my example above I do not have the IDOC no in the final data so how do I use the Idoc no as my filename? Apprecaite your help on same.

    You can use dynamic configuration to get the file name .
    Use Adapter Specific Message Attributes for the target Comm Chanel check the indicator for filename in the advanced tab of CC
    create a UDF with i/p as file name  i.e the Idocnum field and
    paste this code
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("","FileName");
    //String filename= conf.get(key);
    conf.put(key, fileName);
    key= null;
    return fileName;
    PS: use cache as value in UDF
    ands assign the o/p of this UDF to a root node

  • Get file name

    Hello world,
    Am writing a small server application that can accept files and save them locally. Now, the server is working, but am finding it very hard to get the name of the file that's been sent so that I can save the file with that name and its extension.
    e.g. I want if I sent a file, then, the server will save it as But at the moment, its not saving it like that because there is no way can get the name of the file from the client.
    Here is my code:
    class Server {
        static final String ToSave = "C:\\";
        static final int PORT               = 2391;
        public static void main(String args[]) {
            while ( true ) {
                try {
                    ServerSocket socketServer = new ServerSocket(PORT);
                    Socket socket = socketServer.accept();
                    //Assuming we have a file name (FILENAME)from client
                    FileOutputStream fos = new FileOutputStream(ToSave + FILENAME);//<--HERE IS WERE i WANT THE FILENAME
                    BufferedOutputStream out = new BufferedOutputStream(fos);
                    BufferedInputStream in = new BufferedInputStream( socket.getInputStream() );
                    int i;
                    while ((i = != -1) {
                    System.out.println("Transfer complete.");
                catch(Exception e) {
                    System.out.print(  e  );
                try {
                } catch (InterruptedException ie) {

    You have to define a protocol which enables the
    client to tell the server the file name.
    BTW creating server sockets inside a loop is not a
    good idea.
    Thank you very much :)
    I've got the idea on how to implement it now. All I have to do is:
    first connect to the server and send a message containing the name of the file and then, at the server end, I will receive the name and use it to save to incoming file.
    Thanks again.

  • Get File Name in a package

    I have a interface File to DB. In the source exist many files with name mask ccf_*.txt. Im use a ODIFileWait to start my process, but i cant get the file name to use in my interface. How i do to get the file name processed in the ODIFileWait?

    I have the same problem...

Maybe you are looking for

  • How to find out top 10 records from the R/3 using Java code (WD Program)

    Hi Experts, I have used Java Web Dynpro program to fetch records from the backend. Following code helps me and fetches record. As per the customer reqirement, we have to fetch only top 10 records (Actual Cost) from the backend. So I have to modify th

  • IWeb RSS Issues. Help!!!

    Using iWeb 09 I have fed a blog through to a page using the RSS Widget. It shows correctly on the page but on clicking on the entry the address it takes me to isn't correct. Unfortunately it's a passworded site so I can't provide links. The Blog is a

  • Deploying application on OC4J

    Hi, I am deploying a simple web application on OC4J which comes with 9iAS infraStructure installation. I changed server.xml, application.xml, default-web-site.xml & application.xml in the META-INF folder of my app but i couldn't access the appln afte

  • How to delete a folder?

    When I right click on a folder and click delete, Lightroom correctly deletes all pictures in the folder, removes the folder from the library, but leaves empty folder in the file system. Is there a way to make Lightroom delete the folder? I'm not dele

  • Appreciate your feedback: Usability - A good UI is revitalizing

    Dear experts, I would appreciate your feedback and rating for the blog Thanks in advance, Regards, Leon