Ignore the first row loading CSV of APEX

Hi guys, I used the method described here http://avdeo.com/2008/05/21/uploading-Excel-sheet-using-Oracle-Application-Express-Apex/ to load a CSV file into my oracle table and it works OK. Ideally, I would like to keep column headers in the CSV file and ignore when the file is downloaded.


DECLARE 
  v_blob_data         BLOB; 
  v_blob_len          NUMBER; 
  v_position          NUMBER; 
  v_raw_chunk         RAW(10000); 
  v_char              CHAR(1); 
  c_chunk_len         number                  := 1; 
  v_line              VARCHAR2 (32767)        := NULL; 
  v_data_array        wwv_flow_global.vc_arr2; 
  v_rows              number; 
  v_seq               number := 1;
  v_batch             number; 


  BEGIN 


   SELECT max(import_batch_id) +1
   INTO v_batch
   FROM XXMEL_PVS_BSH_ORDER;
  
   --delete from XXMEL_PVS_BSH_ORDER;
      
   -- Read data from wwv_flow_files 
   select blob_content 
   into v_blob_data
   from wwv_flow_files
   where last_updated = (select max(last_updated) 
                         from wwv_flow_files 
                         where UPDATED_BY = :P2_CURRENT_USER);
       


   
   -- Read data from wwv_flow_files
   -- SELECT blob_content 
   --  INTO v_blob_data
   --  FROM wwv_flow_files WHERE FILENAME = 'Book1.csv';
    
                    
    v_blob_len := dbms_lob.getlength(v_blob_data); 
    v_position := 1;
  
     --SELECT XXMEL_PVS_BSH_ORDER_S.nextval
     --INTO v_seq
     --FROM dual;    


     -- Read and convert binary to char 
    WHILE ( v_position <= v_blob_len ) 
     LOOP
        v_raw_chunk := dbms_lob.substr(v_blob_data,c_chunk_len,v_position); 
        v_char :=  CHR(xxmel_hex_to_decimal(RAWTOHEX(v_raw_chunk))); 
        v_line := v_line || v_char; 
        v_position := v_position + c_chunk_len; 
        -- When a whole line is retrieved 
        
      IF :P2_IMPORT_TYPE = 'FORECAST'
        THEN
        
         IF v_char = CHR(10) 
          THEN 
             --raise_application_error(-20001,'v_char:'||CHR(v_char));
             -- Convert comma to : to use wwv_flow_utilities
             v_line := REPLACE (v_line, ',', ':');
             -- Convert each column separated by : into array of data 
              v_data_array := wwv_flow_utilities.string_to_table (v_line); 
             -- Insert data into target table 
         
          EXECUTE IMMEDIATE 'INSERT INTO XXMEL_PVS_BSH_ORDER 
                            (IMPORT_ID
                            ,IMPORT_BATCH_ID
                            ,IMPORT_DATE
                           , REQUIREMENT_PERIOD
                           , PURCHASING_DOCUMENT
                           , MATERIAL
                           , DELIVERY_DATE
                           , SCHEDULED_QTY
                           , RESOURCE_NAME
                           , ORIGINAL_DELIVERY_DATE
                           , FORECAST_SET
                           , LOADED_BY
                           , IMPORT_TYPE
                           --, CUSTOMER
                           ) 
                             VALUES (:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13)' 
             USING
             v_seq--:P2_IMPORT_ID
             ,NVL(v_batch,1)
             ,sysdate
             ,v_data_array(1)
             ,v_data_array(2)
             ,v_data_array(3)
             ,v_data_array(4)
             ,v_data_array(5)
             ,v_data_array(6)
             ,v_data_array(7)
             ,v_data_array(8)
             ,:P2_CURRENT_USER
             ,:P2_IMPORT_TYPE
             --,:P2_CUSTOMER
             ;
            
          v_line := NULL;
          v_seq:= v_seq + 1;
             
         END IF;
         
       ELSIF :P2_IMPORT_TYPE = '21 LITRE'
        THEN 
         
        --SELECT XXMEL_PVS_BSH_ORDER_S.nextval
        --INTO v_seq
        --FROM dual;
        
        
         IF v_char = CHR(10) 
          THEN 
             --raise_application_error(-20001,'v_char:'||CHR(v_char));
             -- Convert comma to : to use wwv_flow_utilities
             v_line := REPLACE (v_line, ',', ':');
             -- Convert each column separated by : into array of data 
              v_data_array := wwv_flow_utilities.string_to_table (v_line); 
             -- Insert data into target table 
         
          EXECUTE IMMEDIATE 'INSERT INTO XXMEL_PVS_BSH_ORDER 
                            (IMPORT_ID
                            ,IMPORT_BATCH_ID
                            ,IMPORT_DATE
                           , PO_NUMBER
                           , MATERIAL
                           , REQUIREMENT_DATE
                           , SCHEDULED_QTY
                           , EDI_ORDER_NO
                           , CUSTOMER
                           , SHIP_TO
                           , SCHEDULED_SHIP_DATE
                           , LOADED_BY
                           , IMPORT_TYPE
                           
                           ) 
                             VALUES (:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12, :13)' 
             USING
             v_seq--:P2_IMPORT_ID
             ,NVL(v_batch,1)
             ,sysdate
             ,v_data_array(1)
             ,v_data_array(2)
             ,v_data_array(3)
             ,v_data_array(4)
             ,v_data_array(5)
             ,v_data_array(6)
             ,NVL(v_data_array(7),'bshgb consignee germany')
             ,v_data_array(8)
             ,:P2_CURRENT_USER
             ,:P2_IMPORT_TYPE
             ;
            
           v_line := NULL;
           v_seq:= v_seq + 1;
           
         END IF;  
           
      ELSIF :P2_IMPORT_TYPE = '36 LITRE'
        THEN 
         
         IF v_char = CHR(10) 
          THEN 
             --raise_application_error(-20001,'v_char:'||CHR(v_char));
             -- Convert comma to : to use wwv_flow_utilities
             v_line := REPLACE (v_line, ',', ':');
             -- Convert each column separated by : into array of data 
              v_data_array := wwv_flow_utilities.string_to_table (v_line); 
             -- Insert data into target table 
         
          EXECUTE IMMEDIATE 'INSERT INTO XXMEL_PVS_BSH_ORDER 
                            (IMPORT_ID
                            ,IMPORT_BATCH_ID
                            ,IMPORT_DATE
                           , PO_NUMBER
                           , MATERIAL
                           , REQUIREMENT_DATE
                           , SCHEDULED_QTY
                           , EDI_ORDER_NO
                           , CUSTOMER
                           , SHIP_TO
                           , SCHEDULED_SHIP_DATE
                           , LOADED_BY
                           , IMPORT_TYPE
                           ) 
                             VALUES (:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13)'  
            USING
             v_seq--:P2_IMPORT_ID
             ,NVL(v_batch,1)
             ,sysdate
             ,v_data_array(1)
             ,v_data_array(2)
             ,v_data_array(3)
             ,v_data_array(4)
             ,v_data_array(5)
             ,v_data_array(6)
             ,NVL(v_data_array(7),'bshgb consignee germany')
             ,v_data_array(8)
            ,:P2_CURRENT_USER
            ,:P2_IMPORT_TYPE
             ;
            
           v_line := NULL;
           v_seq:= v_seq + 1; 
           
             
         END IF; 


      END IF;
         
     END LOOP;
      
  END;


