How to check if file is in correct format

Hi,
I want to check if file is in below format via pl/sql
SCE_ YYYYMMDD
and throw an error if not. If
vsFileName:= 'SCE_20080204';
select TO_DATE(SUBSTR(vsFileName, 5, 8), 'YYYYMMDD') - 1 from dual
woudl return 2/3/2008. This is okay
vsFileName:= ''SCE_TEST0204';This is not okay; and would like to trap the error with file name is not correct
Thanks,
VS

Are you just looking for some exception handling?
SQL> ed
Wrote file afiedt.buf
  1  DECLARE
  2    v_filename VARCHAR2(20) := 'SCE_TEST0204';
  3    v_dt       DATE;
  4    v_err      BOOLEAN := FALSE;
  5  BEGIN
  6    BEGIN
  7      v_dt := TO_DATE(SUBSTR(v_filename, 5), 'YYYYMMDD');
  8    EXCEPTION
  9      WHEN OTHERS THEN
10        v_err := TRUE;
11    END;
12    IF v_err THEN
13      DBMS_OUTPUT.PUT_LINE('Filename is incorrect');
14    ELSE
15      DBMS_OUTPUT.PUT_LINE('Filename is OK');
16    END IF;
17* END;
SQL> /
Filename is incorrect
PL/SQL procedure successfully completed.
SQL> ed
Wrote file afiedt.buf
  1  DECLARE
  2    v_filename VARCHAR2(20) := 'SCE_20080204';
  3    v_dt       DATE;
  4    v_err      BOOLEAN := FALSE;
  5  BEGIN
  6    BEGIN
  7      v_dt := TO_DATE(SUBSTR(v_filename, 5), 'YYYYMMDD');
  8    EXCEPTION
  9      WHEN OTHERS THEN
10        v_err := TRUE;
11    END;
12    IF v_err THEN
13      DBMS_OUTPUT.PUT_LINE('Filename is incorrect');
14    ELSE
15      DBMS_OUTPUT.PUT_LINE('Filename is OK');
16    END IF;
17* END;
SQL> /
Filename is OK
PL/SQL procedure successfully completed.
SQL>

