Advice on uploading files and process data

Hi, I'm building an Apex application. It requires that users can sometimes upload data (csv) that will be validated and inserted into the database.
For now I've created a component that uploads the file and copy it to my UPLOADED_FILES archive table as a blob. Now I need to create a process that review data from blob and, if posible, inform the user of incorrect lines.
It seems that I need to recreate the file on the oracle server from the blob, then use SQL Loader to create an external table from that file and finally run my own validate/copy procedure over the external table data.
So my questions are:
- Is there a more proper way of doing this?
- Can I create the external table directly from the blob, without recreating the file, and an oracle directory?
- When using sql loader, how can I deal with quotes in the text? (the csv is generated from an spreedsheet, it can have text data with quotes that will be scaped, so a posible line will be (three fileds separated by semicolons):
my data 1;"my data 2""some escaped quotes here""and a semicolon inside ; my data 2 final";my data 3;
Will work the declaration: fields terminated by ";" optionally enclosed by '"' ?
note '"' = apostrophe+quotation+apostrophe
Thanks for your advice.

user3917161 wrote:
It seems that I need to recreate the file on the oracle server from the blob, then use SQL Loader to create an external table from that file and finally run my own validate/copy procedure over the external table data.
So my questions are:
- Is there a more proper way of doing this?The only other option is to manually parse the LOB yourself. So until Oracle provides external tables on LOBS too, this approach of writing it to external file for loading as an external table is a necessary evil.
- Can I create the external table directly from the blob, without recreating the file, and an oracle directory?No.
From Oracle® Database Administrator's Guide:
"<i>Oracle Database provides two access drivers for external tables. The default access driver is ORACLE_LOADER, which allows the reading of data from external files using the Oracle loader technology. The ORACLE_LOADER access driver provides data mapping capabilities which are a subset of the control file syntax of SQL*Loader utility. The second access driver, ORACLE_DATAPUMP, lets you unload data—that is, read data from the database and insert it into an external table, represented by one or more external files—and then reload it into an Oracle Database.</i>"
Perhaps we'll get a 3rd access driver in future that either supports LOBs, or enables us to define our own access driver (all that is needed as output from the driver is text lines - and this should not be that difficult to standardise as a custom interface to implement).
- When using sql loader, how can I deal with quotes in the text? (the csv is generated from an spreedsheet, it can have text data with quotes that will be scaped, so a posible line will be (three fileds separated by semicolons):
my data 1;"my data 2""some escaped quotes here""and a semicolon inside ; my data 2 final";my data 3;
Will work the declaration: fields terminated by ";" optionally enclosed by '"' ?
note '"' = apostrophe+quotation+apostropheBest is to try it and see whether it works. Also refer to the Oracle® Database Utilities for SQL*Loader syntax and options.

Similar Messages

  • Automator - Loop through a text file and process data through a 3rd party software

    Just stumbled on Automator the other day (I am a mac n00b) and would like to automate the processing of a text file, line-by-line, using a third party tool.  I would like Automator to loop through the text file one line at a time, copy the string and keep as a variable.  Next, place the variable data (copied string) into the text field of the 3rd party software for processing.  Once the processing is complete, I would like Automator to fetch the next line/string for processing.  I see items like "copy from clipboard" and  "variables" within the menu but I am not finding much documentation on how to utilizle this tool.  Just hear how potentially powerful it is. 
    The 3rd party software is not a brand name, just something made for me to process text.  I may have to use mouse clicks or tabs + [return] to navigate with Automator.  A term I heard on Bn Walldie's itunes video series was "scriptable software" for which I don't think this 3rd party app would be. 
    Kind regards,
    jw

    Good news and bad news...
    The good news is that it should be entirely possible to automate your workflow.
    The bad news is that it will be a nightmare to implement via Automator, if it's even possible.
    Automator is, essentially a pretty interface on top of AppleScript/Apple Events, and with the pretty interface comes a certain stranglehold on features. Knowing how to boil rice might make you a cook, but understanding flavor profiles and ingredient combinations can make you a chef, and it's the same with AppleScript and Automator. Automator's good at getting you from points A to B but if there are any bumps in the road (e.g. the application you're using isn't scriptable) then it falls apart.
    What I'm getting at is that your requirements are pretty simple to implement in AppleScript because you can get 'under the hood' and do exactly what you want, as opposed to Automator's restricted interface.
    The tricky part is that if no one else can see this app it's going to be hard to tell you what to do.
    I can give you the basics on reading a file and iterating through the lines of text in it, and I can show you how to 'type' text in any given application, but it may be up to you to put the pieces together.
    Here's one way of reading a file and working through each line of text:
    -- ask the user for a file:
    set theFile to (choose file)
    -- read the file contents:
    set theFileContents to (read file theFile)
    -- break out the lines/paragraphs of text:
    set theLines to paragraphs of theFileContents
    -- now iterate through those lines, one by one:
    repeat with eachLine in theLines
      -- code to perform for eachLine goes here
    end repeat
    Once you have a line of text (eachLine in the above example) you can 'type' that into another application via something like:
    tell application "AppName" to activate
    tell application "System Events"
              tell process "AppName"
      keystroke eachLine
              end tell
    end tell
    Here the AppleScript is activating the application and using System Events to emulate typing the contents of the eachLine variable into the process. Put this inside your repeat loop and you're almost there.

  • Upload media file and submit data in a same time

    Hi,
    I'm trying to submit data and upload file in a same time to a web page(which is jsp). But i found that the method used to upload file and submit data are different.
    Method used to submit data :-
    PostMethod post = new PostMethod(wbIndex);        
    post.addRequestHeader("Content-Type","text/html; charset=big5");
    for(int i=0;i<field.length;i++){
         post.addParameter(field,value[i]);
    System.out.print("field[" + field[i] + "], value[" + value[i] + "] ");
    responseCode = client.executeMethod(post);
    System.out.println("response code : " + responseCode);
    and method used to upload file
    URL url = new URL(wbIndex);
    // create a boundary string
    String boundary = MultiPartFormOutputStream.createBoundary();
    URLConnection urlConn = MultiPartFormOutputStream.createConnection(url);
    urlConn.setRequestProperty("Accept", "*/*");
    urlConn.setRequestProperty("Content-Type",
         MultiPartFormOutputStream.getContentType(boundary));
    // set some other request headers...
    urlConn.setRequestProperty("Connection", "Keep-Alive");
    urlConn.setRequestProperty("Cache-Control", "no-cache");
    // no need to connect cuz getOutputStream() does it
    MultiPartFormOutputStream out =
         new MultiPartFormOutputStream(urlConn.getOutputStream(), boundary);
    // write a text field element
    out.writeField("myText", "text field text");
    // upload a file
    out.writeFile("myFile", "text/plain", new File("C:\\test.wav"));
    out.close();Does anyone know how to submit data and upload file to the page at a same time?
    null

    Hi,
    Thanks for your reply. You meant that both method also can used to upload file and submit data? How about if i want to use the first method to upload file and submit data? How can i upload the file by using first method?

  • Upload material and contract data from file in CCM 2.0

    Hi guys,
    This might be a difficult one!
    We have the following situation in a Client:
    We are upgrading a Requisitite catalog (working with BBP 2.0)
    to a CCM 2.0 catalog.
    In Requisite, one can upload material- and contract data from a file (it is standard funcionality) into the database.
    We need to have the same kind of funcionality in CCM 2.0 because our client does not prefer to work with XI (which is the standard SAP solution in these cases).
    How can we accomplish this? maybe with some additional ABAP coding!
    Our client is not working with Vendor Catalogs but I´m trying to see if we can use a dummy vendor catalog to accomplish material upload in CCM2 form a CSV file.
    Anyone had to face this situation before?
    If so, please provide some clues how to do it?
    Thanks in advance,
    Aart

    SAP CATALOG CSV 2.0 <;>
    Defaults;EN
    Model
    Catalog;All;;All Catalog
    DataType;DATE;DATE;Date
    Characteristic;Z_ACTION;/CCM/NAME;false;Action
    Characteristic;/CCM/PRODUCT_ID;/CCM/ID;false;Part Number
    Characteristic;/CCM/SHORT_DESCRIPTION;/CCM/DESCRIPTION;false;Description
    Characteristic;Z_MATERIAL_TYPE;/CCM/ID;false;Material Type
    Characteristic;/CCM/MINIMUM_QUANTITY;/CCM/MINIMUM_QUANTITY;false;Order Unit
    Characteristic;Z_CONTENT;/CCM/MINIMUM_QUANTITY;false;Content
    Characteristic;/CCM/LEAD_TIME;/CCM/LEAD_TIME;false;Lead Time
    Characteristic;Z_SUPPLIER_ID;/CCM/ID;false;Supplier Number
    Characteristic;Z_SUPPLIER_NAME;/CCM/NAME;false;Sup Name
    Characteristic;Z_P_GROUP;/CCM/ID;false;Purchasing Group
    Characteristic;Z_P_ORG;/CCM/ID;false;Purchasing Org
    Characteristic;/CCM/CONTRACT_ID;/CCM/ID;false;Contract Number
    Characteristic;/CCM/CONTRACT_ITEM_ID;/CCM/ID;false;Contract Item
    Characteristic;/CCM/PRODUCT_GROUP;/CCM/ID;false;Product Category
    Characteristic;/CCM/PRICE;/CCM/PRICE;true;Price
    Characteristic;Z_DATE;DATE;false;Date
    Characteristic;/CCM/LONG_DESCRIPTION;/CCM/LONG_DESCRIPTION;false;Long Description
    Characteristic;/CCM/PICTURE;/CCM/ATTACHMENT;false;Picture
    Schema;All;Z_ACTION;Z_MATERIAL_TYPE;Z_CONTENT;Z_SUPPLIER_ID;Z_SUPPLIER_NAME;Z_P_GROUP;Z_P_ORG;Z_DATE;All Schema
    Category;10000300;;;ABC
    Category;10000400;;;DEF

  • Reading file and dump data into database using BPEL process

    I have to read CSV files and insert data into database.. To achieve this, I have created asynchronous bpel process. Added Filed Adapter and associated it with Receive activity.. Added DB adapter and associated with Invoke activity. Total two receive activity are available in  process, when tried to Test through EM, only first receive activity is completed, and waiting on second receive activity. Please suggest how to proceed with..
    Thanks, Manoj.

    Deepak, thank for your reply.. As per your suggestion I created BPEL composite with
    template "Define Service Later". I followed below steps, please correct me if I am wrong/missing anything. Your help is highly appreciated...
    Step 1-
    Created File adapter and corresponding Receive Activity (checkbox create instance is checked) with input variable.
    Step 2 - Then in composite.xml, dragged the
    web service under "Exposed Services" and linked the web service with Bpel process.
    Step 3 - Opened .bpel file and added the DB adapter with corresponding Invoke activity, created input variable. Web service is created of Type "Service" with existing WSDL(first option aginst WSDL URL).
    and added Assign activity between receive and invoke activities.
    Deployed the composite to server, when triedTest it
    manually through EM, it is promting for input like "subElmArray Size", then I entered value as 1 with corresponding values for two elements and click on Test We Service button.. Ptocess is completing in error. The error is
    Error Message:
    Fault ID
    service:80020
    Fault Time
    Sep 20, 2013 11:09:49 AM
    Non Recoverable System Fault :
    Correlation definition not registered. The correlation set definition for operation Read, process default/FileUpload18!1.0*soa_3feb622a-f47e-4a53-8051-855f0bf93715/FileUpload18, is not registered with the server. The correlation set was not defined in the process. Redeploy the process to the containe

  • How to upload file and show it's progress

    hi
    i want to upload files and show the progress of the upload
    process how?
    thanks in advance.

    Hey,
    I attached a sample I did in Flash 8 using PHP. Hope it
    helps.
    http://www.cybercussion.com/vault/fileuploading.zip

  • Opening an .xls file and writing data to it....

    Hi ,
    I have written the following simple routine... which is supposed to open a .xls file and some data are written...:
    DECLARE
    application ole2.obj_type;
    workbooks ole2.obj_type;
    workbook ole2.obj_type;
    worksheet ole2.obj_type;
    worksheets ole2.obj_type;
    cell ole2.obj_type;
    --Declare handles to OLE argument lists
    args ole2.list_type;
    BEGIN
    application:=OLE2.CREATE_OBJ('Excel.Application');
    OLE2.Set_Property(application,'Visible', 'True');
    workbooks := ole2.get_obj_property(application, 'Workbooks');
    workbook:=OLE2.INVOKE_OBJ(workbooks,'Add');
    args:= ole2.create_arglist;
    ole2.add_arg(args, 'c:\example.XLS');
    workbook := ole2.invoke_obj(workbook, 'Open', args);
    ole2.destroy_arglist(args);
    args:=OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(args, 1); 
    OLE2.ADD_ARG(args, 1);
    cell:=OLE2.Invoke_Obj(workbooks, 'Cells', args); 
    OLE2.DESTROY_ARGLIST(args);
    OLE2.Set_Property(cell, 'Value', 'Excel');
    args := OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(args, 0);
    OLE2.INVOKE(workbook, 'Close', args);
    OLE2.DESTROY_ARGLIST(args);
    OLE2.RELEASE_OBJ(cell);
    OLE2.RELEASE_OBJ(workbook);
    OLE2.RELEASE_OBJ(workbooks);
    OLE2.RELEASE_OBJ(application);
    OLE2.INVOKE(application,'Quit');
    END; but it does nothing.... it simply opens the Excel application..... How should I modify the routine in order to open the example.xls file and write some data to it .....???????
    Many thanks,
    Simon

    OK... I SOLVED THE PROBLEM.....
    Regards,
    Simon

  • Save the file and give date & time stamp

    1. Reading the Excel file from the selection screen as a parameter.
    2. Using F.M. ALSM_EXCEL_TO_INTERNAL_TABLE reading Excel file into
        Internal table.
    3. Implementing the Business Logic.
    4. Move output to Final Internal table.
    5. Final internal table should generate a Flat file. By using GUI_DOWNLOAD.
    6. That flat file should be saved with the name and location given in the Excel.
    7. When ever I run the program output file will generate in the same location but with date and time stamp. Because I’m running the program for range of employees say initially I run for 1 – 10,000 employees next 10,001- 20,000 like that.
    Whenever I run for 2nd time it will overwrite the previous output, that’s the reason I’m using date and time stamp.
    Eg:
    PERSONAL Numbers              Name                                         Location
    00000001                 xxxxx-24.04.2007-10.30          C:\        
    00000002                 xxxxx-24.04.2007-10.35
    00000003                 xxxxx-25.04.2007-10.40
    00000004                                  xxxxx-25.04.2007-10.30
    Can any one help me how to save the file and give date & time stamp through hardcode?
    please help me in this issue.

    I am not clear with your problem. Based on the understanding of your question,
    there  can be two cases.
    1- U want to insert time stamp in the output file.
    2- Time stamp is already there, u just have to solve the overwriting issue.
    If your question goes with option 2, You can make use of import parameters
    <b>CONFIRM_OVERWRITE</b> : Which will ask for confirmation before overwriting.
    <b>APPEND</b> : which you can choose either to append the data to the existing file or overwrite it.
    Please inform if the issue is not resolved.
    Message was edited by:
            BINU RAJ BINU

  • Please recommend if we have options to read xml file and insert data into table without a temporary table.

    Please recommend if we have options to read xml file and insert data into table without a temporary table. 

    DECLARE @data XML;
    SET @data =N'<Root>
    <List RecordID="946236" />
    <List RecordID="946237" />
    <List RecordID="946238" />
    <List RecordID="946239" />
    <List RecordID="946240" />
    </Root>'
    INSERT INTO t (id) SELECT T.customer.value('@RecordID', 'INT') AS id
    FROM @data.nodes('Root/List')
     AS T(customer);
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • When I upload files and correct in lightroom then I export to another named file I keep getting two duplicates. numbered 1 and 2. this never happened before

    When I upload files and correct in lightroom then I export to another named file I keep getting two duplicates. numbered 1 and 2. this never happened before

    When I first upload to lightroom I set up a file called new photos. When I correct them I export to a newly named file. But when I go to the newly named
    File on my harddrive there are duplicate files
    Stan

  • How to read an ascii file and record data in a 2d array

    HI everyone,
    I have an experimental data file in ascii format. It contains 10 data sets.
    I'm trying to read the ascii file and record data in a 2d array for further analysis,
    but I still could not figure it out how to do it.
    Please help me to get this done.
    Here I have attaced the ascii file.
    -Sam
    Attachments:
    data.asc ‏123 KB
    2015-01-27_18-01-31_fourier_A2-F-abs.zip ‏728 KB

    Got it!
    Thank you very much !
    -Pamsath

  • How can FMS create a text file and write data into it in the Server application folders?

    Recently, I writed a programe about creating a text file and writing data into it in the server application folder. My code is as following:
               var fileObj = new File("/MyApp/test.txt");
               if( fileObj !=  null)
                      if(fileObj.open( "text", "append"))
                            fileObj.write( "                                                      ———— Chat Info Backup ————\r\n" );
                            fileObj.close( );
                            trace("Chat info backup document :" +  fileObj.name + " has been created successfully!");    
    But when I run it, FMS throw the error as following: File operation open failed  ;  TypeError: fileObj has no properties.
    Can you help me ? Thanks in advance.
    Supplement: The text file named test.txt doesn't exist before create the fileObj, an instance of File Class.

    Is MyApp the name of the application directory, or is it a child of the application directory? If myApp is the app name, just use test.txt as the path flag in the file constructor.

  • File upload using commons-upload-file and tomcat 5.5

    Hi,
    This is my first post and I hope that I post it at the right place.
    I'm trying to upload a file using commons-upload-file and tomcat 5.5.
    Is there a way to prevent submitting a big file, If I detect that the file being uploaded exceed a limit that I have fixed ?
    i.e. I check the request length, if it's bigger than 1meg I cancel the whole thing and the big file is not transferred.
    The problem that I get at the moment is that it seems that the file is transferred even if I close request inputstream or response outputstream. Any help would be appreciated !
    Thank you
    Redgy

    Well here is a snippet of my code:
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            long maxSize = 50000;
            boolean isMultipart = ServletFileUpload.isMultipartContent(request);
            if(isMultipart){
                // Create a new file upload handler
                ServletFileUpload upload = new ServletFileUpload();
                upload.setSizeMax(maxSize);
                try {
                    upload.parseRequest(request);
                } catch (FileUploadException ex) {
                    ex.printStackTrace();
                    request.getInputStream().close();
                    response.getWriter().print("blah");
                    response.sendError(response.SC_INTERNAL_SERVER_ERROR);
                    response.getOutputStream().close();
        }If the file is bigger than 50kb, it Throws the FileUploadException.
    But whatever I do, It seems that there is still a connection between my browser and tomcat.. any clue ?
    thanks
    Edited by: redgyx on Jan 31, 2008 6:17 AM

  • HT4599 How do I upload photos from PC to icloud - loaded into upload file and does not seem to upload

    How do I upload photos from PC to icloud.  I have already moved photos to icloud upload file and nothing seems to upload.  jnelso1

    I have this problem too. Photo stream works fine on iPhone+iPad, but the photos are never loaded to my PC (Win 8.1). My shared folders works fine on iOS and PC, but not My photo stram.
    In the beginning, a couple of years ago, it work, but not now (2014).
    All iOS are updated, and PC-iCloud software/panel is Active, and Photo stream is activated.
    What to do??
    Reset all streams on PC? I tried, no result.
    I can understand that it takes time to reload all Pictures from iCload to my PC, but I wait Days, weeks...

  • Uploading Excel File and Reading Data from that File

    <b>Hi
    Can anyone Please tell me how to upload an Excel File in to the Web Dynpro Application and After that i want to read the data from that uploaded excel file in the Web Dynpro Application to the Web Dynpro table.
    Plz help me to solve this.......
    Regards
    Chandran</b>

    Hi,
    Upload Excel file using File Upload UI
    1)Add jxl jar folder in the lib folder of ur project.
    2)Go to properties of ur project and add jar to ur project.
    3)Using the File upload ui ,browse and upload the file.
    4)Write the read file in to ur server location using fileoutput stream.
    5)then using code u can read the excelfile from the server location itself.
    Here is the code:
         IWDAttributeInfo attInfo =wdContext.getNodeInfo().getAttribute("upload");
    /** get the name of excel file and storing it in the server with the same name and extention****/
    binaryType=IWDModifiableBinaryTypeattInfo.getModifiableSimpleType();
    fileuploaded = binaryType.getFileName();
    byte b[] = wdContext.currentContextElement().getUpload();
    File filename =new File("
    <Server name>
    <folde name>
    " + fileuploaded);
    try {
    FileOutputStream out = new FileOutputStream(filename);
    out.write(b);
    out.close();
    } catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    /**Readind from the server**/
    int iRows = 0;
    try {     Workbook wb = null;
         Sheet sheet = null;
         wb = Workbook.getWorkbook(filename);
         sheet = wb.getSheet(0);
         int iColumns = sheet.getColumns();
          iRows = sheet.getRows();
         int i = 0;
        //get Cell contents by (COLUMN, ROW);
        for (int r = 0; r < iRows; r++) {
       for (int c = 0; c < iColumns; c++) {
         Cell cell = sheet.getCell(c, r);
         characterarray<i> = cell.getContents();
    //wdComponentAPI.getMessageManager().reportSuccess("Row"r characterarray<i>);
    i++;
    wb.close();
    Declare Globally
    //@@begin others
    String fileuploaded;
    IWDModifiableBinaryType binaryType;
    String characterarray[] = new String[1000];
    //@@end
    Also look at this blog too  /people/perumal.kanthan/blog/2005/03/21/reading-excel-data-from-java-using-hssf-api
    Thanks and Regards,
    Arun

Maybe you are looking for

  • Traveling with the imac 24"

    Hi everyone, I have the late 2006 iMac 24" and i'm looking to bring this along with me for an overseas assignment. I've read about the iLugger and i've read about shipping the iMac using the original box that came with it. Has anyone had any experien

  • All incoming receipts with specific WBS elemnt.

    Hi, This is my posting in SDN.Now iam working in supporting side.I  want to create  A new FI AR report is needed which would display all invoices and received payments for a specific WBS element. The required fields are available in 0FIAR_4 . We are

  • Outbound e-mails blocked in Outlook

    I'm using Outlook V14.0.2 for Mac and suddenly outbound messages became blocked again.  Had problem previously more than a month ago when Port 25 was blocked so changed to port 587 and all was well.  Suddenly this problem has reappeared again and wit

  • Indesign CS 6 keeps crashing when I delete an object

    Indesign CS 6 keeps crashing when I delete an object

  • Reader views EPS?

    Hello. I understand Reader is supposed to be able to view EPS files.  For some time I have noted that Reader has not been able to view the EPS documents that I have created using CorelDraw X4. They open fine in Illustrator 10, re-open fine in CorelDr