BEGIN
 xxmel_pvs_pkg.remove_chr;
END;

I tried to change the starting position in the above code but cannot make it work.

Can someone please indicate which must be placed under the code above in the order so he can start inserting line 2?

Thank you

Chris

You can try this:

Add this to the statements

Boolean v_first_line_read: = false;

And after this line "-when an entire row is retrieved.

IF v_char = Chr (10) AND NO v_first_line_read

THEN

v_first_line_read: = true;

v_line: = NULL;

v_char: = NULL;

END IF;

Tags: Database

Similar Questions

  • How to ignore the first row of the table when VO is used as a dvt:pieGraph?

    Hello

    I have a VO object read-only. I use this VO datacontrol object to display a table and pieGraph to my jspx page. When removed from the datacontrol as a pieGraph in page jspx, it gives the graph to 50% of the total (which is the first line) and all other lines at 50%. Here, my problem is that the first line of a column in the table is total of all other lines in this column. Now, I have to show the pieGraph with slices of all lines except the first row.  Is there a way I can do this without using programmatically. Or any other simple solution for program help. Help, please.

    Thank you

    Ashok Laura.

    Hello

    Assuming that we have a table that displays the details of the Department. We will build a dynamic pie chart to display the employee details for departments that are displaced from the Department table. Please check below blog.

    https://blogs.Oracle.com/ADF/entry/dynamic_pie_graph_generation_by

    Thank you

    Amey

  • How to freeze the first row in Microsoft Excel 2008 for MAC (worms. 12.3.6.)?

    Hello world

    I need to set the first row of a table in Excel 2008 for Mac. I know it should by a button, but don ' t have probably, or is hidden somewhere I checked the point of view, the tools and all the menu, I didn't find, y at - he someone to help me? Thank you

    Make sure you are in Normal mode, not Page view

    Go to the window in the menu bar and select freeze the panes

    Then you should be able to scroll through the sheet with line 1 has left in place.

    If you need for example three rows frozen, go to the fourth line and select freeze the panes.

    Then you should be able to scroll through the sheet with lines 1 to 3 from left in place.

  • The letters on my keyboard on the screen are passed. that is the A is now in the first row of letters, the M is in the middle line. How can I change?

    The letters on my keyboard on the screen are passed. that is the A is now in the first row of letters, the M is in the middle line. How can I change? I don't know how he has changed as a first step.

    Try the settings > General > keyboard > English > typing on the QWERTY keyboard. -AJ

  • LogFilter - ignoring the first alarm

    Here's the situation. We have three servers brprlmbpxxx and LogFilter agents deployed on each server. One of the strings match that we monitor is "Communication link failure". Every morning, we get two alerts on each server for a total of six alerts. We were informed by the developers that we can ignore these first six alerts every day. What I'm trying to do is to find a way that we do not have these six alerts but receive alerts later.

    Here is some info on this. These six alerts can come from any time of the day. So, I don't know if there is a way to configure a rule that will ignore the first two "Communication link failure" alerts LogFilter and then draw attention to any warning which follows.

    Hello Raul

    If these alerts are sent at the same time every day, you might have to try a power failure?

    Brian

  • ListField.drawListRow only draws a line in the first row, all the lines.

    I'm close. ListField.drawListRow is called for every row without problem, but the two graphics.drawLine only are displayed (shot) in the first row at the point of coordinates noted.

    I thought that each line would get the two drawn drawLines?

    Graphics.Clear is called correctly (as a test only - I have commented out them as well, but not changes).

    How can I get the two Graphics.drawLine at the bottom of the method called for each line, correctly?

    public void drawListRow(ListField listField, Graphics graphics, int index,
            int y, int width) {
        Logger.debug("CoffeeStoreContent [drawListRow] y: " + y + " width: " + width);
        /*
         * Top Margin
         */
        y += appGraphics.calcHiRes(6);
    
        int[] colors = appGraphics.getColorPalette(sportTitle);
    
        /*
         * Get the current CoffeeStore object.
         */
        CoffeeStore currentRow = (CoffeeStore) get(listField, index);
    
        StringBuffer subline = new StringBuffer(currentRow.getSource());
        subline.append(Characters.SPACE);
        subline.append("|");
        subline.append(Characters.SPACE);
        subline.append(currentRow.getDateAgo());
    
        int HiX = 43;
    
        if (graphics.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS)) {
            graphics.clear();
            graphics.setColor(AppGraphics.YELLOW_HIGHLIGHT);
            graphics.fillRect(0, (index * listField.getRowHeight()),
                    listField.getWidth(), listField.getRowHeight());
    
            graphics.setFont(font);
            graphics.setColor(Color.BLACK);
            graphics.drawText(currentRow.getLinkText(), HiX, y, 0, width);
    
            graphics.setColor(AppGraphics.TEIGHT);
            graphics.drawText(subline.toString(), HiX, (y
                    + graphics.getFont().getHeight() + 2), 0, width);
        } else {
            graphics.clear();
            graphics.setColor(colors[0]);
            graphics.fillRect(0, (index * listField.getRowHeight()),
                    listField.getWidth(), listField.getRowHeight());
    
            graphics.setFont(font);
            graphics.setColor(AppGraphics.TSIX);
            graphics.drawText(currentRow.getLinkText(), HiX, y, 0, width);
    
            graphics.setColor(Color.WHITE);
            graphics.drawText(subline.toString(), HiX, (y
                    + graphics.getFont().getHeight() + 2), 0, width);
        }
    
        graphics.setColor(colors[2]);
        graphics.drawLine(0, 50, width, 50);
        graphics.setColor(colors[3]);
        graphics.drawLine(0, 51, width, 51);
    }
    

    No - only y + 50 is enough.

  • How can I set the first row is 0, depending on the text box

    How can I set the first row is 0, according to the text box selected_text_to_inlineobj.jsx


    https://gist.github.com/milligramme/9368861@

    Try this,

    function boooxed (object_style_name) {
      if (app.selection.length !== 1) return
      var doc = app.documents[0];
      var sel = doc.selection[0];
      if ('baseline' in sel) {
        var bx = sel.insertionPoints[0].textFrames.add();
        bx.appliedObjectStyle = doc.objectStyles.item(object_style_name);
        bx.geometricBounds = [0,0,5,30];
        sel.duplicate(LocationOptions.AT_END, bx.parentStory);
        bx.insertionPoints[0].firstLineIndent=0;
        bx.fit(FitOptions.FRAME_TO_CONTENT);
        if (sel.contents.length) sel.remove();
      }
    };
    
    var object_style_name = "AAA"; //set anchored object settings, textframe preferences, and more
    boooxed(object_style_name);
    

    Vandy

  • Apply a paragraph style to the first cell in the first row of a table

    I want to apply a paragraph style to the first cell in the first row of a table.

    I use JavaScript with ID CS 5.

    Thank you.

    . aragraphStyles.itemByName ("NameOfStyle") .p appliedParagraphStyle = app.activeDocument.paragraphStyleGroups.itemByName ("NameOfGroup")

  • How to get the sum of the first row in the previous row?

    Dear gurus... I need to get the sum of a column of the first row of my result set to the previous line based on a condition. I read analytical functions for this but they provide the sum of the first rank to Current Row through declaration "rows between Unbounded preceding and current line. Y at - it a statement that calculates the sum as "rows between Unbounded preceding and previous row?

    Hello

    kamranpathan wrote:
    Dear gurus... I need to get the sum of a column of the first row of my result set to the previous line based on a condition. I read analytical functions for this but they provide the sum of the first rank to Current Row through declaration "rows between Unbounded preceding and current line.

    If you do not explicitly give a windowing clause, then you get the default windowing clause you indicated.
    If you want another clause of windowing, ionclude in the analytic function call.

    Y at - it a statement that calculates the sum as "rows between Unbounded preceding and previous row?

    Yes. The correct syntax for "Previous rank" is «PREVIOUS 1»

    ...  ROWS BETWEEN  UNBOUNDED PRECEDING
                AND        1          PRECEDING
    

    For more information, search for "Analytic Functions" in the manual of the SQL language:
    http://download.Oracle.com/docs/CD/E11882_01/server.112/e17118/functions004.htm#sthref917

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all tables and also post the results desired from these data.
    Explain, using specific examples, how you get these results from these data.
    Always tell what version of Oracle you are using.
    You will find the answers better faster if you always provide this information whenever you post a question.

    Published by: Frank Kulash, Sep 17, 2011 17:04
    I just saw Etbin responses.
    As usual, Etbin has a good point. If the column that you are basically cannot be NULL, then it is probably easier to subtract the total current line and use the default windowing clause.
    Even if it can be null, you find may be easier to use this approach.

  • Hide the first row of a table

    Hi all

    Can only hide the first row of a table (no matter what that data as there are)

    Thanks in advance,
    Imtiaz.

    Use

  • Problem with the removal of the first row of the table

    Hi all

    I have a problem with my forms with tables where I have buttons to add or remove rows from the table. Adding the lines works fine but deleting lines has a problem when deleting the first row. Example: Here is a table with two rows where column 1 has the add and remove buttons and column 2 user imput that looks like this:

    Column 1
    Column 2
    Add and remove buttons hererank 1
    Add and remove buttons hererank 2
    Add and remove buttons hererank 3

    If the user deletes line 2 the table looks like which is correct:

    Column 1
    Column 2
    Add and remove buttons hererank 1
    Add and remove buttons hererank 3

    If the user deletes line 1 then the table looks like which is false since the ranks 2 and 3 should be left:

    Column 1
    Column 2
    Add and remove buttons hererank 1
    Add and remove buttons hererank 3

    The code is pretty simple:

    Table3.row2.instanceManager.addInstance (1); for the click event of the button Add line

    Table3.row2.instanceManager.removeInstance (1); for the click event of the button Delete line

    What I am doing wrong?

    Thanks in advance!

    Al

    The expression will be based on your structure... done .This refers to the current object, parent refers to the container parent of this object and index is the index of this object. So watching your hierarchy and from the key, you will need this.parent to join the line subform is it in (usually it is th esubform that repeats). If it's in a subform, you will need to add another parent. Continue on this road until you get to the repeating subform and then ask its index. Your expression might look like this.parent.parent.parent.index. Using this.index, you find the instance of the button object and there are just people and that's why you always get 0.

    Make sense?

    BTW your form is attached not... so I can't check what you should put it.

    Paul

  • Ignore the first n lines with locked back.

    TimesTen is used from Java using the client-server access. We need to replicate the lines of TimesTen to a different database.

    We have lines of parallel job processing. During the treatment, the rows are locked:

    N FIRST SELECT * FROM TABLE_X FOR UPDATE

    The problem is that the first task selects and locks the first n rows and other jobs must wait until the locks are released. Is it possible to skip lines locked, so the other jobs would choose another set of lines.

    With Oracle, this can be accomplished by using the SKIP LOCKED clause. Locked IS NULL clause with SQL Server by using WHERE.

    Is it possible to have this kind of behavior in TimesTen?

    Is there another solution for replication of the lines? XLA API seems to be for this, but it seems a little complicated and use the direct access, which is not appropriate for our facility.

    Thank you

    Unfortunately, TimesTen doesn't have an option to ignore locked rows. I'm guessing that the "another database" is not Oracle? In this case, you can use a cache AWT group. XLA (or JMS/XLA for Java) really is the best option to "reproduce" in terms of performance, etc.. It is true that use the component which performs the "replication" to run on the computer where TimesTen runs, but the rest of the application would not have to do. Live view you the spirit gives much better performance :-)

    If you really need to do it through SQL, then you will need to find a way to get different jobs watch different sets of rows without locking up. Exactly how you could of course a lot depends on the application and exactly what he's trying to do. One approach would be to have a column in the table to identify what "Replicator" currently dealing line. You can use NULL means that it is not being processed and an ID value (could just be a number) to indicate that Replicator 1 (or 2 or 3 or...) is the treatment. Replicator ' wouldn't 'reserve' a set of rows to update it column "n" and commit. He would then do its job and then update the column again to another value which means "made replication." This can work very well or may not depending on what the application should do with lines, etc.

    Chris

  • Cannot connect to Youtube. The first page load, try to register and gets stuck in a loop.

    Pretty much what the title says. I try to load Youtube, and during the initial page load, it automatically attempts to connect. I don't know why, but it can not open my session and gets stuck in a loop. I don't have the patience to see if that solves finally itself, especially when I can sign very well in other browsers. The same thing happens whenever I try to connect to my Google account, as Youtube is related to Google.

    Many issues of the site can be caused by corrupted cookies or cache. To try to solve these problems, the first step is to clear cookies and cache.

    Note: This will be temporarily you disconnect from all the sites that you are connected. To clear the cache and cookies to do the following:

    • Go to Firefox > history > clear recent history or (if no Firefox button is displayed) go to tools > clear recent history.
    • Under "Time range to clear", select "all".
    • Now, click the arrow next to details to toggle the active details list.
    • In the list of details, see the Cache and Cookies and uncheck everything.
    • Now click the clear now button.

    More information can be found in article to clear your cache, history, and other personal information in Firefox .

  • Customize the table (first column and the first row)

    Hello everyone, I have a question: How can I insert words and numbers in the same table?

    I have create a VI that measure the temperature with an external instrument and put the data into a table, which is saved.

    Each line is a Thermocouple and each column is a measure, but there are only numbers!
    I would have the first column with the name of the channel and line of fist with the name of the measure.

    I had create an excel for example to explain my wish (Cattura.PNG).

    Thanks to all who help me

    You can insert headers required as column and row to convert it to an array of strings, as in the image below.

  • ExportCollectionAction causes the current values of lines to be copied into the first row of the table

    Greetings experts,

    I use JDev 11.1.2.3

    I am faced with a really strange behavior of the exportCollectionActionListener. I have a table for each row in this table, a link that calls a popUp. This popUp tells the story of this selected save changes (means it displays data from a different table/VO, who keeps a history of the first) in a table. I have a button that calls the exportCollection for this second table. When I press on it, an excel file is generated and downloaded and everything is perfect until now. If there was not any which record in this table, and o back to the first, by pressing the button send is not track all changes. But if there where all records from this table of history (always talking about the history of the current line), go back to the first and press on submit, that the very first line of the table of fir trees, gets all of it's values as the last row of the second table, as it is copied from one to the other. I have to press on restore back to normal (note that the popUp has it's CancelListener to call a restore of a bean to support operation).

    Why is this happening?

    Thanks in advance

    I found a work around for this problem.

    I added the code that causes the whole view Refresh (ie: the whole page), the popUp cancelListener, also I changed the commandLink partialSubmit property and set it to true. It's not like totally cool watching the screen charge for this fragment of a second after the closure of the pop-up window, but it not the drill.

Maybe you are looking for

  • How to upgrade PHP

    Just try to find how to upgrade PHP on El Capitan

  • When I start Firefox, it shows nothing more than a black screen and all toolbars are empty as well

    Title says it all. Every time I start Firefox, the screen is black. Where the buttons of the browser would be (buttons previous/next, toolbars, bookmarks, etc.), is a light background that does not display anything. Any help would be appreciated.

  • Title of podcast not appearing is not in iTunes

    I've been podcasting on iTunes for 6 months and all of a sudden the title says 'No Title' I understand that the title field may be empty, but I don't know how to fix it.  The problem appeared suddenly and everything works well on stitcher. Can you he

  • E5 - 571g tap in Crans interemittently of work

    My Synaptic touchpad sometimes lose the ability to tap-tap. Tapping the touchpad starts by dragging or by selecting instead of click, as if the mouse button is blocked. Hard clicking on the touchpad still works. The problem is that I can only get rid

  • Print spooler is corrupted after every reboot.

    original title: corrupt Printer Spooler I have huge problems with my spooler.  I tried every fix I found on this site, and they work.  Until my laptop is restarted, then Windows 7 seems to be obsessed with restore corrupted files.  It seems he has pr