Dynamically creating oracle table with csv file as source

Hi,
We have a requirment..TO create a dynamic external table.. Whenever the data or number of columns change in the CSV file the table should be replaced with current data and current number of columns...as we are naive experienced people in oracle please give us a clear solution.. We have tried with a code already ..But getting some errors. Code given below..
thank you
we have executed this code by changing the schema name and table name ..Remaining everything same ...
Assume the following:
- Oracle User and Schema name is ALLEXPERTS
- Database name is EXPERTS
- The directory object is file_dir
- CSV file directory is /export/home/log
- The csv file name is ALLEXPERTS_CSV.log
- The table name is all_experts_tbl
1. Create a directory object in Oracle. The directory will point to the directory where the file located.
conn sys/{password}@EXPERTS as sysdba;
CREATE OR REPLACE DIRECTORY file_dir AS '/export/home/log';
2. Grant the directory privilege to the user
GRANT READ ON DIRECTORY file_dir TO ALLEXPERTS;
3. Create the table
Connect as ALLEXPERTS user
create table ALLEXPERTS.all_experts_tbl
(txt_line varchar2(512))
organization external
(type ORACLE_LOADER
default directory file_dir
access parameters (records delimited by newline
fields
(txt_line char(512)))
location ('ALLEXPERTS_CSV.log')
This will create a table that links the data to a file. Now you can treat this file as a regular table where you can use SELECT statement to retrieve the data.
PL/SQL to create the data (PSEUDO code)
CREATE OR REPLACE PROCEDURE new_proc IS
-- Setup the cursor
CURSOR c_main IS SELECT *
FROM allexperts.all_experts_tbl;
CURSOR c_first_row IS ALLEXPERTS_CSV.logSELECT *
FROM allexperts.all_experts_tbl
WHERE ROWNUM = 1;
-- Declare Variable
l_delimiter_count NUMBER;
l_temp_counter NUMBER:=1;
l_current_row VARCHAR2(100);
l_create_statements VARCHAR2(1000);
BEGIN
-- Get the first row
-- Open the c_first_row and fetch the data into l_current_row
-- Count the number of delimiter l_current_row and set the l_delimiter_count
OPEN c_first_row;
FETCH c_first_row INTO l_current_row;
CLOSE c_first_row;
l_delimiter_count := number of delimiter in l_current_row;
-- Create the table with the right number of columns
l_create_statements := 'CREATE TABLE csv_table ( ';
WHILE l_temp_counter <= l_delimiter_count
LOOP
l_create_statement := l_create_statement || 'COL' || l_temp_counter || ' VARCHAR2(100)'
l_temp_counter := l_temp_counter + 1;
IF l_temp_counter <=l_delimiter_count THEN
l_create_statement := l_create_statement || ',';
END IF;
END;
l_create_statement := l_create_statement || ')';
EXECUTE IMMEDIATE l_create_statement;
-- Open the c_main to parse all the rows and insert into the table
WHILE rec IN c_main
LOOP
-- Loop thru all the records and parse them
-- Insert the data into the table created above
END LOOP;

The initial table is showing errors and the procedure is created with compilation errors
After executing the create table i am getting the following errors
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-00554: error encountered while parsing access parameters
KUP-01005: syntax error: found "identifier": expecting one of: "badfile,
byteordermark, characterset, column, data, delimited, discardfile,
disable_directory_link_check, exit, fields, fixed, load, logfile, language,
nodiscardfile, nobadfile, nologfile, date_cache, processing, readsize, string,
skip, territory, varia"
KUP-01008: the bad identifier was: deli
KUP-01007: at line 1 column 9
ORA-06512: at "SYS.ORACLE_LOADER", line 19

Similar Messages

  • Uploading Dynamically created Internal table form Flat file

    I am creating dynamic internal table as follows:
    *-create dynamic internal table
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = i_fldcat[]
        IMPORTING
          ep_table        = i_modify.
      ASSIGN i_modify->* TO <fs_tab>.
    The dymamic internal table is created with the given Ztable in the selection screen.
    Now the problem is when I try to upload this table <fs_table> using function module Call function 'UPLOAD'.
    The first column of flat file is getting updated in Mandt of <fs_table>.
    I want to update sy-mandt in MANDT of <fs_table> and the rest of the fields with flat file data.
    e.g.
    Flat file data:
    100 white
    101 black
    <fs_table> structure is getting uploaded as below
    mandt zcode zdesc
    100     white
    101     black
    if the clint is 700
    it has to be uploaded as
    mandt zcode zdesc
    700    100     white
    700    101     black
    Can someone knows what should be the approach or any other function module to be used ?
    Message was edited by:
            Mahesh Sahu

    See the answer in your previous thread and close this thread. why do you want to have many threads for one question.

  • Updating internal table with CSV file

    I have a flat file as below:
    aaaa, bbbb, asdc, dfgfhg, sdfsg, sdf, sdf, sdf, dfg, sdf, sgf, drgftfgh, sgf, drgtf, swftgd, sgf,
    'sjhdfjhf','2003-10-11 07:52:37','167','alkjd',NULL,NULL,NULL,NULL,NULL,'MX1',NULL,NULL,'dkjffdj ,',NULL,NULL,NULL,'1',NULL,NULL,'AR, dfkj ',
    Where we can see it is separated by commas.I want to upload this one into onr internal table.I used GUI_UPLOAD and gave the logic as folows:
    TYPES: BEGIN OF ttab,
    rec(1000) TYPE c,
    END OF ttab.
    TYPES: BEGIN OF tdat,
    aaaa type char10
    bbbb type char10,
    asdc  type char10,
    dfgfhg  type char10,
    sdfsg  type char10,
    sdf  type char10,
    sdf  type char10,
    sdf  type char10,
    dfg   type char10,
    sdf    type char10,
    sgf  type char10,
    drgftfgh  type char10,
    sgf  type char10,
    drgtf  type char10,
    swftgd  type char10,
    sgf  type char10,
    END OF tdat.
    DATA: itab TYPE TABLE OF ttab WITH HEADER LINE.
    DATA: idat TYPE TABLE OF tdat WITH HEADER LINE.
    DATA: file_str TYPE string.
    PARAMETERS: p_file TYPE localfile.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
    static = 'X'
    CHANGING
    file_name = p_file.
    START-OF-SELECTION.
    file_str = p_file.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = file_str
    TABLES
    data_tab = itab
    EXCEPTIONS
    file_open_error = 1
    file_read_error = 2
    no_batch = 3
    gui_refuse_filetransfer = 4
    invalid_type = 5
    no_authority = 6
    unknown_error = 7
    bad_data_format = 8
    header_not_allowed = 9
    separator_not_allowed = 10
    header_too_long = 11
    unknown_dp_error = 12
    access_denied = 13
    dp_out_of_memory = 14
    disk_full = 15
    dp_timeout = 16
    OTHERS = 17.
    LOOP AT itab.
    CLEAR idat.
    SPLIT itab-rec AT ',' INTO idat-aaaa
    idat-bbbb ,
    idat-asdc  ,
    idat-dfgfhg  ,
    idat-sdfsg  ,
    idat-sdf  ,
    idat-sdf  ,
    idat-sdf  ,
    idat-dfg   ,
    idat-sdf    ,
    idat-sgf  ,
    idat-drgftfgh  ,
    idat-sgf  ,
    idat-drgtf  ,
    idat-swftgd  ,
    idat-sgf  ,
    APPEND idat.
    ENDLOOP.
    Now the issue is when I use the statement SPLIT itab-rec AT ',' this is not updating the table idat properly.Because the flat file contains the value as 'dkjffdj ,', too.
    Can anyone give me some solution to update the internal table.

    hI
    or you delete ' from csv file before uploading it or after uploading it, in this last case u can use statament replace:
    REPLACE ''' WITH SPACE INTO ITAB-FIELD.
    Max

  • To populate dynamically created int table with data from other table

    Hi everybody,
    I have already created an internal table dynamically, but now want to populate it with data from another IT depending on the plant name.
    My dynamic int table contains fields with plant name like '8001' ,'8002' and so on.
    no I want to read data from the other table and depending on bwkey which contains similar data like plant name , want to append to this new dynamic int table through read key statement.
    I cannot reference the field name hard coded as it does not allow field symbol reference to be hard coded.
    Pls help.

    Hi,
    Check the code below:
    REPORT  ztestdyn.
    TYPE-POOLS : slis.
    TABLES: yyle0003.
    DATA:
      g_exit    TYPE c,
      g_save    VALUE 'A',               "For parameter I_SAVE
      g_repid   LIKE sy-repid,           "For program name
      g_variant TYPE disvariant.         "For parameter IS_VARIANT
    *Tables
      DATA: d_ref TYPE REF TO data,
            d_ref1 TYPE REF TO data,
            i_alv_cat1 TYPE TABLE OF lvc_s_fcat,
            ls_alv_cat1 LIKE LINE OF i_alv_cat1.
      DATA: BEGIN OF total_tab OCCURS 0 ,
            tknum TYPE yyle0003-tknum,
            quantity TYPE p,  "yyle0003-QUANTITY,
            END OF total_tab.
      DATA: BEGIN OF g_scandata_tab OCCURS 0.
              INCLUDE STRUCTURE yyle0003.
      DATA: END OF g_scandata_tab.
      DATA: g_yyle0003_tab LIKE yyle0003 OCCURS 0 WITH HEADER LINE.
      DATA: g_itab1 TYPE TABLE OF yyle0003.
      DATA: wa_itab1 LIKE g_scandata_tab.
      TYPES: BEGIN OF itab2,
             tknum TYPE yyle0003-tknum,
             vhilm TYPE yyle0003-vhilm,
             quantity TYPE p,
             END OF itab2.
      DATA: g_itab3 TYPE TABLE OF itab2.
      DATA: wa_itab3 TYPE itab2.
      DATA: g_itab5 TYPE TABLE OF itab2.
      DATA: wa_itab5 TYPE itab2.
      DATA: g_itab4 TYPE TABLE OF itab2.
      DATA: wa_itab4 TYPE itab2.
      DATA: gv_wa TYPE REF TO data.
      DATA : wa_tab TYPE itab2.
      DATA: BEGIN OF itab6 OCCURS 0,
             vhilm TYPE yyle0003-vhilm,
             quantity TYPE p,
             END OF itab6.
    ******************Start of Internal Table Definition *******************
      DATA:
            g_custom_container_0100 TYPE REF TO cl_gui_custom_container,
            g_alv_grid_0100    TYPE REF TO cl_gui_alv_grid,
            g_container_0100   TYPE scrfname VALUE 'LIST',
            g_mylayout         TYPE lvc_s_layo,
            ok_code            LIKE sy-ucomm.
      FIELD-SYMBOLS :<f_fs> TYPE table,
                     <f_fs11> TYPE table,
                     <f_fs1> TYPE table,
                     <f_fs3> TYPE ANY,
                     <f_fs4> TYPE ANY,
                     <f_field> TYPE ANY,
                     <f_fs5> TYPE ANY.
      FIELD-SYMBOLS: <fs_wa> TYPE ANY.
      DATA: l_var TYPE i,
            l_i   TYPE i.
      DATA: l_var1 TYPE char20,
            l_var2 TYPE char20.
    DATA: l_TOTAL TYPE I,
          L_FILL TYPE i,
          L_TOT  TYPE I.
    DATA: l_int TYPE i,
           l_sum TYPE i.
    FIELD-SYMBOLS: <f_fs2> TYPE  itab2, "
                     <f_fs6> TYPE ANY,
                     <f_fs7> TYPE ANY.
      DATA: l_var3 TYPE char15.
      DATA: l_quant TYPE p.
    FIELD-SYMBOLS: <f_fs8> LIKE itab6, "
                     <f_fs9> TYPE ANY,
                     <f_fs10> TYPE ANY.
    FIELD-SYMBOLS : <f_fs12> TYPE ANY,
                      <f_fs13> TYPE ANY.
      SORT g_scandata_tab BY tknum vhilm.
      LOOP AT g_scandata_tab INTO wa_itab1.
        MOVE-CORRESPONDING wa_itab1 TO wa_itab3.
        APPEND wa_itab3 TO g_itab3.
      ENDLOOP.
      LOOP AT g_itab3 INTO wa_itab3.
        COLLECT wa_itab3 INTO g_itab4.
      ENDLOOP.
      LOOP AT g_itab4 INTO wa_itab4.
        MOVE-CORRESPONDING wa_itab4 TO wa_itab5.
        MOVE-CORRESPONDING wa_itab4 TO itab6.
        APPEND wa_itab5 TO g_itab5.
        COLLECT itab6.
      ENDLOOP.
      CLEAR wa_itab3.
      SORT g_itab4 BY tknum vhilm.
      DELETE ADJACENT DUPLICATES FROM g_itab4 COMPARING vhilm.
      DESCRIBE TABLE g_itab4 LINES l_var.
      l_i = '2'.
      ls_alv_cat1-fieldname = 'TKNUM'.
      ls_alv_cat1-col_pos = 1.
      ls_alv_cat1-coltext ='ShipmentNo.'.
      APPEND ls_alv_cat1 TO i_alv_cat1.
      DATA: l_var4(10) TYPE c,
            l_var5(10) TYPE c,
            l_fieldname(20) TYPE c..
      LOOP AT g_itab4 INTO wa_itab4.
        IF l_var >= 1.
          CONDENSE wa_itab4-vhilm NO-GAPS.
          ls_alv_cat1-fieldname = wa_itab4-vhilm. "l_fieldname.
          ls_alv_cat1-col_pos = l_i.
          ls_alv_cat1-coltext = wa_itab4-vhilm.
          ls_alv_cat1-do_sum  ='X'.
          APPEND ls_alv_cat1 TO i_alv_cat1.
          CLEAR : ls_alv_cat1, l_fieldname.
          l_i = l_i + 1.
        ENDIF.
        AT LAST.
          ls_alv_cat1-fieldname = 'TOTAL'. "l_fieldname.
          ls_alv_cat1-col_pos = l_i.
          ls_alv_cat1-coltext = 'TOTAL'.
          ls_alv_cat1-do_sum  ='X'.
          APPEND ls_alv_cat1 TO i_alv_cat1.
          CLEAR : ls_alv_cat1, l_fieldname.
        ENDAT.
        SORT i_alv_cat1 BY fieldname.
        DELETE ADJACENT DUPLICATES FROM i_alv_cat1.
      ENDLOOP.
      SORT i_alv_cat1 BY col_pos.
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = i_alv_cat1
        IMPORTING
          ep_table = d_ref.
      ASSIGN d_ref->* TO <f_fs>.
      CREATE DATA gv_wa LIKE LINE OF <f_fs>.
      ASSIGN gv_wa->* TO <fs_wa>.
      DELETE ADJACENT DUPLICATES FROM <f_fs> COMPARING ALL FIELDS.
        LOOP AT itab6.
        CLEAR wa_itab5.
        wa_itab5-tknum = 'Total'.
        MOVE-CORRESPONDING itab6 TO wa_itab5.
        APPEND wa_itab5 TO g_itab5.
        CLEAR wa_itab5.
      ENDLOOP.
         DESCRIBE TABLE g_itab5 LINES L_TOT.
           LOOP AT TOTAL_TAB.
          L_TOTAL = L_TOTAL + total_tab-quantity.
         ENDLOOP.
      LOOP AT g_final ASSIGNING <f_fs2>.
        ASSIGN COMPONENT 'TKNUM' OF STRUCTURE <f_fs2> TO <f_fs6>.
        ASSIGN COMPONENT 'TKNUM' OF STRUCTURE <fs_wa> TO <f_fs7>.
        <f_fs7> = <f_fs6>.
        CONDENSE <f_fs2>-vhilm NO-GAPS.
        ASSIGN COMPONENT 'VHILM' OF STRUCTURE <f_fs2> TO <f_fs3>.
        ASSIGN COMPONENT 3 OF STRUCTURE <f_fs2> TO <f_fs4>.
        MOVE <f_fs3> TO l_var1.
        ASSIGN COMPONENT l_var1 OF STRUCTURE <fs_wa> TO <f_fs5>.
        <f_fs5> =  <f_fs4>.
        CLEAR total_tab-quantity.
        READ TABLE total_tab WITH KEY tknum = <f_fs6>.
        IF sy-subrc = 0.
          ASSIGN total_tab-quantity TO <f_fs12>.
          ASSIGN COMPONENT 'TOTAL' OF STRUCTURE <fs_wa> TO <f_fs13>.
          <f_fs13> = <f_fs12>.
        ENDIF.
        L_FILL = L_FILL + 1.
        IF L_FILL = L_TOT.
         ASSIGN L_TOTAL TO <f_fs12>.
          ASSIGN COMPONENT 'TOTAL' OF STRUCTURE <fs_wa> TO <f_fs13>.
          <f_fs13> = <f_fs12>.
        ENDIF.
        AT END OF <f_fs2>-tknum.
          APPEND <fs_wa> TO <f_fs>.
          CLEAR  <fs_wa>.
        ENDAT.
      ENDLOOP.
      CLEAR: <f_fs6>,
              <f_fs7>.
      CLEAR <fs_wa>.
    CALL SCREEN 0100.
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'ZVKS'.
      SET TITLEBAR 'ZVKS'.
      CHECK sy-ucomm IS INITIAL.
      SORT g_scandata_tab BY tknum vhilm.
      CREATE OBJECT g_custom_container_0100
             EXPORTING container_name = g_container_0100
             EXCEPTIONS
               cntl_error = 1
               cntl_system_error = 2
               create_error = 3
               lifetime_error = 4
               lifetime_dynpro_dynpro_link = 5.
      CREATE OBJECT g_alv_grid_0100
             EXPORTING i_parent = g_custom_container_0100.
      g_mylayout-grid_title = 'Display Scanning data'.
      CALL METHOD g_alv_grid_0100->set_table_for_first_display
        CHANGING
          it_outtab                     = <f_fs>
          it_fieldcatalog               = i_alv_cat1
                    EXCEPTIONS
                      invalid_parameter_combination = 1
                      program_error                 = 2
                      too_many_lines                = 3
                      OTHERS                        = 4.
      IF sy-subrc <> 0.
                  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    Regards
    Kannaiah

  • Uploading data from excel file to a dynamically created internal table

    Hi,
    I have a requirement where i have to upload data from an excel file into a database table. I would be able to determine the structure of the table only at runtime based on the user input.. so i have created an internal table dynamically.
    Could you please tell me if its possible to upload data from an excel file to the dynamically created internal table using any function modules?
    I thought of doing this by declaring a generic internal table of one field and then uploading the *.csv file into it and then splitting it based on "," and then assigning it to the field symbol referencing the internal table.. but my file length exceeds 132 characters and i'm only able to get data of lenght 132 char's in my internal table ( generic one).
    Could anyone please show me a way around this.
    Thanks in advance,
    Harsha

    Sure, check this out.
    report zrich_0002.
    type-pools: slis.
    field-symbols: <dyn_table> type standard table,
                   <dyn_wa>,
                   <dyn_field>.
    data: it_fldcat type lvc_t_fcat,
          wa_it_fldcat type lvc_s_fcat.
    type-pools : abap.
    data: new_table type ref to data,
          new_line  type ref to data.
    data: iflat type table of string.
    data: xflat type string.
      data: irec type table of string with header line.
      data: tabix type sy-tabix.
    data: file type string.
    selection-screen begin of block b1 with frame title text .
    parameters: p_file type  rlgrap-filename default 'c:Test.csv'.
    parameters: p_flds type i.
    selection-screen end of block b1.
    start-of-selection.
    * Add X number of fields to the dynamic itab cataelog
      do p_flds times.
        clear wa_it_fldcat.
        wa_it_fldcat-fieldname = sy-index.
        wa_it_fldcat-datatype = 'C'.
        wa_it_fldcat-inttype = 'C'.
        wa_it_fldcat-intlen = 10.
        append wa_it_fldcat to it_fldcat .
      enddo.
    * Create dynamic internal table and assign to FS
      call method cl_alv_table_create=>create_dynamic_table
                   exporting
                      it_fieldcatalog = it_fldcat
                   importing
                      ep_table        = new_table.
      assign new_table->* to <dyn_table>.
    * Create dynamic work area and assign to FS
      create data new_line like line of <dyn_table>.
      assign new_line->* to <dyn_wa>.
      file = p_file.
      call method cl_gui_frontend_services=>gui_upload
        exporting
          filename                = file
        changing
          data_tab                = iflat
        exceptions
          file_open_error         = 1
          file_read_error         = 2
          no_batch                = 3
          gui_refuse_filetransfer = 4
          invalid_type            = 5
          no_authority            = 6
          unknown_error           = 7
          bad_data_format         = 8
          header_not_allowed      = 9
          separator_not_allowed   = 10
          header_too_long         = 11
          unknown_dp_error        = 12
          access_denied           = 13
          dp_out_of_memory        = 14
          disk_full               = 15
          dp_timeout              = 16
          others                  = 17.
      loop at iflat into xflat.
        clear irec. refresh irec.
        split xflat at ',' into table irec.
        loop at irec.
          tabix = sy-tabix.
          assign component tabix of structure <dyn_wa> to <dyn_field>.
          <dyn_field> = irec.
        endloop.
        append <dyn_wa> to <dyn_table>.
      endloop.
    * Write out data from table.
      loop at <dyn_table> into <dyn_wa>.
        do.
          assign component  sy-index  of structure <dyn_wa> to <dyn_field>.
          if sy-subrc <> 0.
            exit.
          endif.
          if sy-index = 1.
            write:/ <dyn_field>.
          else.
            write: <dyn_field>.
          endif.
        enddo.
      endloop.
    Regards,
    Rich Heilman

  • Upload text file to oracle table with checking and aggregation

    Hi Friends,
    I am new to ODI.  I have encountered a problem which is specific to ODI 11G (11.1.1.6.3) to upload text file to oracle table with checking and aggregation.  Would you please teach me how to implement the following requirement in ODI 11G?
    Input text file a:
    staffCode, staffCat, status, data
    input text file b:
    staffCodeStart, staffCodeEnd, staffCat
    temp output oracle table c:
    staffCat, data
    output oracle table d:
    staffCat, data
    order:
    a.staffCode, a.staffCat, a.status
    filter:
    a.status = ‘active’
    join:
    a left outerjoin b on a.staffCode between b.staffCodeStart and b.staffCodeEnd
    insert temp table c:
    c.staffCat = if b.staffCat is not null then b.staffCat else a.staffCat
    c.data = a.data
    insert table d:
    if c.staffCat between 99 and 1000 then d.staffCat = c.staffCat, d.data = sum(c.data)
    else d.staffCat = c.staffCat, d.data = LAST(c.data)
    Any help on fixing this is highly appreciated. Thanks!!
    Thanks,
    Chris

    Dear Santy,
    Many thanks for your prompt reply.  May I have more information about the LAST or SUM step?
    I was successful to create and run the following interfaces p and q
    1. Drag text file a to a newly created interface panel p
    2. Filter text file a : a.status = ‘active’
    3. Lookup text file a to text file b : a.staffCode between b.staffCodeStart and b.staffCodeEnd
    4. Drag oracle temp table c to interface panel p
    5. Set c.staffCat : CASE WHEN b.staffCat IS NULL THEN a.staffCat ELSE b.staffCat END
    6. Set c.data : a.data
    7. Drag oracle temp table c to a newly created interface panel q
    8. Drag oracle table d to interface panel q
    9. Set UK to d.staffCat
    10. Set Distinct Rows to table d
    11. Set d.staffCat = c.staffCat
    12. Set d.data = SUM(c.data)
    However, the interface q should be more than that:
    If c.staffCat is between 99 and 1000, then d.data = the last record c.data; else d.data = sum(c.data)
    Would you please teach me how to do the LAST or SUM steps?  Moreover, can interface p and interface q be combined to one interface and do not use the temp table c?  Millions thanks!
    Regards,
    Chris

  • How to create a table with datatype blob and insert a pdf file (ravi)

    how to create a table with datatype blob and insert a pdf file,
    give me the explain asap
    1.create the table?
    2.insert the pdffiles into tables?
    3.how to view the files?
    Thanks & Regards
    ravikumar.k
    Edited by: 895044 on Dec 5, 2011 2:55 AM

    895044 wrote:
    how to create a table with datatype blob and insert a pdf file,
    give me the explain asapPerhaps you should read...
    {message:id=9360002}
    especially point 2.
    We're not just sitting here waiting to answer your question as quickly as possible for you.

  • Uploading a file (.doc, .xls, .txt) into an Oracle table with BLOB column

    Hello All :
    I have been trying to figure out for a simple code I can use in my JSP to upload a file (of any format) into an Oracle table with a BLOB column type. I have gone through a lot of existing forums but couldnot find a simple code (that doesnot use Servlet, for eg.) to implement this piece.
    Thanks a lot for your help !!

    Hi.
    First of all to put a file into Oracle you need to get the array of bytes byte[] for that file. For this use for example FileInputStream.
    After you get the byte array try to use this code:
            try {
                Connection conn = myGetDBConnection();
                PreparedStatement pstmt = conn.prepareStatement("INSERT INTO table1 (content) VALUES(?)");
                byte[] content = myGetFileAsBytes();
                if (content != null) {
                    pstmt.setBinaryStream(0, new ByteArrayInputStream(content), content.length);
                pstmt.close();
                conn.close();
            } catch (Exception ex) {
                ex.printStackTrace();
            }or instead of using ByteArrayInputStream try pstmt.setBinaryStream(0, new FileInputStream(yourFile), getFileSize());Hope this will help...
    regards, Victor Letunovsky

  • Download int table into csv file with each column in separate column in csv

    Hi All,
    I want to download the data in internal table to CSV file. but each column in the table should come as separate column in csv format.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          FILENAME                = GD_FILE
          FILETYPE                = 'ASC'
          WRITE_FIELD_SEPARATOR   = 'X'
        tables
          DATA_TAB                = I_LINES_NEW
        EXCEPTIONS
          FILE_OPEN_ERROR         = 1
          FILE_READ_ERROR         = 2
          NO_BATCH                = 3
          GUI_REFUSE_FILETRANSFER = 4
          INVALID_TYPE            = 5
          NO_AUTHORITY            = 6
          UNKNOWN_ERROR           = 7
          BAD_DATA_FORMAT         = 8
          HEADER_NOT_ALLOWED      = 9
          SEPARATOR_NOT_ALLOWED   = 10
          HEADER_TOO_LONG         = 11
          UNKNOWN_DP_ERROR        = 12
          ACCESS_DENIED           = 13
          DP_OUT_OF_MEMORY        = 14
          DISK_FULL               = 15
          DP_TIMEOUT              = 16
          OTHERS                  = 17.
      IF SY-SUBRC NE 0.
        WRITE: 'Error ', SY-SUBRC, 'returned from GUI_DOWNLOAD SAP OUTBOUND'.
        SKIP.
      ENDIF.
    with the above values passd , I am getting csv file but all the columns in one column separated by some square symbol.
    How to separate them into different columns.
    Thanks in advance
    rgds,
    Madhuri

    Below example might help you understand on dowloading CSV file:
    TYPE-POOLS: truxs.
    DATA: i_t001 TYPE STANDARD TABLE OF t001,
          i_data TYPE truxs_t_text_data.
    SELECT * FROM t001 INTO TABLE i_t001 UP TO 20 ROWS.
    CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
      EXPORTING
        i_field_seperator          = ','
    *   I_LINE_HEADER              =
    *   I_FILENAME                 =
    *   I_APPL_KEEP                = ' '
      TABLES
        i_tab_sap_data             = i_t001
    CHANGING
       i_tab_converted_data       = i_data
    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.
    DATA: file TYPE string VALUE 'C:\testing.csv'.
    CALL METHOD cl_gui_frontend_services=>gui_download
      EXPORTING
        filename                = file
      CHANGING
        data_tab                = i_data[]
      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
        not_supported_by_gui    = 22
        error_no_gui            = 23
        OTHERS                  = 24.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Regards
    Eswar

  • Send mails with csv file as an attachment through oracle(SQL SCripts / Stor

    Hello Everybody,
    I have recently come across a requirement in which I am supposed to send mails with csv file as an attachment through oracle(SQL SCripts / Stored Procedure) .
    The contents of the csv file are to be retreived from the Database as well as the content of the mail and to whom it needs to be sent has also to be picked up from the database.
    Can somebody suggest me with a suitable code for the same?
    Would be of great help..!!
    Thanks & Regards,
    - VR
    Edited by: user646716 on Dec 18, 2009 10:44 AM

    read below links
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:255615160805
    http://www.orafaq.com/wiki/Send_mail_from_PL/SQL#Send_mail_with_UTL_TCP_-withattachments
    How to send csv file as an attachment

  • How to create a table with events in smartforms?

    How to create a table with events view in smartforms?
    It doesn't like general table with header, main area and footer.
    for example:
    in smartforms: LE_SHP_DELNOTE
    table name is TABLEITEM(Delivery items table)

    Vel wrote:
    I am creating XML file using DBMS_XMLGEN package. This XML file will contain data from two different database tables. So I am creating temporary table in the PL/SQL procedure to have the data from these different tables in a single temporary table.
    Please find the below Dynamic SQL statements that i'm using for create the temp table and inserting the data into it.
    Before insert the V_NAME filed, i will be appending a VARCHAR field to the original data.
    EXECUTE IMMEDIATE 'CREATE TABLE TEMP_TABLE (UNIQUE_KEY NUMBER , FILE_NAME VARCHAR2(1000), LAST_DATE DATE)';
    EXECUTE IMMEDIATE 'INSERT INTO TEMP_TABLE values (SEQUENCE.nextval,:1,:2)' USING V_NAME,vLastDate;What exactly i need is to eliminate the INSERT portion of it,Since i have to insert more 90,000 rows into it. Is there way to have the temp table created with data in it along with the sequence value as well.
    I'm using Oracle 10.2.0.4 version.
    Edited by: 903948 on Dec 22, 2011 10:58 PMWhat you need to do to eliminate the INSERT statement is to -- as already suggested by others - eliminate the temporary table. You don't need it. It is just necessary overhead. Please explain why you (apparently) believe that the suggestion of a view will not meet your requirements.

  • Jython error while updating a oracle table based on file count

    Hi,
    i have jython procedure for counting counting records in a flat file
    Here is the code(took from odiexperts) modified and am getting errors, somebody take a look and let me know what is the sql exception in this code
    COMMAND on target: Jython
    Command on source : Oracle --and specified the logical schema
    Without connecting to the database using the jdbc connection i can see the output successfully, but i want to update the oracle table with count. any help is greatly appreciated
    ---------------------------------Error-----------------------------
    org.apache.bsf.BSFException: exception from Jython:
    Traceback (innermost last):
    File "<string>", line 45, in ?
    java.sql.SQLException: ORA-00936: missing expression
    ---------------------------------------Code--------------------------------------------------
    import java.sql.Connection
    import java.sql.Statement
    import java.sql.DriverManager
    import java.sql.ResultSet
    import java.sql.ResultSetMetaData
    import os
    import string
    import java.sql as sql
    import java.lang as lang
    import re
    filesrc = open('c:\mm\xyz.csv','r')
    first=filesrc.readline()
    lines = 0
    while first:
    #get the no of lines in the file
    lines += 1
    first=filesrc.readline()
    #print lines
    ## THE ABOVE PART OF THE PROGRAM IS TO COUNT THE NUMBER OF LINES
    ## AND STORE IT INTO THE VARIABLE `LINES `
    def intWithCommas(x):
    if type(x) not in [type(0), type(0L)]:
    raise TypeError("Parameter must be an integer.")
    if x < 0:
    return '-' + intWithCommas(-x)
    result = ''
    while x >= 1000:
    x, r = divmod(x, 1000)
    result = ",%03d%s" % (r, result)
    return "%d%s" % (x, result)
    ## THE ABOVE PROGRAM IS TO DISPLAY THE NUMBERS
    sourceConnection = odiRef.getJDBCConnection("SRC")
    sqlstring = sourceConnection.createStatement()
    sqlstmt="update tab1 set tot_coll_amt = to_number( "#lines ") where load_audit_key=418507"
    sqlstring.executeQuery(sqlstmt)
    sourceConnection.close()
    s0=' \n\nThe Number of Lines in the File are ->> '
    s1=str(intWithCommas(lines))
    s2=' \n\nand the First Line of the File is ->> '
    filesrc.seek(0)
    s3=str(filesrc.readline())
    final=s0 + s1 + s2 + s3
    filesrc.close()
    raise final

    i changed as you adviced ankit
    am getting the following error now
    org.apache.bsf.BSFException: exception from Jython:
    Traceback (innermost last):
    File "<string>", line 37, in ?
    java.sql.SQLException: ORA-00911: invalid character
    here is the modified code
    sourceConnection = odiRef.getJDBCConnection("SRC")
    sqlstring = sourceConnection.createStatement()
    sqlstmt="update tab1 set tot_coll_amt = to_number('#lines') where load_audit_key=418507;"
    result=sqlstring.executeUpdate(sqlstmt)
    sourceConnection.close()
    Any ideas
    Edited by: Sunny on Dec 3, 2010 1:04 PM

  • Working with CSV files in Numbers 09

    I'm able to import CSV files into Numbers '09 but the CSV file has multiple categories in each column. I want to SUM just one section and put the result in a summary chart but don't how to limit the SUM to just one of the groups in the column. The number of the rows is constantly changing with each import but the data that I want to use is always in column G. I would like to be able to just import the updated CSV file without having to manual select the cells I want to use each time. Any ideas? Thanks.

    If you took care to use the Numbers's vocabulary, things would be easier.
    You import datas upon vehicle 1 in table 1, not in sheet 1.
    If you really use the import feature, you will get a new table name each time so the formula would be different each time.
    The good practice would be to create a table with 11 columns for each vehicle.
    In every cell of column K (the 11th one), the formula would be:
    =IF(ISERROR(VLOOKUP("Total Price",$G$1:G2,1,0)),"",IF(OR(G="Total Price",ISBLANK(G),NOT(ISERROR(VLOOKUP("type",$G$1:G2,1,0)))),"",1))
    Then, import the CSV,
    copy the newly created table's contents and paste it in the table dedicated to the vehicle.
    Delete the table created during the import process.
    Doing that,
    the cell dedicated to vehicle 1 in "Vehicle Expense Summary" would be :
    =SUMIF(vehicle1 :: K,">0",vehicle1 :: G)
    the cell dedicated to vehicle 2 in "Vehicle Expense Summary" would be :
    =SUMIF(vehicle2 :: K,">0",vehicle2 :: G)
    Yvan KOENIG (VALLAURIS, France) mercredi 3 mars 2010 19:04:30

  • Updating an oracle table with data from an xml string

    Hi - I need help with the following problem:
    We have a table in the database with a field of xml type. We are going to take each string that gets inserted into the xml type field in the 'xml table' and parse the data into another oracle table with corresponding fields for every element.
    once the record gets inserted into the 'real table' the user might want to update this record they will then insert another record into the 'xml table' indicating an update(with a flag) and then we need to update the 'real table' with the updated values that have been sent in.
    The problem that I am having is that I do not know how to create this update statement that will tell me which fields of the table need to be updated.(only the fields that need to be updated will be in the xml string in the 'xml table').
    Please help me with this - ASAP!

    Are you wanting to upload the file through an Oracle Form or just upload a file? If it isn't via forms, then you should probably post your question here: {forum:id=732}
    You also should post the version of Forms, Database, etc...
    As far as uploading files via a text file, I personally like to use Oracle External Tables even in Forms. You can Google that and there is plenty of information. If you search this forum, then you will see lots of people use UTL_FILE in forms, but you can Google that also for more information.

  • How to create a table in the file using java code.?

    HI,
    I should export the data from the view objects to a word document. I have done that but I should
    display the data in the form of a table.
    Kindly come up with the necessary information on how to create a table in the file using java.
    Thanks,
    Phani

    Hi, Thank you for responding to my query.
    The below are the details of my code.
    DCBindingContainer dcBindings =
    (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    DCIteratorBinding StudentDetailsContent =
    (DCIteratorBinding)dcBindings.get("StudentView1Iterator");
    OutputStreamWriter w = new OutputStreamWriter(outputStream, "UTF-8");
    Row currentRow =
    StudentDetailsContent.getRowSetIterator().first();
    Object a[]= currentRow.getAttributeValues();
    int i;
    for(i=0 ;i<=a.length;i++){
    w.write(a.toString());
    w.write(" ");
    w.flush();
    I am usning this coding to achieve the task of exporting data to file.
    I need to display this information in the table that is where I need help from you people.
    Thanks,

Maybe you are looking for

  • CapacityPolicy: Handling "cache is full"

    I am working with Java Object Cache (in 10.1.3 dp4) and am having some problems with managing the size of the cache. In my javacache.xml file, I set the max number of objects to some number (2000). Eventually, the size of the cache grows that big (we

  • Commited changes to cvs are not seen  on incomming changes in Jdeveloper

    Hi, We are devlopping application on JDeveloper 10.1.3.4. We are using tortories cvs from jdeveloper. We had no problems for a while, everything worked fine(incoming changes and outgoing changes were properly seen on pending changes tab in jdev). Bef

  • Maximum RAM for HP dv7 3150ed

    Hi there, I am trying to find the max. RAM my notebook can handle, but it´s quite unclear. Is it now 8 or 16GB ? I have a HP dv7 3150ed Greetings from Holland, Martin This question was solved. View Solution.

  • Tethering option in Lightroom 3

    I am using Lightroom Beta 3 that expires at the end of this month and I'm excited about the new tether feature that is now part of LR3. The Beta version doesn't support saving to my Nikon D700's CF card, but will save to the hard drive. Can anyone te

  • Preflight limitation 255 files converting PDFs to PDF/a 1b (sRGB) – is it a glitch?

    Hi, I am using Acrobat x Pro 10.1.4 and I am trying to convert 1000 PDF files to PDF/A 1b using Preflight in the batch mode. From my testing it seems that Preflight would only process first 255 files in that folder and that's it. I have noticed that