Uploading CSV file to DB table using APEX

HI,
Can anyone guide me how to upload a .csv file to a DB table.
THANKS IN ADVANCE

user12550902 wrote:
as i got some information from the otn..i got a pl/sql code which is used in the process.
i used it in browse item .selecting file in the client disk and submitting it.when i press the button submit ,it calls a process.It is complex to parse a CSV file manually - as your code is doing. Using an external table (and having Oracle parse it for you), is a lot simpler.
My guess is that your parsing code fails to deal with all the data formatting cases for that CSV file - and thus the run-time error and failure.
I suggest that the very first thing you consider is modularisation. How can one test the parsing code in your source? It is totally embedded in the code. A very unflexible approach in all aspects - from code design to maintenance, troubleshooting and debugging. It also does not allow the CSV parsing code to be re-used.
It comes down to a very fundamental software engineering principle - modularise your code. Always.
Here's an example of creating a CSV parser - using a custom SQL data type to store the "tokens" from the CSV file, and a function to return it.
SQL> create or replace type TStrings is table of varchar2(4000);
  2  /                                                         
Type created.
SQL>
SQL> create or replace function tokenise( line varchar2, separatorChars varchar2 default ',', enclosedBy varchar2 default null ) return TStrings is
  2          strList         TStrings;                                                                                                            
  3          str             varchar2(4000);                                                                                                      
  4          i               integer;                                                                                                             
  5          l               integer;                                                                                                             
  6          enclose1        integer;                                                                                                             
  7          enclose2        integer;                                                                                                             
  8          encloseStr      varchar2(4000);                                                                                                      
  9          replaceStr      varchar2(4000);                                                                                                      
10                                                                                                                                               
11          procedure AddString( cLine varchar2 ) is                                                                                             
12          begin                                                                                                                                
13                  strList.Extend(1);                                                                                                           
14                  strList( strList.Count ) := REPLACE( cLine, CHR(0), separatorChars );                                                        
15          end;                                                                                                                                 
16                                                                                                                                               
17  begin                                                                                                                                        
18          strList := new TStrings();                                                                                                           
19                                                                                                                                               
20          str := line;                                                                                                                         
21          loop                                                                                                                                 
22                  if enclosedBy is not null then                                                                                               
23                          -- find the enclosed text, if any                                                                                    
24                          enclose1 := INSTR( str, enclosedBy, 1 );                                                                             
25                          enclose2 := INSTR( str, enclosedBy, 2 );                                                                             
26                                                                                                                                               
27                          if (enclose1 > 0) and (enclose2 > 0) and (enclose2 > enclose1) then                                                  
28                                  -- extract the enclosed string                                                                               
29                                  encloseStr := SUBSTR( str, enclose1, enclose2-enclose1+1 );                                                  
30                                  -- replace the separator char's with zero char's                                                             
31                                  replaceStr := REPLACE( encloseStr, separatorChars, CHR(0) );                                                 
32                                  -- and remove the enclosed quotes                                                                            
33                                  replaceStr := REPLACE( replaceStr, enclosedBy );                                                             
34                                  -- change the enclosed string in the big string to the replacement string                                    
35                                  str := REPLACE( str, encloseStr, replaceStr );                                                               
36                          end if;                                                                                                              
37                  end if;                                                                                                                      
38                                                                                                                                               
39                  l := LENGTH( str );                                                                                                          
40                  i := INSTR( str, separatorChars );                                                                                           
41                                                                                                                                               
42                  if i = 0 then                                                                                                                
43                          AddString( str );                                                                                                    
44                  else                                                                                                                         
45                          AddString( SUBSTR( str, 1, i-1 ) );                                                                                  
46                          str := SUBSTR( str, i+1 );                                                                                           
47                  end if;                                                                                                                      
48                                                                                                                                               
49                  -- if the separator was on the last char of the line, there is                                                               
50                  -- a trailing null column which we need to add manually                                                                      
51                  if i = l then                                                                                                                
52                          AddString( null );                                                                                                   
53                  end if;                                                                                                                      
54                                                                                                                                               
55                  exit when str is NULL;                                                                                                       
56                  exit when i = 0;                                                                                                             
57          end loop;                                                                                                                            
58                                                                                                                                               
59          return( strList );                                                                                                                   
60  end;                                                                                                                                         
61  /
Function created.
SQL> show errors
No errors.
SQL>
SQL> col TOKEN format a30
SQL>
SQL> -- default commas as separator, with a trailing null column
SQL> select rownum as TOKEN_ID, column_value as TOKEN from TABLE( tokenise('id,surname,date,1234,') );
  TOKEN_ID TOKEN
         1 id
         2 surname
         3 date
         4 1234
         5
SQL>
SQL> -- default commas as separator, with enclosed text, nulls, etc
SQL> select rownum as TOKEN_ID, column_value as TOKEN  from TABLE( tokenise('id,surname,"What do you want, universe?",date,1234,,another column',',','"') );
  TOKEN_ID TOKEN
         1 id
         2 surname
         3 What do you want, universe?
         4 date
         5 1234
         6
         7 another column