Similar Messages

  • I have a MacBook Pro, I want to copy Itunes files to an SD card to play in my car, the SD Card doesn't appear in Itunes when I insert it, and I don't know how to convert the files to the correct format, can anyone help?

    I have a MacBook Pro, I want to copy Itunes files to an SD card to play in my car, the SD Card doesn't appear in Itunes when I insert it, and I don't know how to convert the files to the correct format, can anyone help?
    Thank you

    So it seems from reading the COMMAND manual that my first issue is that I used a 16GB SD card, and the manual says it will only recogize up to a 2GB SD card. I did use my MB Air's SD card slot and crated a folder and dragged the music files to it, then to the card. So I am going to get a 2GB card and try that next. Otherwise just stick with the iPOD connected. At least that is 8GB

  • How to check amsilent file in Sun Access manager patch or redeploying WAR's

    h1. How to check amsilent file in Sun Access manager patch or redeploying WAR's
    I had a hard time getting all the passwords correct, so I wrote a shell (bash) script that uses most passwords and other parameters in searches and queries. It let's you know before you start if a value is wrong. It does not change anything, only queries.
    h2. One pitfall I found ...
    during the postinstall of patch 05. I told Sun about it, but I suspect it was too late and is also an issue with patch 06:
    Look at the documentation regarding amconfig and the amsilent file:
    http://docs.sun.com/app/docs/doc/819-2137/adsav?l=en&q=amconfig&a=view
    Two problems that are clear to me now:
    1. ADMINPASSWD in practice, this password is used for cn=puser, not amadmin as it says. Perhaps there is something that makes them the same. It was the same for me, so it probably does not matter.
    2. AS81_ADMINPASSWD is not the same as ADMINPASSWD using either my definition or the document's definition. However, in the amsilent template, it is set like this, which I found is incorrect and the cause of my recent hair loss:
    <blockquote>AS81_ADMINPASSWD="$ADMINPASSWD"</blockquote>
    Also, this one if you use the web server:
    <blockquote>WL8_PASSWORD="$ADMINPASSWD"</blockquote>
    Delete the $ADMINPASSWD and replace it with the password for the app/web server.
    h2. The Script.
    It tests for the above problem, but I just realized it does not check $ADMINPASSWD. If that is set incorrectly in your amsilent, you'll get errors immediately from amconfig, so no big deal. If you make improvements, please post a reply!
    Paste this into a file named checkamsilent. LDAP and appserver must be running. It reads /opt/SUNWam/amsilent. Run it as root or use sudo:
    sudo ./checkamsilent
    #!/usr/bin/bash
            echo "This will test several important parameters of the amsilent file "
            echo "run this as root."
            echo "### read in the amsilent parameters"
            echo "source /opt/SUNWam/amsilent  "
    source /opt/SUNWam/amsilent
            echo "### look for the *server port* with LISTNER, otherwise it's not listening. "
            echo "netstat -a | grep $SERVER_PORT    "
            echo "--------------"
    netstat -a | grep $SERVER_PORT  
            echo "--------------"
            echo "."
            echo "### *admin port* with LISTNER, otherwise it's not listening. "
            echo "netstat -a | grep $ADMIN_PORT   "
            echo "--------------"
    netstat -a | grep $ADMIN_PORT 
            echo "--------------"
            echo "."
            echo "### Expect to see a line of XML, otherwise the SERVER_PORT is incorrect in the amsilent file."
            echo "grep $SERVER_PORT  ${AS81_INSTANCE_DIR}/config/domain.xml  "
            echo "--------------"
    grep $SERVER_PORT  ${AS81_INSTANCE_DIR}/config/domain.xml
            echo "--------------"
            echo "."
            echo "### Expect to see a line of XML, otherwise the ADMIN_PORT is incorrect in the amsilent file."
            echo "grep $ADMIN_PORT  ${AS81_INSTANCE_DIR}/config/domain.xml "
            echo "--------------"
    grep $ADMIN_PORT  ${AS81_INSTANCE_DIR}/config/domain.xml
            echo "--------------"
            echo "."
            echo "### bind as the directory manager "
            echo "ldapsearch -v -h $DS_HOST -p 3892  -L -s sub -D \"$DS_DIRMGRDN\" -w \"$DS_DIRMGRPASSWD\" -b 'dc=nsf, dc=gov' \"cn=amldapuser\"" 
    ldapsearch -v -h $DS_HOST -p 3892  -L -s sub -D "$DS_DIRMGRDN" -w "$DS_DIRMGRPASSWD" -b 'dc=nsf, dc=gov' "cn=amldapuser" 
            echo "."
            echo "### check the amldapuser password. "
            echo "ldapsearch -w $AMLDAPUSERPASSWD -v -h $DS_HOST -p 3892  -L -s sub -D cn=amldapuser,ou=DSAME Users,dc=nsf,dc=gov -b ou=DSAME Users,dc=nsf,dc=gov cn=* cn  "
    ldapsearch -w "$AMLDAPUSERPASSWD" -v -h $DS_HOST -p 3892  -L -s sub -D "cn=amldapuser,ou=DSAME Users,dc=nsf,dc=gov" -b "ou=DSAME Users,dc=nsf,dc=gov" cn=* cn
            echo "."
            echo "### check the app server admin: AS81_ADMIN password: AS81_ADMINPASSWD  and port: ADMIN_PORT "
         echo "### That's actually a bug in the template.  "
         echo "### Do not use AS81_ADMINPASSWD=\$ADMINPASSWD  Make sure they are  different passwords! Don\'t use the default!"
         echo "Expect to see a WARNING about --password option. "
            echo "/opt/SUNWappserver/appserver/bin/asadmin  list-http-listeners --user $AS81_ADMIN --port $ADMIN_PORT  -w $AS81_ADMINPASSWD  "
    /opt/SUNWappserver/appserver/bin/asadmin  list-http-listeners --user $AS81_ADMIN --port $ADMIN_PORT  -w "$AS81_ADMINPASSWD"
            echo "done!"

    I change the product machine from LG optimus to Samsung Galaxy but the file writing is not working, too.
    I copied the source code from Adobe website about FileStream  but it is needless too.
    -----------------program code------------------------
    import flash.filesystem.*;
    import flash.filesystem.FileStream;
    import flash.events.Event;
    //txtFld is a standard textField component
    txtFld.text = "Start";var file:File = new File();
    //btnSaveFile is a standard button component
    btnSaveFile.addEventListener(MouseEvent.CLICK,handlerBtnSaveFile);
    function handlerBtnSaveFile(e:Event){
    txtFld.text = "Pressed";
    file = File.documentsDirectory;
    file = file.resolvePath("test.txt");
    var fileStream:FileStream = new FileStream();
    fileStream.openAsync(file, FileMode.WRITE);
    fileStream.writeUTFBytes("Hello");
    txtFld.text = file.nativePath.toString();
    //fileStream.addEventListener(Event.CLOSE, fileClosed);
    fileStream.close();
    fcnFileName();
    function fcnFileName(){
    txtFld.text = file.name.toString();
    function fileClosed(event:Event):void {
        trace("closed");
    txtFld.text = "FileClosed";

  • How to Check a file in the directory..

    Dear,
    Pl. do suggest me how to check a file (e.g. abc.txt) is in the directory (say d:\Print).
    Do tell me how to check whether this file is exist in the directory or not???
    Thanx in Advance.
    Bhavesh

    Hi
    You can use Win_Api_Utility.Copy_File cmd. IF the file does not exist r the file was not copied to the destination properly, it will raise no_data_found error. See Forms help - Find option for syntax & more details.
    I've used it & works well.
    Regards
    APK

  • CVAPI_DOC_CHECKOUTVIEW - how to check´out files to a SAP directory

    Hello,
    I have an issue with understanding and providing the FM CVAPI_DOC_CHECKOUTVIEW to check out files from KPRO to a SAP directory.
    I use CV120_KPRO_CHECKOUT to checkout files to local PC and this runs fine, but not for checking out files to SAP directories. So I found the API.... FM.
    But I am confused about the data required to run the FM CVAPI_DOC_CHECKOUTVIEW . I tried several times but it does not work either for check out to clnt nor to SAP server.
    Parameters for DOKAR, DOKNR, DOKVR and DOKTL are clear to me. PF-CONTENT_PROVIDE is CLNT for PC check out and SRV for Server checkout. But what about the rest?
    I am not sure how to provide the tables and the fields PF_FTP_DEST / PF_HTTP_DEST / PF_HOSTNAME and the PS_API_CONTROL.
    Can anybody help me with the required import data.
    Best regards
    Dirk

    Hi Dirk.
    We are using bapi to get the document file (original)
    Look our usage of pf_http_dest and pf_ftp_dest.
    CALL FUNCTION 'BAPI_DOCUMENT_GETDETAIL2'
      EXPORTING
        documenttype       = vl_dokar
        documentnumber     = vl_doknr
        documentpart       = vl_doktl
        documentversion    = vl_dokvr
        getactivefiles     = 'X'
        getdocdescriptions = 'X'
        getdocfiles        = 'X'
      TABLES
        documentfiles      = t_document.
    READ TABLE t_document INTO wa_document INDEX 1.
    CALL FUNCTION 'BAPI_DOCUMENT_CHECKOUTVIEW2'
      EXPORTING
        documenttype    = vl_dokar
        documentnumber  = vl_doknr
        documentpart    = vl_doktl
        documentversion = vl_dokvr
        documentfile    = wa_document
        originalpath    = 'your SAP directory'
        pf_http_dest    = 'SAPHTTPA'
        pf_ftp_dest     = 'SAPFTPA'
    IMPORTING
        return          = wa_return
    TABLES
        documentfiles   = tl_files.
    Darley

  • How to check out files from DTR

    Dear all,
    I've check in files and activated it to the DTR. but somehow the transportation to production server was not complete coz it said that the DC built failed...how should i resovled this problem?  What is the steps to check out files from DTR..and what is the steps to delete a DC from DTR? thank you

    Hi
    see the following link ,it will be helpful for u.
    [Working with the Design Time Repository |http://help.sap.com/saphelp_nwce10/helpdata/en/83/74c4ce0ed93b4abc6144aafaa1130f/content.htm]
    Thanks
    Hazrath

  • How to check Fla file version?

    Hi Guys,
    I installed on my system Adobe flash cs3. but when i opened my Fla file that time getting the following error.
    So how to check the Fla file version??
    Thanks in Advance..
    JaxNa

    FLA Version Checker and Launcher
    http://www.peterelst.com/blog/2005/10/02/flavor-fla-version-checker/http://www.northcode.com/blog.php/2007/07/27/FLA-Version-Checker-and-Launcher

  • How to ensure JSP files are syntactically correct before deployment?

    Hi All,
    Is there a way to ensure the JSP files are syntactically correct before
    deploying them to the server (iAS)? Where can I find the details for the
    errors so as to resolve them? Please advise.
    Christopher Lam

    You can precompile them before deploying.
    Use jspc.bat from \iplanet\ias6\ias\bin.
    There could be a bug in this script. I had to fix something for myself. Check the parts containing 'tomcat'

  • How to check the file size before loading it to the context

    Hello,
    I have an application to upload a file and write it to the server using the FileUpload UI and IWDResource Interface.
    I would like to limit the size of the file the user is uploading to, say, 2MB.
    The problem is that the current API doesn't allow me to check the file size before I store it in IWDResource. The API available for IWDResource:
    IWDResource resource = ...
    InputStream stream = resource.read(false);
    size = stream.available();
    Is working on the file only AFTER storing it in the context and the server's memory. This way, if a user decides to upload 1GB file for example, he can easily crash the server.
    I am already familiar with <a href="https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/00062266-3aa9-2910-d485-f1088c3a4d71">this</a> arcticle but it doesn't answer this question as well, all it does is calculating the file size only after storing it in the context.
    Any ideas...?
    Roy

    Hi Ram,
    Have you activated your Objects ?
    You need to activate your objects in order to see them in RWB.
    Thanks & Regards,
    Varun Joshi

  • How to Save Pdf file in a particular format

    Hi Experts,
                        Can anybody tell me how to save a pdf file in a particular format,My requirement is i have a print button in webdynpro ,when ever user clicks on print ,adobe form is opened ,if user clicks on save .Form is saving with adobe form name .My requirement is it should be saved as ID NO.Date.Pdf  form lets Id is 0456 ,form should be saved as 0456.040614.pdf format, Thanks in Advance
    Regards
    Sandesh

    Hi Sandesh,
    Please provide the complete code from print & save button.
    Thanks & Regards,
    Balamurugan G

  • How to convert binary file to a particular format?

    Hi,
    I am having a requirement. I have in database various kinds of files stored as binary format. Its a sybase database. Now the files can be .pdf, or .doc also. But they are stored in binary format.
    I need to read the file from database.
    Now I can use jdbc to read the particular column value which contains the file in binary format.
    But tricky part is how to convert the binary file entry in a proper respective file format? So I have another column which basically has the value to tell the type of file. So I have ".doc" or ".pdf" as each entry of file...
    So please help me how can we do this using Java?
    THanks

    Hi,
    I am having a requirement. I have in database various
    kinds of files stored as binary format. Its a sybase
    database. Now the files can be .pdf, or .doc also.
    But they are stored in binary format.
    I need to read the file from database.
    Now I can use jdbc to read the particular column
    value which contains the file in binary format.
    But tricky part is how to convert the binary file
    entry in a proper respective file format? So I have
    another column which basically has the value to tell
    the type of file. So I have ".doc" or ".pdf" as each
    entry of file...
    So please help me how can we do this using Java?
    THanks

  • Please help -  How to export HTML file into MS word format

    How to export HTML file into MS word file without any change
    in design format?
    As I have been trying to do that but problem is coming in
    formating. Table's witdth and height get disturbed in MS word when
    I import the html file.
    What I do after creating HTML in dreamweaver I save that file
    into .txt format in dreamweaver. and then import it in MS Word. And
    I tried too much for it but invain.
    Please help me in finding the way of solution.
    Please help me as my job is in trouble. It's very urgent
    pleeease help me. I'll be thankful to you.

    Just open the HTML file in Word.
    Walt
    "apollo321" <[email protected]> wrote in
    message
    news:gavbhd$6j4$[email protected]..
    > How to export HTML file into MS word file without any
    change in design
    > format?
    >
    > As I have been trying to do that but problem is coming
    in formating.
    > Table's
    > witdth and height get disturbed in MS word when I import
    the html file.
    >
    > What I do after creating HTML in dreamweaver I save that
    file into .txt
    > format
    > in dreamweaver. and then import it in MS Word. And I
    tried too much for it
    > but
    > invain.
    >
    > Please help me in finding the way of solution.
    >
    > Please help me as my job is in trouble. It's very urgent
    pleeease help me.
    > I'll be thankful to you.
    >

  • How to open bwf files on a bwf formatted disc

    Hi
    I use Fostex CR-500 to record. I can record fine when formatting this to Audio-CD.
    These files is easily imported in Logic.
    But when I want to record in 24/44,1 I have to BWF format the disc.
    But then I can´t import the files to logic.
    When opening in finder I can see the file on the disc.
    Any solutions or should I try a Windows machine?
    with regards
    Leif

    BWF is an audio file format (Broadcast Wave File) not a disk format. For your Fostex machine to record BWF files it needs to have the CDs formatted as UDF. This UDF format is what's causing you trouble. Logic and quicktime are very happy to handle BWF files. indeed its the default recording format for Logic!
    You need to find a way of reading those CD's.
    A quick google found this software (don't know if its any good or suitable!)...
    http://www.softarch.com/us/products/rdvd.html
    more info on UDF...
    http://homepage.mac.com/wenguangwang/myhome/udf.html
    It may also be down to the Fostex not producing proper finished or finalised disks. I don't know this machine but I'd guess it would have a sort of "finalising" process you need to implement to make your CD's ready to read on computers.
    Just my thoughts!

  • How to Check Images File Exist? in different server

    Hi,
    I have 10 different coldfusion server.
    for example 9 server is for the web application site - for
    example
    http://myserverone/studentweb
    the other one is for images website, just for displaying
    student picture - for example
    http://myserverimage/studentpicture.
    the purpose of this website is to display student picture
    that i store as gif files.
    from my studentweb website i will call the images from
    studentpicture website as source for my image placeholder.
    for example this is my code i'm calling form
    http://myserverone/studentweb
    website:
    <img src="
    http://myserverimage/studentpicture/#studentnumber#.gif"
    alt="" name="studentpicture" width="160" height="200">
    my problem is, if there is no specific student picture in my
    studentpicture website, then the placeholder will display an X (
    mean the images not found )
    how do i prevent the X to display?
    how do i using coldfusion or any kind of way to check if the
    images exist on that website ( different server ), so if the images
    is not found, i can display a default images? i can do this if i'm
    calling the website in the same server, but not using a different
    server.
    this is like using other website images for your own personal
    website and sometimes the owner delete the images from their
    website, and i want to display my own images if that images been
    removed from the source website.
    anyone have done this before?
    thanks for suggestion and guide...
    haire

    1. Use CFHTTP with method="HEAD".
    2. See, if the HTTP status code is 200.
    The head-method is of course more efficient, as it doesn't
    need to "get" the message body. However, a status code of 200 is
    possible even when the requested image file is no longer on the
    server.

  • How to check pc file path validity?

    Hi,
       In my program I have to extract so much SAP data and write in a file in the fornt-end PC. In the selection screen I will input the filepath\name to write the data.
    But how should I check whether the filepath is valid or not in the 'AT SELECTION-SCREEN' event itself? so that if it is not valid path, I can give an error message before extracting all the SAP data.
    Thank you!
    Sunitha.

    Hi Sunitha,
    Please check the following sample code from other thread at selection screen value request event.
    Using ABAP Objects:
    PARAMETER : p_file LIKE rlgrap-filename.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR path.
    DATA: directory TYPE string,                            
          filetable TYPE filetable,                         
          line      TYPE LINE OF filetable,                 
          rc        TYPE i.                                 
    CALL METHOD cl_gui_frontend_services=>get_temp_directory
      CHANGING                                              
          temp_dir = directory.      
    CALL METHOD cl_gui_frontend_services=>file_open_dialog  
      EXPORTING                                             
          window_title      = 'SELECT THE FILE'         
          initial_directory = directory                     
          file_filter       = '*.XLS'                       
          multiselection    = ' '                           
        CHANGING                                            
          file_table        = filetable    
          rc                = rc.                       
    IF rc = 1.                                          
      READ TABLE filetable INDEX 1 INTO line.           
      P_FILE = line-filename.                         
    ENDIF.   
    Using Normal ABAP:
    DATA: P_FILE LIKE RLGRAP-FILENAME,
          DPATH LIKE RLGRAP-FILENAME,
          UPATH LIKE RLGRAP-FILENAME,
          MODE TYPE C,
          FLG_UD TYPE C.
    CALL FUNCTION 'WS_ULDL_PATH'
      IMPORTING
        DOWNLOAD_PATH = DPATH
        UPLOAD_PATH   = UPATH.
    IF FLG_UD <> 'D'.
      DPATH = UPATH.
      MODE = 'O'.
    ELSE.
      MODE = 'S'.
    ENDIF.
    CALL FUNCTION 'WS_FILENAME_GET'
      EXPORTING
        DEF_FILENAME     = '*.XLS'
        DEF_PATH         = DPATH
        MASK             = ',*.XLS,*.*,*.*.'
        MODE             = MODE
      IMPORTING
        FILENAME         = P_FILE
      EXCEPTIONS
        SELECTION_CANCEL = 3.
    IF SY-SUBRC <> 0.
      EXIT.
    ENDIF.
    Hope this will help.
    Regards,
    Ferry Lianto

Maybe you are looking for

  • Problem in OIM Installation in Linux-64 bit environment

    Hi, Components used 1. Oracle Database11gR1 2. Weblogic Application server 10.3.0(installed in non clustered mode) 3. OIM 9.1.0.1 Also ensured the above three are compatible. I'm facing problem at the end of OIM installation in RedHat Linux-64 bit en

  • Is printing possible with script after the document with a password to prevent printing??

    I saved a pdf with a password to prevent printing. When I open the pdf with Adobe Reader, I want print the document with automatic. is this possible?? I used a many kinds method, all the scripts were refused because security level. please give me a a

  • Forms 10g itegration with ADF

    Hi, Can we integrate Forms 10g with ADF? Any Blogs/Reference to it? Thanks, CN

  • BridgeView gives error when starting historical data engine

    Has anyone come across this problem The software has been operating well for the last 3 years now all of a sudden has given this error when starting the Historical database engine

  • Just got Z22, have ?

    Hi,    I just got the Z22 Palm and I am trying to download it on my computer. I have the Vista operating system. I get a message when I run the instulation disk that say " internal error 2738" and than the next screen to exit. Can anyone help with th