7 rows selected.
SQL>
{code}
This approach enables you to write a single and comprehensive parser, test it using SQL and PL/SQL, use it in PL/SQL and SQL, and re-use the code where and when needed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Getting Issue while uploading CSV file into internal table

    Hi,
    CSV file Data format as below
         a             b               c              d           e               f
    2.01E14     29-Sep-08     13:44:19     2.01E14     SELL     T+1
    actual values of column   A is 201000000000000
                     and  columen D is 201000000035690
    I am uploading above said CSV file into internal table using
    the below coding:
    TYPES: BEGIN OF TY_INTERN.
            INCLUDE STRUCTURE  KCDE_CELLS.
    TYPES: END OF TY_INTERN.
    CALL FUNCTION 'KCD_CSV_FILE_TO_INTERN_CONVERT'
        EXPORTING
          I_FILENAME      = P_FILE
          I_SEPARATOR     = ','
        TABLES
          E_INTERN        = T_INTERN
        EXCEPTIONS
          UPLOAD_CSV      = 1
          UPLOAD_FILETYPE = 2
          OTHERS          = 3.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    am getting all columns data into internal table,
    getting problem is columan A & D. am getting values into internal table for both; 2.01E+14. How to get actual values without modifying the csv file format.
    waiting for your reply...
    thanks & regards,
    abhi

    Hi Saurabh,
    Thanks for your reply.
    even i can't double click on those columns.
    b'se the program needs be executed in background there can lot of csv file in one folder. No manual interaction on those csv files.
    regards,
    abhi

  • Help Required:How Upload Excel file Into Oracle Table Using PLSQL Procedure

    Please Help , Urgent Help Needed.
    Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package.
    Case's are :
    1. Excel File is On Users/ Client PC.
    2. Application is on Remote Server(Oracle Forms D2k).
    3. User Is Using Application Using Terminal Server LogIn.
    4. So If User Will Use to GET_FILE_NAME() function of D2K to Get Excel File , D2k Will Try to pick File from That Remote Server(Bcs User Logind from Terminal Server Option).
    5. Cannot Use Util_File Package Or Oracle Directory to Place That File on Server.
    6. we are Using Oracle 8.7
    So Need Some PL/SQL Package or Fuction/ Procedure to Upload Excel file on User's Pc to Oracle Table.
    Please Guide me wd some Code. or with Some Pl/SQL Package, or With SOme Hint. Or any Link ....
    Jus help to Sort This Issue ........
    you can also write me on :
    [email protected], [email protected]

    TEXT_IO is a PL/SQL package available only in Forms (you'll want to post in the Forms forum for more information). It is not available in a stored procedure in the database (where the equivalent package is UTL_FILE).
    If the Terminal Server machine and the database machine do not have access to the file system on the client machine, no application running on either machine will have access to the file. Barring exceptional setups (like the FTP server on the client machine), your applications are not going to have more access to the client machine than the operating system does.
    If you map the client drives from the Terminal Server box, there is the potential for your Forms application to access those files. If you want the files to be accessible to a stored procedure in the database, you'll need to move the files somewhere the database can access them.
    Justin

  • Uploading CSV file into internal table

    Hi,
    I want to upload a CSV file into internal table.The flat file is having values as below:
    'AAAAA','2003-10-11 07:52:37','167','Argentina',NULL,NULL,NULL,NULL,NULL,'MX1',NULL,NULL,'AAAA BBBB',NULL,NULL,NULL,'1',NULL,NULL,'AR ',NULL,NULL,NULL,'ARGENT','M1V','MX1',NULL,NULL,'F','F','F','F','F',NULL,'1',NULL,'MX','MMI ',NULL
    'jklhg','2004-06-25 08:01:57','456','hjllajsdk','MANAGUA   ',NULL,NULL,'265-5139','266-5136 al 38','MX1',NULL,NULL,'hjgkid GRÖBER','sdfsdf dfs asdfsdf 380 ad ased,','200 as ads, sfd sfd abajao y 50 m al sdf',NULL,'1',NULL,NULL,'NI ',NULL,NULL,NULL,'sdfdfg','M1V','dds',NULL,NULL,
    Here I can not even split at ',' because some of the values are having value like NULL and some have values with comma too,
    The delimiter is a quote and the separator is a comma here.
    Can anyone help on this?
    Thanks.
    Edited by: Ginger on Jun 29, 2009 9:08 AM

    As long as there can be a comma in a text literal you are right that the spilt command doesn't help. However there is one possibility how to attack this under one assumption:
    - A comma outside a text delimiter is always considered a separator
    - A comma inside a text delimiter is always considered a comma as part of the text
    You have to read you file line by line and then travel along the line string character by character and setting a flag or counter for the text delimiters:
    e.g.
    "Text","Text1, Text2",NULL,NULL,"Text"
    String Index  1: EQ " => lv_delimiter = 'X'
    String Index  2: EQ T => text literal (because lv_delimiter = 'X')
    String Index  3: EQ e => text literal (because lv_delimiter = 'X')
    String Index  4: EQ x => text literal (because lv_delimiter = 'X')
    String Index  5: EQ t => text literal (because lv_delimiter = 'X')
    String Index  6: EQ " => lv_delimiter = ' ' (because it was 'X' before)
    String Index  7: EQ , => This is a separator because lv_delimiter = ' '
    String Index  8: EQ " => lv_delimiter = 'X' (because it was ' ' before)
    String Index  9: EQ T => text literal (because lv_delimiter = 'X')
    String Index 10: EQ e => text literal (because lv_delimiter = 'X')
    String Index 11: EQ x => text literal (because lv_delimiter = 'X')
    String Index 12: EQ t => text literal (because lv_delimiter = 'X')
    String Index 13: EQ 1 => text literal (because lv_delimiter = 'X')
    String Index 14: EQ , => text literal (because lv_delimiter = 'X')
    String Index 15: EQ T => text literal (because lv_delimiter = 'X')
    Whenever you hit a 'real' separator (lv_delimiter = ' ') you pass the value of the string before that up to the previous separator into the next structure field.
    This is not an easy way to do it, but if you might have commas in your text literal and NULL values I gues it is probably the only way to go.
    Hope that helps,
    Michael

  • Program to upload csv file to internal table and insert into database table

    Hi I'm writing a program where I need to upload a csv file into an internal table using gui_upload, but i also need this program to insert the data into my custom database table using the split command.  Anybody have any samples to help, its urgent!

    Hi,
    Check this table may be it will give u an hint...
    REPORT z_table_upload LINE-SIZE 255.
    Data
    DATA: it_dd03p TYPE TABLE OF dd03p,
          is_dd03p TYPE dd03p.
    DATA: it_rdata  TYPE TABLE OF text1024,
          is_rdata  TYPE text1024.
    DATA: it_fields TYPE TABLE OF fieldname.
    DATA: it_file  TYPE REF TO data,
          is_file  TYPE REF TO data.
    DATA: w_error  TYPE text132.
    Macros
    DEFINE write_error.
      concatenate 'Error: table'
                  p_table
                  &1
                  &2
             into w_error
             separated by space.
      condense w_error.
      write: / w_error.
      stop.
    END-OF-DEFINITION.
    Field symbols
    FIELD-SYMBOLS: <table> TYPE STANDARD TABLE,
                   <data>  TYPE ANY,
                   <fs>    TYPE ANY.
    Selection screen
    SELECTION-SCREEN: BEGIN OF BLOCK b01 WITH FRAME TITLE text-b01.
    PARAMETERS: p_file  TYPE localfile DEFAULT 'C:\temp\' OBLIGATORY,
                p_separ TYPE c DEFAULT ';' OBLIGATORY.
    SELECTION-SCREEN: END OF BLOCK b01.
    SELECTION-SCREEN: BEGIN OF BLOCK b02 WITH FRAME TITLE text-b02.
    PARAMETERS: p_table TYPE tabname OBLIGATORY
                                     MEMORY ID dtb
                                     MATCHCODE OBJECT dd_dbtb_16.
    SELECTION-SCREEN: END OF BLOCK b02.
    SELECTION-SCREEN: BEGIN OF BLOCK b03 WITH FRAME TITLE text-b03.
    PARAMETERS: p_create TYPE c AS CHECKBOX.
    SELECTION-SCREEN: END OF BLOCK b03,
                      SKIP.
    SELECTION-SCREEN: BEGIN OF BLOCK b04 WITH FRAME TITLE text-b04.
    PARAMETERS: p_nodb RADIOBUTTON GROUP g1 DEFAULT 'X'
                                   USER-COMMAND rg1,
                p_save RADIOBUTTON GROUP g1,
                p_dele RADIOBUTTON GROUP g1.
    SELECTION-SCREEN: SKIP.
    PARAMETERS: p_test TYPE c AS CHECKBOX,
                p_list TYPE c AS CHECKBOX DEFAULT 'X'.
    SELECTION-SCREEN: END OF BLOCK b04.
    At selection screen
    AT SELECTION-SCREEN.
      IF sy-ucomm = 'RG1'.
        IF p_nodb IS INITIAL.
          p_test = 'X'.
        ENDIF.
      ENDIF.
    At selection screen
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'F4_FILENAME'
           EXPORTING
                field_name = 'P_FILE'
           IMPORTING
                file_name  = p_file.
    Start of selection
    START-OF-SELECTION.
      PERFORM f_table_definition USING p_table.
      PERFORM f_upload_data USING p_file.
      PERFORM f_prepare_table USING p_table.
      PERFORM f_process_data.
      IF p_nodb IS INITIAL.
        PERFORM f_modify_table.
      ENDIF.
      IF p_list = 'X'.
        PERFORM f_list_records.
      ENDIF.
    End of selection
    END-OF-SELECTION.
          FORM f_table_definition                                       *
    -->  VALUE(IN_TABLE)                                               *
    FORM f_table_definition USING value(in_table).
      DATA: l_tname TYPE tabname,
            l_state TYPE ddgotstate,
            l_dd02v TYPE dd02v.
      l_tname = in_table.
      CALL FUNCTION 'DDIF_TABL_GET'
           EXPORTING
                name          = l_tname
           IMPORTING
                gotstate      = l_state
                dd02v_wa      = l_dd02v
           TABLES
                dd03p_tab     = it_dd03p
           EXCEPTIONS
                illegal_input = 1
                OTHERS        = 2.
      IF l_state NE 'A'.
        write_error 'does not exist or is not active' space.
      ENDIF.
      IF l_dd02v-tabclass NE 'TRANSP' AND
         l_dd02v-tabclass NE 'CLUSTER'.
        write_error 'is type' l_dd02v-tabclass.
      ENDIF.
    ENDFORM.
          FORM f_prepare_table                                          *
    -->  VALUE(IN_TABLE)                                               *
    FORM f_prepare_table USING value(in_table).
      DATA: l_tname TYPE tabname,
            lt_ftab TYPE lvc_t_fcat.
      l_tname = in_table.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
           EXPORTING
                i_structure_name = l_tname
           CHANGING
                ct_fieldcat      = lt_ftab
           EXCEPTIONS
                OTHERS           = 1.
      IF sy-subrc NE 0.
        WRITE: / 'Error while building field catalog'.
        STOP.
      ENDIF.
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = lt_ftab
        IMPORTING
          ep_table        = it_file.
      ASSIGN it_file->* TO <table>.
      CREATE DATA is_file LIKE LINE OF <table>.
      ASSIGN is_file->* TO <data>.
    ENDFORM.
          FORM f_upload_data                                            *
    -->  VALUE(IN_FILE)                                                *
    FORM f_upload_data USING value(in_file).
      DATA: l_file    TYPE string,
            l_ltext   TYPE string.
      DATA: l_lengt   TYPE i,
            l_field   TYPE fieldname.
      DATA: l_missk   TYPE c.
      l_file = in_file.
      l_lengt = strlen( in_file ).
      FORMAT INTENSIFIED ON.
      WRITE: / 'Reading file', in_file(l_lengt).
      CALL FUNCTION 'GUI_UPLOAD'
           EXPORTING
                filename = l_file
                filetype = 'ASC'
           TABLES
                data_tab = it_rdata
           EXCEPTIONS
                OTHERS   = 1.
      IF sy-subrc <> 0.
        WRITE: /3 'Error uploading', l_file.
        STOP.
      ENDIF.
    File not empty
      DESCRIBE TABLE it_rdata LINES sy-tmaxl.
      IF sy-tmaxl = 0.
        WRITE: /3 'File', l_file, 'is empty'.
        STOP.
      ELSE.
        WRITE: '-', sy-tmaxl, 'rows read'.
      ENDIF.
    File header on first row
      READ TABLE it_rdata INTO is_rdata INDEX 1.
      l_ltext = is_rdata.
      WHILE l_ltext CS p_separ.
        SPLIT l_ltext AT p_separ INTO l_field l_ltext.
        APPEND l_field TO it_fields.
      ENDWHILE.
      IF sy-subrc = 0.
        l_field = l_ltext.
        APPEND l_field TO it_fields.
      ENDIF.
    Check all key fields are present
      SKIP.
      FORMAT RESET.
      FORMAT COLOR COL_HEADING.
      WRITE: /3 'Key fields'.
      FORMAT RESET.
      LOOP AT it_dd03p INTO is_dd03p WHERE NOT keyflag IS initial.
        WRITE: /3 is_dd03p-fieldname.
        READ TABLE it_fields WITH KEY table_line = is_dd03p-fieldname
                             TRANSPORTING NO FIELDS.
        IF sy-subrc = 0.
          FORMAT COLOR COL_POSITIVE.
          WRITE: 'ok'.
          FORMAT RESET.
        ELSEIF is_dd03p-datatype NE 'CLNT'.
          FORMAT COLOR COL_NEGATIVE.
          WRITE: 'error'.
          FORMAT RESET.
          l_missk = 'X'.
        ENDIF.
      ENDLOOP.
    Log other fields
      SKIP.
      FORMAT COLOR COL_HEADING.
      WRITE: /3 'Other fields'.
      FORMAT RESET.
      LOOP AT it_dd03p INTO is_dd03p WHERE keyflag IS initial.
        WRITE: /3 is_dd03p-fieldname.
        READ TABLE it_fields WITH KEY table_line = is_dd03p-fieldname
                             TRANSPORTING NO FIELDS.
        IF sy-subrc = 0.
          WRITE: 'X'.
        ENDIF.
      ENDLOOP.
    Missing key field
      IF l_missk = 'X'.
        SKIP.
        WRITE: /3 'Missing key fields - no further processing'.
        STOP.
      ENDIF.
    ENDFORM.
          FORM f_process_data                                           *
    FORM f_process_data.
      DATA: l_ltext TYPE string,
            l_stext TYPE text40,
            l_field TYPE fieldname,
            l_datat TYPE c.
      LOOP AT it_rdata INTO is_rdata FROM 2.
        l_ltext = is_rdata.
        LOOP AT it_fields INTO l_field.
          ASSIGN COMPONENT l_field OF STRUCTURE <data> TO <fs>.
          IF sy-subrc = 0.
          Field value comes from file, determine conversion
            DESCRIBE FIELD <fs> TYPE l_datat.
            CASE l_datat.
              WHEN 'N'.
                SPLIT l_ltext AT p_separ INTO l_stext l_ltext.
                WRITE l_stext TO <fs> RIGHT-JUSTIFIED.
                OVERLAY <fs> WITH '0000000000000000'.           "max 16
              WHEN 'P'.
                SPLIT l_ltext AT p_separ INTO l_stext l_ltext.
                TRANSLATE l_stext USING ',.'.
                <fs> = l_stext.
              WHEN 'F'.
                SPLIT l_ltext AT p_separ INTO l_stext l_ltext.
                TRANSLATE l_stext USING ',.'.
                <fs> = l_stext.
              WHEN 'D'.
                SPLIT l_ltext AT p_separ INTO l_stext l_ltext.
                TRANSLATE l_stext USING '/.-.'.
                CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
                     EXPORTING
                          date_external = l_stext
                     IMPORTING
                          date_internal = <fs>
                     EXCEPTIONS
                          OTHERS        = 1.
              WHEN 'T'.
                CALL FUNCTION 'CONVERT_TIME_INPUT'
                     EXPORTING
                          input  = l_stext
                     IMPORTING
                          output = <fs>
                     EXCEPTIONS
                          OTHERS = 1.
              WHEN OTHERS.
                SPLIT l_ltext AT p_separ INTO <fs> l_ltext.
            ENDCASE.
          ELSE.
            SHIFT l_ltext UP TO p_separ.
            SHIFT l_ltext.
          ENDIF.
        ENDLOOP.
        IF NOT <data> IS INITIAL.
          LOOP AT it_dd03p INTO is_dd03p WHERE datatype = 'CLNT'.
          This field is mandant
            ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
                                                          TO <fs>.
            <fs> = sy-mandt.
          ENDLOOP.
          IF p_create = 'X'.
            IF is_dd03p-rollname = 'ERDAT'.
              ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
                                                            TO <fs>.
              <fs> = sy-datum.
            ENDIF.
            IF is_dd03p-rollname = 'ERZET'.
              ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
                                                            TO <fs>.
              <fs> = sy-uzeit.
            ENDIF.
            IF is_dd03p-rollname = 'ERNAM'.
              ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
                                                            TO <fs>.
              <fs> = sy-uname.
            ENDIF.
          ENDIF.
          IF is_dd03p-rollname = 'AEDAT'.
            ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
                                                          TO <fs>.
            <fs> = sy-datum.
          ENDIF.
          IF is_dd03p-rollname = 'AETIM'.
            ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
                                                          TO <fs>.
            <fs> = sy-uzeit.
          ENDIF.
          IF is_dd03p-rollname = 'AENAM'.
            ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
                                                          TO <fs>.
            <fs> = sy-uname.
          ENDIF.
          APPEND <data> TO <table>.
        ENDIF.
      ENDLOOP.
    ENDFORM.
          FORM f_modify_table                                           *
    FORM f_modify_table.
      SKIP.
      IF p_save = 'X'.
        MODIFY (p_table) FROM TABLE <table>.
      ELSEIF p_dele = 'X'.
        DELETE (p_table) FROM TABLE <table>.
      ELSE.
        EXIT.
      ENDIF.
      IF sy-subrc EQ 0.
        FORMAT COLOR COL_POSITIVE.
        IF p_save = 'X'.
          WRITE: /3 'Modify table OK'.
        ELSE.
          WRITE: /3 'Delete table OK'.
        ENDIF.
        FORMAT RESET.
        IF p_test IS INITIAL.
          COMMIT WORK.
        ELSE.
          ROLLBACK WORK.
          WRITE: '- test only, no update'.
        ENDIF.
      ELSE.
        FORMAT COLOR COL_NEGATIVE.
        WRITE: /3 'Error while modifying table'.
        FORMAT RESET.
      ENDIF.
    ENDFORM.
          FORM f_list_records                                           *
    FORM f_list_records.
      DATA: l_tleng TYPE i,
            l_lasti TYPE i,
            l_offst TYPE i.
    Output width
      l_tleng = 1.
      LOOP AT it_dd03p INTO is_dd03p.
        l_tleng = l_tleng + is_dd03p-outputlen.
        IF l_tleng LT sy-linsz.
          l_lasti = sy-tabix.
          l_tleng = l_tleng + 1.
        ELSE.
          l_tleng = l_tleng - is_dd03p-outputlen.
          EXIT.
        ENDIF.
      ENDLOOP.
    Output header
      SKIP.
      FORMAT COLOR COL_HEADING.
      WRITE: /3 'Contents'.
      FORMAT RESET.
      ULINE AT /3(l_tleng).
    Output records
      LOOP AT <table> ASSIGNING <data>.
        LOOP AT it_dd03p INTO is_dd03p FROM 1 TO l_lasti.
          IF is_dd03p-position = 1.
            WRITE: /3 sy-vline.
            l_offst = 3.
          ENDIF.
          ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data> TO <fs>.
          l_offst = l_offst + 1.
          IF is_dd03p-decimals LE 2.
            WRITE: AT l_offst <fs>.
          ELSE.
            WRITE: AT l_offst <fs> DECIMALS 3.
          ENDIF.
          l_offst = l_offst + is_dd03p-outputlen.
          WRITE: AT l_offst sy-vline.
        ENDLOOP.
      ENDLOOP.
    Ouptut end
      ULINE AT /3(l_tleng).
    ENDFORM.
    Regards,
    Joy.

  • Loading multiple .csv files into a table using SSIS

    Hi,
    I have a requirement where I have 200+ csv files to be loaded into Netezza table using SSIS.
    Issue I am facing is all columns have different number of columns, for ex, file 1 has columns A,B,C and file 2 has columns C,D,E. My target table has all columns from A to E in it. 
    But, when I am using for each loop container, only the file for which I have specified filepath+filename in loop variable, that is getting loaded. Rest all files, no data is getting loaded from them and package is executing successfully.
    Any help is appreciated.
    Regards,
    VT

    if you want to iterate through files then all files should be in same folder and you should use file enumerator type within ForEach loop. Then inside loop you might need a script task to generate the data flow on the fly based on the avialble input columns
    from the file and do the mapping in the destination. So I assume you put NULLs (or some default value) for missing columns from the file
    http://blog.quasarinc.com/ssis/best-solution-to-load-dynamically-change-csv-file-in-ssis-etl-package/
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Anyone know how to upload csv file to temp table of sybase DB from java?

    Dear All,
    I blindly need your help in achieving the following:
    I have the csv file which contains OrdId and BillId values. I just wanted to read these two values one by one from excel and loaded them into one temp table of Sybase SQL Anywhere.
    here is the sample query for your reference:
    begin tran
    create table tempdb..ordBill (ord_id int identity,bill_id int
    go
    load table tempdb..ordBill from 'c:\\test\\test.csv'Error:
    Incorrect syntax near the keyword 'table'.
    I am having only one tool Microsoft ISQL/W from which i connect to remote sybase DB and run some queries like sp_help , create etc.. from there.
    It would be great,if somebody knows the way of doing the above thru some java program. Otherwise, is there any tool like BCP required to do the above?
    Awaiting for your valuable reply
    thanks
    pannar

    Hi,
    I could connect to my Sybase DB thru java program. Can somebody help me how to upload the csv file into sybase temp table ?
    Here is the sample code:
    import java.sql.*;
    public class DBConn {
    public DBConn(){
    public static void main(String[] args) {
    try {
    //Class.forName("com.sybase.jdbc2.jdbc.SybDriver.class.getname()");
    //Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Class.forName("com.sybase.jdbc2.jdbc.SybDriver");
    String sourceURL = "jdbc:sybase:Tds:ldbd1.devo.ilx.com:5000";
    Connection conn = DriverManager.getConnection(sourceURL, "pannar", "pannar");
    //Connection conn = DriverManager.getConnection(sourceURL);
    System.out.println("Success");
    } catch (Exception e) {
    System.err.println("Got an excpetion! ");
    e.printStackTrace();
    }

  • Negative Numbers considered as VARCHAR while uploading CSV file under Data Load in APEX

    I am trying to upload a CSV file which contains negative numbers. These negative numbers are being considered as VARCHAR2 while uploading. And if I change the Column Type to Numbers the upload fails.
    Any solutions the problem will highly be appreciated.

    select * from nls_database_parameters
    where parameter = 'NLS_NUMERIC_CHARACTERS'
    shows you which characters your database believes represent the decimal place and the thousands separator. So, if your database expects 1,234.123 and you present a 'number' as 1 234,123 it will complain.
    Also, in your case... your comma-separated-values contain commas? Or are the individual fields enclosed with quotes?

  • Uploading EXCEL file into Internal Table Using GUI_UPLOAD

    Can any one please give me an example use of FM "GUI_UPLOAD" which to upload a EXCEL file????? (not .txt)

    Use the forum search option [GUI_UPLOAD FOR EXCEL|https://forums.sdn.sap.com/search.jspa?threadID=&q=GUI_UPLOADFOREXCEL&objID=c42&dateRange=all&numResults=15&rankBy=10001]) or sdn wiki/code gallery ([UPLOAD EXCEL|https://wiki.sdn.sap.com/wiki/dosearchsite.action?searchQuery.queryString=upload+Excel&searchQuery.spaceKey=conf_global])  - Same question already answered many time
    GUI_UPLOAD doesnt perform such conversion (Excel, Word, PDF) and wont give you a suitable result, use one of the FM mentioned above or [office integration|http://help.sap.com/saphelp_47x200/helpdata/en/21/b53138e1ba11d2bdbe080009b4534c/frameset.htm] or OLE or convert your Excel sheet to a simpler format : txt, csv, xml.
    Regards,
    Raymond

  • Uploading csv file with number type data to database using apex

    hi
    am trying to upload csv file to oracle database using apex when i select the file using file browser and click on the button.
    my table looks like
    coloumn type
    col1 number(2)
    col2 number(2)
    col3 number(2)
    col4 number(2)
    please tell me the steps i need to follow
    urgent requirement

    This thread should help - Load CSV file into a table when a button is clicked by the user

  • Uploading CSV file

    Hi,
    i saved excel file into CSV file in that file amount filed contains comma.now iam uploading csv file into internal table using GUI_UPLOAD iam getting data into internal table.
    internaltable contains row  like
    1100,600000,1114,"1,89",Hours on Project.  1,89 is amount
    filed.how can i split the above internal table and move to another internal table.another internal table row contains like 1100  600000 1114  1,89  Hours on Project. Please provide me solution.
    Regards,
    Suresh

    There is a function module for converting file to CSV format please find the code below :
    *& Report  ZCRPT_PP_013
    REPORT  zcrpt_pp_013.
           no standard page heading
           line-size  80
           line-count 65(0)
           message-id ...
      Dev. Class       :                                                 *
      Report Name      :                                                 *
      Program Type     :                                                 *
      Created by       :                                                 *
      Created on       :                                                 *
      Transaction Code :                                                 *
      Module Name      :                                                 *
      Object ID        :                                                 *
      Description      :                                                 *
      SAP Release      : 4.6 C                                           *
      Change Request   :                                                 *
    TYPE-POOLS : slis, truxs.
          1 :   Tables Defination                                        *
    TABLES : mseg,mara,makt,mard,t001w.
          2 :   Selection Screen                                         *
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS: s_matnr FOR mard-matnr.
    PARAMETERS : p_werks LIKE mard-werks.
    SELECTION-SCREEN END   OF BLOCK b1.
    *SELECTION-SCREEN BEGIN OF BLOCK m WITH FRAME.
    *PARAMETERS: p_file TYPE  rlgrap-filename.
    *SELECTION-SCREEN END OF BLOCK m.
          3 :   Internal Table Declaration                               *
    DATA   :  BEGIN OF it_mara OCCURS 0,
              place1(12),
              place2(12),
              matnr LIKE mard-matnr,
              maktx LIKE makt-maktx,
              labst LIKE mard-labst,
              werks like mard-werks,
              place3(12),
              date(10) ,
              END OF it_mara.
    DATA: it_mara1 TYPE truxs_t_text_data.
    DATA : layout    TYPE slis_layout_alv,
           event     TYPE slis_t_event ,
           wa_event  TYPE slis_alv_event,
           variant   TYPE disvariant.
    DATA : alvly     TYPE slis_layout_alv.
    DATA : alvev     TYPE slis_t_event.
    DATA : fcat      TYPE slis_t_fieldcat_alv.
    DATA : w_fcat    TYPE slis_fieldcat_alv.
            :   Start of Selection                                       *
    START-OF-SELECTION.
      perform build_layout.
      PERFORM select.
      PERFORM process.
      PERFORM display.
    END-OF-SELECTION.
      F o r m     R o u t i n e s     S t a r t s     H e r e            *
    *&      Form  SELECT
          text
    -->  p1        text
    <--  p2        text
    FORM select .
      SELECT matnr  werks FROM mard
             INTO CORRESPONDING FIELDS OF TABLE it_mara
             WHERE matnr IN s_matnr
             AND werks LIKE p_werks.
      LOOP AT it_mara.
      SELECT SUM( labst ) FROM mard INTO it_mara-labst
                                 WHERE matnr = it_mara-matnr
                                 AND werks = it_mara-werks.
        SELECT SINGLE maktx INTO it_mara-maktx FROM makt
                          WHERE matnr = it_mara-matnr.
        MODIFY it_mara TRANSPORTING maktx labst.
      ENDLOOP.
    ENDFORM.                    "SELECT
    *&      Form  PROCESS
          text
    -->  p1        text
    <--  p2        text
    FORM process .
      LOOP AT it_mara.
        WRITE  sy-datum TO it_mara-date USING EDIT MASK '__/__/____'.
        WRITE 'VIKROLI' TO it_mara-place1.
        WRITE 'VIKROLI' TO it_mara-place2.
        WRITE 'Stock'   TO it_mara-place3.
       WRITE  '2101'   TO it_mara-werks.
        MODIFY it_mara TRANSPORTING place1 place2 labst place3 date.
      ENDLOOP.
      DELETE ADJACENT DUPLICATES FROM it_mara  COMPARING ALL FIELDS.
      DELETE it_mara WHERE labst EQ ' '.
    CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
      EXPORTING
        I_FIELD_SEPERATOR          = ';'
      I_LINE_HEADER              =
      I_FILENAME                 =
      I_APPL_KEEP                = ' '
      TABLES
        i_tab_sap_data             = it_mara
      CHANGING
        I_TAB_CONVERTED_DATA       = it_mara1
      EXCEPTIONS
        CONVERSION_FAILED          = 1
        OTHERS                     = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
          CALL FUNCTION 'GUI_DOWNLOAD'
            EXPORTING
              filename                        = 'C:\Documents and Settings\coconut1\Desktop\ticket\FG_VIKROLI.csv'
            FILETYPE                        = 'ASC'
            WRITE_FIELD_SEPARATOR           = ','
          IMPORTING
            FILELENGTH                      =
            tables
              data_tab                        = it_mara1
            FIELDNAMES                      =
           EXCEPTIONS
             FILE_WRITE_ERROR                = 1
             NO_BATCH                        = 2
             GUI_REFUSE_FILETRANSFER         = 3
             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.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
    ENDFORM.                    " PROCESS
    *&      Form  DISPLAY
          text
    -->  p1        text
    <--  p2        text
    FORM display .
      w_fcat-fieldname = 'PLACE1'.
      w_fcat-tabname   = 'it_mara'.
      w_fcat-col_pos   = 1.
      w_fcat-outputlen = '10' .
      APPEND w_fcat TO fcat.
      CLEAR w_fcat.
      w_fcat-fieldname = 'PLACE2'.
      w_fcat-tabname   = 'it_mara'.
      w_fcat-col_pos   = 2.
      w_fcat-outputlen = '10' .
      APPEND w_fcat TO fcat.
      CLEAR w_fcat.
      w_fcat-fieldname = 'MATNR'.
      w_fcat-tabname   = 'it_mara'.
      w_fcat-col_pos   = 3.
      w_fcat-outputlen = '15' .
      APPEND w_fcat TO fcat.
      CLEAR w_fcat.
      w_fcat-fieldname = 'MAKTX'.
      w_fcat-tabname   = 'it_mara'.
      w_fcat-col_pos   = 4.
      w_fcat-outputlen = '40' .
      APPEND w_fcat TO fcat.
      CLEAR w_fcat.
      w_fcat-fieldname = 'LABST'.
      w_fcat-tabname   = 'it_mara'.
      w_fcat-col_pos   = 5.
      w_fcat-outputlen = '15' .
      APPEND w_fcat TO fcat.
      CLEAR w_fcat.
      w_fcat-fieldname = 'PLACE3'.
      w_fcat-tabname   = 'it_mara'.
      w_fcat-col_pos   = 6.
      w_fcat-outputlen = '15' .
      APPEND w_fcat TO fcat.
      CLEAR w_fcat.
      w_fcat-fieldname = 'DATE'.
      w_fcat-tabname   = 'it_mara'.
      w_fcat-col_pos   = 7.
      w_fcat-outputlen = '15' .
      APPEND w_fcat TO fcat.
      CLEAR w_fcat.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
         i_callback_program                = sy-repid
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = ' '
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
         is_layout                         = alvly
         it_fieldcat                       = fcat
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
         i_save                            =  'X'
      IS_VARIANT                        =
      IT_EVENTS                         =
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
        TABLES
          t_outtab                          = it_mara
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " DISPLAY
    *&      Form  build_layout
          text
    -->  p1        text
    <--  p2        text
    form build_layout .
    alvly-no_input          = 'X'.
    alvly-no_colhead        = 'X'.
    alvly-zebra             = 'X'.
    alvly-colwidth_optimize = 'X'.
    endform.                    " build_layout

  • Uploading CSV file into Webdynpro abap application

    Hi all,
    Please let me know the process of uploading .csv file in Webdynpro(ABAP) using FILE_UPLOAD UI element.
    Thanks
    Subathra

    Hi,
    you can use the following code ..........
    assumiing the file cointain tow colums name and age
    TYPES :
           BEGIN OF str_itab,
           name(10) TYPE c,
           age(10) TYPE c,
           END OF str_itab.  DATA : t_table1 TYPE STANDARD TABLE OF str_itab,
             i_data TYPE STANDARD TABLE OF string,
             lo_nd_sflight TYPE REF TO if_wd_context_node,
             lo_el_sflight TYPE REF TO if_wd_context_element,
             l_string TYPE string,
             fs_table TYPE str_itab,
             l_xstring TYPE xstring,
             fields TYPE string_table,
             lv_field TYPE string.  DATA : t_table TYPE if_main=>elements_data_tab,
             data_table TYPE if_main=>elements_data_tab.
    get single attribute 
    wd_context->get_attribute(    EXPORTING      name =  `DATASOURCE`    IMPORTING      value = l_xstring ).
      CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
        EXPORTING
          in_xstring = l_xstring
        IMPORTING
          out_string = l_string.
    SPLIT l_string  AT cl_abap_char_utilities=>newline INTO TABLE i_data.
    Bind With table Element.  LOOP AT i_data INTO l_string.
        SPLIT l_string AT cl_abap_char_utilities=>horizontal_tab INTO TABLE fields.   
        READ TABLE fields INTO lv_field INDEX 1.
        fs_table-name = lv_field.   
        READ TABLE fields INTO lv_field INDEX 2.
        fs_table-age = lv_field.    APPEND fs_table TO t_table1.
      ENDLOOP.
      lo_nd_sflight = wd_context->get_child_node( 'DATA_TAB' ).
      lo_nd_sflight->bind_table( t_table1 ).
    Thanks,
    Shaik Shadulla.
    Edited by: shaik shadulla on Jul 16, 2009 3:27 PM

  • Uploading csv file into database using apex

    Dear all
    I am using apex 4 and oracle express 10g, i need to upload .csv file into the database for one of my appls, i have referred discussion forum for solutions, i found also, but some how its not working for me.
    below mentioned is error and the code
    ERROR:
    ORA-06550: line 38, column 8: PLS-00221: 'V_DATA_ARRAY' is not a procedure or is undefined ORA-06550: line 38, column 8: PL/SQL: Statement ignored ORA-06550: line 39, column 8: PLS-00221: 'V_DATA_ARRAY' is not a procedure or is undefined ORA-06550: line 39, column 8: PL/SQL: Statement ignored ORA-06550: line 40, column 8: PLS-00221: 'V_DATA_ARRAY' is not a procedure or is undefined ORA-06550: line 40, column 8: PL/SQL: Statement ignored ORA-06550: line 41, column 8: PLS-00221: 'V_DATA_ARRAY' is not a proc
    Error
    OK
    CODE:
    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;
    BEGIN
    -- Read data from wwv_flow_files
    select blob_content into v_blob_data
    from wwv_flow_files where filename = 'DDNEW.csv';
    v_blob_len := dbms_lob.getlength(v_blob_data);
    v_position := 1;
    -- 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(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 v_char = CHR(10) THEN
    -- 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 TABLE_X (v1, v2, v3, v4 ,v5, v6, v7,v8 ,v9, v10, v11)
    values (:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11)'
    USING
    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);
    v_data_array(9);
    v_data_array(10);
    v_data_array(11);
    -- Clear out
    v_line := NULL;
    END IF;
    END LOOP;
    END;
    what i understand from this is system does not identify v_data_array as array for some reasons, please help me.
    initially system was giving error for hex_to_decimal, but i managed to get this function on discussion forum and now it seems to be ok. but v_data_array problem is still there.
    thanks in advance
    regards
    Uday

    Hi,
    Mistakes in your sample I did correct
    Problem 1
    select blob_content into v_blob_data
    from wwv_flow_files where filename = 'DDNEW.csv'; to
    select blob_content into v_blob_data
    from wwv_flow_files where name = :P1_FILE;Problem 2
    EXECUTE IMMEDIATE 'insert into TABLE_X (v1, v2, v3, v4 ,v5, v6, v7,v8 ,v9, v10, v11)
    values (:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11)'
    USING
    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);
    v_data_array(9);
    v_data_array(10);
    v_data_array(11);  to
    EXECUTE IMMEDIATE 'insert into TABLE_X (v1, v2, v3, v4 ,v5, v6, v7,v8 ,v9, v10, v11)
    values (:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11)'
    USING
    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),
    v_data_array(9),
    v_data_array(10),
    v_data_array(11);  And I did create missing table
    CREATE TABLE TABLE_X
        v1  VARCHAR2(255),
        v2  VARCHAR2(255),
        v3  VARCHAR2(255),
        v4  VARCHAR2(255),
        v5  VARCHAR2(255),
        v6  VARCHAR2(255),
        v7  VARCHAR2(255),
        v8  VARCHAR2(255),
        v9  VARCHAR2(255),
        v10 VARCHAR2(255),
        v11 VARCHAR2(255)
      );Regards,
    Jari
    Edited by: jarola on Nov 19, 2010 3:03 PM

  • How to upload above20000 records csv files into oracle table,Oracle APEX3.2

    Can any one help me how to CSV upload more than 20,000 records using APEX 3.2 upload process.i am using regular upload process using BOLB file
    SELECT blob_content,id,filename into v_blob_data,v_file_id,v_file_name
    FROM apex_application_files
    WHERE last_updated = (select max(last_updated)
    from apex_application_files WHERE UPDATED_BY = :APP_USER)
    AND id = (select max(id) from apex_application_files where updated_by = :APP_USER);
    I tried to upload but my page getting time out. my application best working up to 1000 records. after that its getting timed out.Each record is storing 2 secornds in the oracle table.So 1000 records it taking 7 minuts after that APEX upload webpage getting timed out
    please help me with source how to speed upload csv file process or help another best with with source example.
    Thanks,
    Sant.
    Edited by: 994152 on Mar 15, 2013 5:38 AM

    See this posting:
    Internet Explorer Cannot Display
    There, I provided a couple of links on this particular issue. You need to change the timeout on your application server.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.apress.com/9781430235125
    http://apex.oracle.com/pls/apex/f?p=31517:1
    http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
    -------------------------------------------------------------------

  • Upload csv file data to sql server tables

    Hi all,
    I want clients to upload csv file from their machines to the server.
    Then the program should read all the data from the csv file and do a bulk insert into the SQL Server tables.
    Please help me of how to go about doing this.
    Thanx in advance.....

    1) Use a multipart form with input type="file" to let the client choose a file.
    2) Get the binary stream and put it in a BufferedReader.
    3) Read each line and map it to a DTO and add each DTO to a list.
    4) Persist the list of DTO's.
    Helpful links:
    1) http://www.google.com/search?q=jsp+upload+file
    2) http://www.google.com/search?q=java+io+tutorial
    3) http://www.google.com/search?q=java+bufferedreader+readline
    4) http://www.google.com/search?q=jdbc+tutorial and http://www.google.com/search?q=sql+tutorial

Maybe you are looking for

  • Collection Question - Clearing a computer from one collection to another

    Hey Guys, I have quick question. I have two collection , one for windows 7 and for windows 8. When adding a computer to my windows 8 collection, can I simply delete the old object from the windows 7 collection? Or is there a process for doing this? T

  • TS2446 how to unlock my i pod

    i need to unloc my locked i pod

  • Modal windows while changing viewstack.selectedindex

    Hi! I have a viewstack and on one view I push a button and call below function. The viewstack changes but the screen freezes without showing me my alert box. Using "proper" PopUpManager functionality and a custom component did not solve the problem.

  • Calendar won't sync

    Ever since I installed the most recent iTunes upgrade (11.0.1) on my iMac, the calendar on my iMac does not sync to my iPad 2. This function worked fine until this latest version of iTunes. I am in the Info tab, which is where I used to be able to sy

  • How to setup exclusion indicator in price?

    who could give me a example about how to use exclusion indicator in price? That is to say how to cause different result according to different indicator value. what are needed to setup step by step?