PROCESS TO INSERT FILE INTO CUSTOM TABLE

Hello - grateful if anyone can assist.
I have followed the official guide notes but am unable to insert a line with blob file into my custom table (APEX_AM_LEASES)
Error message is as follows:
ORA-06550: line 2, column 13: PL/SQL: ORA-00913: too many values ORA-06550: line 2, column 1: PL/SQL: SQL Statement ignored.
My Process code is as follows:
IF ( :P6_DOC_UPLOADED is not null ) THEN
INSERT INTO APEX_AM_LEASES(id, CLIENT_REF, CLIENT_NAME, PROPERTY_REF, PROPERTY_NAME, TENANT_REF, TENANT_NAME, DOC_TYPE_NO, DOC_TYPE, URL, BLOB_CONTENT, MIME_TYPE)
SELECT ID,:P6_DOC_UPLOADED,:P6_CLIENT_REF, :P6_CLIENT_NAME, :P6_PROPERTY_REF, :P6_PROPERTY_NAME, :P6_TENANT_REF, :P6_TENANT_NAME, :P6_DOC_TYPE_NO, :P6_DOC_TYPE, :P6_URL, blob_content,mime_type
FROM APEX_APPLICATION_FILES
WHERE name = :P6_DOC_UPLOADED;
DELETE from APEX_APPLICATION_FILES WHERE name = :P6_DOC_UPLOADED;
END IF;

Hi srikavi - thank you for your quick response. I think I get it however I have amended and am getting a new error:
ORA-06550: line 2, column 163: PL/SQL: ORA-00904: "MIME_TYPE": invalid identifier ORA-06550: line 2, column 1: PL/SQL: SQL Statement ignored
IF ( :P6_DOC_UPLOADED is not null ) THEN
INSERT INTO APEX_AM_LEASES(DOC_UPLOADED, CLIENT_REF, CLIENT_NAME, PROPERTY_REF, PROPERTY_NAME, TENANT_REF, TENANT_NAME, DOC_TYPE_NO, DOC_TYPE, URL, BLOB_CONTENT, MIME_TYPE)
SELECT :P6_DOC_UPLOADED, :P6_CLIENT_REF, :P6_CLIENT_NAME, :P6_PROPERTY_REF, :P6_PROPERTY_NAME, :P6_TENANT_REF, :P6_TENANT_NAME, :P6_DOC_TYPE_NO, :P6_DOC_TYPE, :P6_URL, blob_content, mime_type
FROM APEX_APPLICATION_FILES
WHERE name = :P6_DOC_UPLOADED;
DELETE from APEX_APPLICATION_FILES WHERE name = :P6_DOC_UPLOADED;
END IF;

Similar Messages

  • Uploading the contents of file into  custom table

    Hi ,
    I have a req where in i want to put the contents of the file into the Z table . I have taken a file upload UI element and in that i have taken 4 attributes as file name f, file type ,file size and file contents and binded this file contents to the data property of the UI element. Now with out explicitly defining the fields i want to put all this content of file into the Z table created  for any file created or if i could put the whole text file into that table so that any one could see that file even though its not saved in the desktop for that user.
    Can any one help me out?

    Yes i am converting it inot the lstring using the same FM which you have given. I have to store the total file but the only doubt is like if its a input field how could i save a file form. Can you please check the code i want to save the total file into the table.
    DATA lo_nd_upload TYPE REF TO if_wd_context_node.
        DATA lo_el_upload TYPE REF TO if_wd_context_element.
        data  i_data TYPE STANDARD TABLE OF string.
        DATA ls_upload TYPE wd_this->Element_upload.
        data lv_field type string.
        data lt_file type TABLE OF ZFILE_UPLOAD.
        data ls_file LIKE LINE OF lt_file.
        data l_xstring type xstring.
       data  fields TYPE string_table.
    data l_String type string.
      navigate from <CONTEXT> to <UPLOAD> via lead selection
        lo_nd_upload = wd_context->get_child_node( name = wd_this->wdctx_upload ).
      @TODO handle non existant child
      IF lo_nd_upload IS INITIAL.
      ENDIF.
      get element via lead selection
        lo_el_upload = lo_nd_upload->get_element( ).
      @TODO handle not set lead selection
        IF lo_el_upload IS INITIAL.
        ENDIF.
      get all declared attributes
        lo_el_upload->get_static_attributes(
          IMPORTING
            static_attributes = ls_upload ).
       DATA lv_file_contents TYPE wd_this->Element_upload-file_contents.
    navigate from <CONTEXT> to <UPLOAD> via lead selection
    @TODO handle non existant child
    IF lo_nd_upload IS INITIAL.
    ENDIF.
    get element via lead selection
       lo_el_upload = lo_nd_upload->get_element( ).
    alternative access  via index
    lo_el_upload = lo_nd_upload->get_element( index = 1 ).
    @TODO handle not set lead selection
       IF lo_el_upload IS INITIAL.
       ENDIF.
    get single attribute
       lo_el_upload->get_attribute(
         EXPORTING
           name =  'FILE_CONTENTS'
         IMPORTING
           value = l_xstring ).
    for text file conversion we have to FM
    CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
      EXPORTING
      FROM_CODEPAGE       = '8500'
        IN_XSTRING          = l_xstring
      OUT_LEN             =
    IMPORTING
       OUT_STRING          = l_string.
    SPLIT l_string  AT cl_abap_char_utilities=>newline INTO TABLE i_data.
      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.
    endloop.
    ls_upload will contain all the file details
    ls_file-file_size = xstrlen( ls_upload-file_contents ) * lv_float  .
    ls_file-file_name = ls_upload-file_name.
    ls_file-file_type = ls_upload-file_type.
    ls_file-file_contents = ls_upload-file_contents.
    insert ZFILE_UPLOAD FROM ls_file.
    thanks

  • How to store the flat file data into custom table?

    Hi,
    Iam working on inbound interface.Can any one tell me how to store the flat file data into custom table?what is the procedure?
    Regards,
    Sujan

    Hie
    u can use function
    F4_FILENAME
    to pick the file from front-end or location.
    then use function
    WS_UPLOAD
    to upload into
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'F4_FILENAME'   "Function to pick file
        EXPORTING
          field_name = 'p_file'     "file
        IMPORTING
          file_name  = p_file.     "file
      CALL FUNCTION 'WS_UPLOAD'
       EXPORTING
         filename                       = p_file1
        TABLES
          data_tab                      = it_line
    *then loop at it_line splitting it into the fields of your custom table.
    loop at it_line.
              split itline at ',' into
              itab-name
              itab-surname.
    endloop.
    then u can insert the values into yo table from the itab work area.
    regards
    Isaac Prince

  • R12 - Approach to Insert into custom table after payment is done

    Hi,
    I have a requirement to insert into a custom table after invoice payment in R12. Code units are already in place to load data from ap tables to custom one.
    I have identified 2 ways in which this can be done:
    1. Call from the business event oracle.apps.ap.payment
    2. Call after the program 'Send separate remittance advice' completes, again as a business event after the concurrent program completes i.e. to use 'Request Completed' business event.
    My questions are as below:
    1. Is there any other way in which I can write to a custom table after payment is done
    2. How else can after report trigger be fired for SRA in R12 (without customizing the standard SRA java conc pgm)
    3. When exactly business event 'oracle.apps.ap.payment' will be fired? Will it be fired for all payments irrespective of the way payment is done like thru PPR, payment workbench, etc?
    Please share your thoughts on this.
    Thanks,
    Kavipriya

    in our case, we have created a database trigger on IBY_PAY_INSTRUCTIONS_ALL, to insert the requisite data into custom tables whenever the payment status is "Ready for Printing"

  • How to insert a gif file into a table?

    Hi,
    I need to insert a gif file into a table. Can anyone tell me where I can find the information on how to create this kind of table, how to insert a gif file into a table and how to select?
    Thanks,
    Helen

    Hi Helen,
    You could read about that in the documentation which is available online.
    For a starter: BLOB. And I bet there are many examples to be found on the web.
    Good luck. :)
    Regards,
    Guido

  • Insert data into oracle table from XML file

    I need to insert data into oracle table from XML file
    If anybody handled this type of scenario, Please let me know how to insert data into oracle table from XML file
    Thanks in advance

    The XML DB forum provides the best support for XML topics related to Oracle.
    Here's the FAQ on that forum:
    XML DB FAQ
    where there are plenty of examples of shredding XML into Oracle tables and such like. ;)

  • How  to  insert data into custom database table from an hcsf

    i want to insert data into database table that i have created from an hcsf.
    example :
    say i have created a table in oracle database and i hav created a hcsf file.now i want that when somebody fills in that hcsf and click submit ,i want that entries should be updated in my database table.
    plzzz reply ASAP(it's urgent)

    you'll need a bit of Java code... extract the data during a check-in filter, and insert it into the database.
    check out the "DataAccess" component in the HowToComponents for query-running examples, and the "DynamicPrefix" component for a check-in filter example.
    I have older copies here:
    http://bezzotech.com/library

  • Inserting XML file  into a Table

    Hello,
    Can someone provide me with a sample code to load xml files into a table. Thanks a lot.
    Rajeesh

    Keeping my fingers crossed that this quote from "Building XML Oracle Applications" by Steve Muench (O'Reilly & Associates, 2000, ISBN 1-56592-691-9) falls into the "fair use" category, and that you want it in PL/SQL, here is a procedure:
    PROCEDURE insertXMLFile
    (dir VARCHAR2, file VARCHAR2, name VARCHAR2 := NULL) IS
    theBFile BFILE;
    theCLob CLOB;
    theDocName VARCHAR2(200) := NVL(name,file);
    BEGIN
    -- (1) Insert a new row into xml_documents with an empty CLOB, and
    -- (2) Retrieve the empty CLOB into a variable with RETURNING.INTO
    INSERT INTO stylesheets(docname,sheet) VALUES(theDocName,empty_clob( ))
    RETURNING sheet INTO theCLob;
    -- (3) Get a BFile handle to the external file
    theBFile := BFileName(dir,file);
    -- (4) Open the file
    dbms_lob.fileOpen(theBFile);
    -- (5) Copy the contents of the BFile into the empty CLOB
    dbms_lob.loadFromFile(dest_lob => theCLob, src_lob => theBFile, amount => dbms_lob.getLength(theBFile));
    -- (6) Close the file and commit
    dbms_lob.fileClose(theBFile);
    COMMIT;
    END;

  • How to load a XML file into a table

    Hi,
    I've been working on Oracle for many years but for the first time I was asked to load a XML file into a table.
    As an example, I've found this on the web, but it doesn't work
    Can someone tell me why? I hoped this example could help me.
    the file acct.xml is this:
    <?xml version="1.0"?>
    <ACCOUNT_HEADER_ACK>
    <HEADER>
    <STATUS_CODE>100</STATUS_CODE>
    <STATUS_REMARKS>check</STATUS_REMARKS>
    </HEADER>
    <DETAILS>
    <DETAIL>
    <SEGMENT_NUMBER>2</SEGMENT_NUMBER>
    <REMARKS>rp polytechnic</REMARKS>
    </DETAIL>
    <DETAIL>
    <SEGMENT_NUMBER>3</SEGMENT_NUMBER>
    <REMARKS>rp polytechnic administration</REMARKS>
    </DETAIL>
    <DETAIL>
    <SEGMENT_NUMBER>4</SEGMENT_NUMBER>
    <REMARKS>rp polytechnic finance</REMARKS>
    </DETAIL>
    <DETAIL>
    <SEGMENT_NUMBER>5</SEGMENT_NUMBER>
    <REMARKS>rp polytechnic logistics</REMARKS>
    </DETAIL>
    </DETAILS>
    <HEADER>
    <STATUS_CODE>500</STATUS_CODE>
    <STATUS_REMARKS>process exception</STATUS_REMARKS>
    </HEADER>
    <DETAILS>
    <DETAIL>
    <SEGMENT_NUMBER>20</SEGMENT_NUMBER>
    <REMARKS> base polytechnic</REMARKS>
    </DETAIL>
    <DETAIL>
    <SEGMENT_NUMBER>30</SEGMENT_NUMBER>
    </DETAIL>
    <DETAIL>
    <SEGMENT_NUMBER>40</SEGMENT_NUMBER>
    <REMARKS> base polytechnic finance</REMARKS>
    </DETAIL>
    <DETAIL>
    <SEGMENT_NUMBER>50</SEGMENT_NUMBER>
    <REMARKS> base polytechnic logistics</REMARKS>
    </DETAIL>
    </DETAILS>
    </ACCOUNT_HEADER_ACK>
    For the two tags HEADER and DETAILS I have the table:
    create table xxrp_acct_details(
    status_code number,
    status_remarks varchar2(100),
    segment_number number,
    remarks varchar2(100)
    before I've created a
    create directory test_dir as 'c:\esterno'; -- where I have my acct.xml
    and after, can you give me a script for loading data by using XMLTABLE?
    I've tried this but it doesn't work:
    DECLARE
    acct_doc xmltype := xmltype( bfilename('TEST_DIR','acct.xml'), nls_charset_id('AL32UTF8') );
    BEGIN
    insert into xxrp_acct_details (status_code, status_remarks, segment_number, remarks)
    select x1.status_code,
            x1.status_remarks,
            x2.segment_number,
            x2.remarks
    from xmltable(
      '/ACCOUNT_HEADER_ACK/HEADER'
      passing acct_doc
      columns header_no      for ordinality,
              status_code    number        path 'STATUS_CODE',
              status_remarks varchar2(100) path 'STATUS_REMARKS'
    ) x1,
    xmltable(
      '$d/ACCOUNT_HEADER_ACK/DETAILS[$hn]/DETAIL'
      passing acct_doc as "d",
              x1.header_no as "hn"
      columns segment_number number        path 'SEGMENT_NUMBER',
              remarks        varchar2(100) path 'REMARKS'
    ) x2
    END;
    This should allow me to get something like this:
    select * from xxrp_acct_details;
    Statuscode status remarks segement remarks
    100 check 2 rp polytechnic
    100 check 3 rp polytechnic administration
    100 check 4 rp polytechnic finance
    100 check 5 rp polytechnic logistics
    500 process exception 20 base polytechnic
    500 process exception 30
    500 process exception 40 base polytechnic finance
    500 process exception 50 base polytechnic logistics
    but I get:
    Error report:
    ORA-06550: line 19, column 11:
    PL/SQL: ORA-00932: inconsistent datatypes: expected - got NUMBER
    ORA-06550: line 4, column 2:
    PL/SQL: SQL Statement ignored
    06550. 00000 -  "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    and if I try to change the script without using the column HEADER_NO to keep track of the header rank inside the document:
    DECLARE
    acct_doc xmltype := xmltype( bfilename('TEST_DIR','acct.xml'), nls_charset_id('AL32UTF8') );
    BEGIN
    insert into xxrp_acct_details (status_code, status_remarks, segment_number, remarks)
    select x1.status_code,
            x1.status_remarks,
            x2.segment_number,
            x2.remarks
    from xmltable(
      '/ACCOUNT_HEADER_ACK/HEADER'
      passing acct_doc
      columns status_code    number        path 'STATUS_CODE',
              status_remarks varchar2(100) path 'STATUS_REMARKS'
    ) x1,
    xmltable(
      '/ACCOUNT_HEADER_ACK/DETAILS'
      passing acct_doc
      columns segment_number number        path 'SEGMENT_NUMBER',
              remarks        varchar2(100) path 'REMARKS'
    ) x2
    END;
    I get this message:
    Error report:
    ORA-19114: error during parsing the XQuery expression: 
    ORA-06550: line 1, column 13:
    PLS-00201: identifier 'SYS.DBMS_XQUERYINT' must be declared
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    ORA-06512: at line 4
    19114. 00000 -  "error during parsing the XQuery expression: %s"
    *Cause:    An error occurred during the parsing of the XQuery expression.
    *Action:   Check the detailed error message for the possible causes.
    My oracle version is 10gR2 Express Edition
    I do need a script for loading xml files into a table as soon as possible, Give me please a simple example for understanding and that works on 10gR2 Express Edition
    Thanks in advance!

    The reason your first SQL statement
    select x1.status_code,
            x1.status_remarks,
            x2.segment_number,
            x2.remarks
    from xmltable(
      '/ACCOUNT_HEADER_ACK/HEADER'
      passing acct_doc
      columns header_no      for ordinality,
              status_code    number        path 'STATUS_CODE',
              status_remarks varchar2(100) path 'STATUS_REMARKS'
    ) x1,
    xmltable(
      '$d/ACCOUNT_HEADER_ACK/DETAILS[$hn]/DETAIL'
      passing acct_doc as "d",
              x1.header_no as "hn"
      columns segment_number number        path 'SEGMENT_NUMBER',
              remarks        varchar2(100) path 'REMARKS'
    ) x2
    returns the error you noticed
    PL/SQL: ORA-00932: inconsistent datatypes: expected - got NUMBER
    is because Oracle is expecting XML to be passed in.  At the moment I forget if it requires a certain format or not, but it is simply expecting the value to be wrapped in simple XML.
    Your query actually runs as is on 11.1 as Oracle changed how that functionality worked when 11.1 was released.  Your query runs slowly, but it does run.
    As you are dealing with groups, is there any way the input XML can be modified to be like
    <ACCOUNT_HEADER_ACK>
    <ACCOUNT_GROUP>
    <HEADER>....</HEADER>
    <DETAILS>....</DETAILS>
    </ACCOUNT_GROUP>
      <ACCOUNT_GROUP>
      <HEADER>....</HEADER>
      <DETAILS>....</DETAILS>
      </ACCOUNT_GROUP>
    </ACCOUNT_HEADER_ACK>
    so that it is easier to associate a HEADER/DETAILS combination?  If so, it would make parsing the XML much easier.
    Assuming the answer is no, here is one hack to accomplish your goal
    select x1.status_code,
            x1.status_remarks,
            x3.segment_number,
            x3.remarks
    from xmltable(
      '/ACCOUNT_HEADER_ACK/HEADER'
      passing acct_doc
      columns header_no      for ordinality,
              status_code    number        path 'STATUS_CODE',
              status_remarks varchar2(100) path 'STATUS_REMARKS'
    ) x1,
    xmltable(
      '$d/ACCOUNT_HEADER_ACK/DETAILS'
      passing acct_doc as "d",
      columns detail_no      for ordinality,
              detail_xml     xmltype       path 'DETAIL'
    ) x2,
    xmltable(
      'DETAIL'
      passing x2.detail_xml
      columns segment_number number        path 'SEGMENT_NUMBER',
              remarks        varchar2(100) path 'REMARKS') x3
    WHERE x1.header_no = x2.detail_no;
    This follows the approach you started with.  Table x1 creates a row for each HEADER node and table x2 creates a row for each DETAILS node.  It assumes there is always a one and only one association between the two.  I use table x3, which is joined to x2, to parse the many DETAIL nodes.  The WHERE clause then joins each header row to the corresponding details row and produces the eight rows you are seeking.
    There is another approach that I know of, and that would be using XQuery within the XMLTable.  It should require using only one XMLTable but I would have to spend some time coming up with that solution and I can't recall whether restrictions exist in 10gR2 Express Edition compared to what can run in 10.2 Enterprise Edition for XQuery.

  • Inserting Data into nested table

    I am exploring the differences between OBJECT & RECORD.
    As i am still in process of learning, I found that both are structures which basically groups elements of different datatypes or columns of different datatypes, one is used in SQL and other is used in PL/SQL, please correct me if I am wrong in my understanding.
    Below i am trying to insert data into an table of type object but i am unsuccessful can you please help.
    CREATE OR REPLACE type sam as OBJECT
    v1 NUMBER,
    v2 VARCHAR2(20 CHAR)
    ---Nested Table---
    create or replace type t_sam as table of sam;
    --Inserting data----
    insert into table(t_sam) values(sam(10,'Dsouza'));
    Error Message:
    Error starting at line 22 in command:
    insert into table(t_sam) values(sam(10,'Dsouza'))
    Error at Command Line:22 Column:13
    Error report:
    SQL Error: ORA-00903: invalid table name
    00903. 00000 -  "invalid table name"
    *Cause:   
    *Action:

    Ariean wrote:
    So only purpose of equivalent SQL types concept of nested tables is to use them as one of the data types while defining an actual table?
    Sort of - you can definitely use them for more than just "defining an actual table". (I'm fairly certain you could pass a nested table into a procedure, for example - try it, though - I'm not 100% sure on that - it just "makes sense". If you can define a type, you can use it, pass it around, whatever.).
    Ariean wrote:
    And that nested table could be a record in SQL or an Object in PLSQL or just simple datatype(number,varchar etc)?
    Nested tables are just like any other custom data type. You can create a nested table of other data types. You can create a custom data type of nested tables.
    It could get stupidly .. er, stupid O_0
    CREATE TYPE o_myobj1 AS object ( id1   number, cdate1  date );
    CREATE TYPE t_mytype1 AS table of o_myobj1;
    CREATE TYPE o_myobj2 AS object ( id2   number,  dumb  t_mytype1 );
    CREATE TYPE t_dumber AS table of o_myobj2;
    O_0
    Ok, my brain's starting to hurt - I hope you get the idea
    Ariean wrote:
    Secondly is my understanding correct about OBJECT & RECORD?
    I can't think of any benefit of describing it another way.

  • Error while Inserting data into flow table

    Hi All,
    I am very new to ODI, I am facing lot of problem in my 1st interface. So I have many questions here, please forgive me if it has irritated to you.
    ========================
    I am developing a simple Project to load a data from an input source file (csv) file into a staging table.
    My plan is to achieve this in 3 interfaces:
    1. Interface-1 : Load the data from an input source (csv) file into a staging table (say Stg_1)
    2. Interface-2 : Read the data from the staging table (stg_1) apply the business rules to it and copy the processed records into another staging table (say stg_2)
    3. Interface-3 : Copy the data from staging table (stg_2) into the target table (say Target) in the target database.
    Question-1 : Is this approach correct?
    ========================
    I don't have any key columns in the staging table (stg_1). When I tried to execute the Flow Control of this I got an error:
    Flow Control not possible if no Key is declared in your Target Datastore
    With one of the response (the response was - "FLOW control requires a KEY in the target table") in this Forum I have introduced a column called "Record_ID" and made it a Primary Key column into my staging table (stg_1) and my problem has been resolved.
    Question-2 : Is a Key column compulsary in the target table? I am working in BO Data Integrator, there is no such compulsion ... I am little confused.
    ========================
    Next, I have defined one Project level sequence. I have mapped the newly introduced key column Record_Id (Primary Key) with the Project level sequence. Now I am got another error of "CKM not selected".
    For this, I have inserted "Insert Check (CKM)" knowledge module in my Project. With this the above problem of "CKM not selected" has been resolved.
    Question-3 : When is this CKM knowledge module required?
    ========================
    After this, the flow/interface is failing while loading data into the intermediar ODI created flow table (I$)
    1 - Loading - SS_0 - Drop work table
    2 - Loading - SS_0 - Create work table
    3 - Loading - SS_0 - Load data
    5 - Integration - FTE Actual data to Staging table - Drop flow table
    6 - Integration - FTE Actual data to Staging table - Create flow table I$
    7 - Integration - FTE Actual data to Staging table - Delete target table
    8 - Integration - FTE Actual data to Staging table - Insert flow into I$ table
    The Error is at Step-8 above. When opened the "Execution" tab for this step I found the message - "Missing parameter Project_1.FTE_Actual_Data_seq_NEXTVAL RECORD_ID".
    Question-4 : What/why is this error? Did I made any mistake while creating a sequence?

    Everyone is new and starts somewhere. And the community is there to help you.
    1.) What is the idea of moving data from stg_1 and then to stg_2 ? Do you really need it for any other purpose other than move data from SourceFile to Target DB.
    Otherwise, its simple to move data from SourceFile -> Target Table
    2.) Does your Target table have a Key ?
    3.) CKM (Check KM) is required when you want to do constraint validation (Checking) on your data. You can define constraints (business rules) on the target table and Flow Control will check the data that is flowing from Source File to Target table using the CKM. All the records that donot satisfy the constraint will be added to E$ (Error table) and will not be added to the Target table.
    4.) Try to avoid ODI sequences. They are slow and arent scalable. Try to use Database sequence wherever possible. And use the DB sequence is target mapping as
    <%=odiRef.getObjectName( "L" , "MY_DB_Sequence_Row" , "D" )%>.nextval
    where MY_DB_Sequence_Row is the oracle sequence in the target schema.
    HTH

  • Load CSV file into a table when a button is clicked by the user

    Hello,
    Can anyone please help me out with this issue, I have a form where in a user comes and uploads a CSV file and clicks a button, when the button is clicked - it should load the CSV file data into the database table for the corresponding columns.
    Can anyone please suggest me a possible solution or an approach.
    Thanks,
    Orton
    Edited by: orton607 on May 5, 2010 2:00 PM

    thanks fro replying.
    I have tried your changes but its not working. One more question is that I am having one column which contains commas, when I tried to load the file its failing. I think its the problem with commas. So I have changed the code to use the replace function for that column, then also its not working. Can anyone please suggest a possible approach. Below is my source code for your reference.
    DECLARE
    v_blob_data BLOB;
    v_blob_len NUMBER;
    v_position NUMBER;
    v_raw_chunk RAW(10000);
    v_char CHAR(1);
    c_chunk_len NUMBER := 1;
    v_line VARCHAR2 (32767):= NULL;
    v_data_array wwv_flow_global.vc_arr2;
    v_rows NUMBER;
    v_sr_no NUMBER := 1;
    l_cnt BINARY_INTEGER := 0;
    l_stepid NUMBER := 10;
    BEGIN
    delete from sample_tbl;
    -- Read data from wwv_flow_files</span>
    select blob_content into v_blob_data from wwv_flow_files
    where last_updated = (select max(last_updated) from wwv_flow_files where UPDATED_BY = :APP_USER)
    and id = (select max(id) from wwv_flow_files where updated_by = :APP_USER);
    v_blob_len := dbms_lob.getlength(v_blob_data);
    v_position := 1;
    -- Read and convert binary to char</span>
    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 </span>
    IF v_char = CHR(10) THEN
    -- Convert comma to : to use wwv_flow_utilities </span>
    v_line := REPLACE (v_line, ',', ':');
    -- Convert each column separated by : into array of data </span>
    v_data_array := wwv_flow_utilities.string_to_table (v_line);
    -- Insert data into target table </span>
    EXECUTE IMMEDIATE 'insert into sample_tbl(col1..col12)
    values (:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12)'
    USING
    v_sr_no,
    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),
    REPLACE(v_data_array(9), ':', ','),
    to_date(v_data_array(10),'MM/DD/YYYY'),
    v_data_array(11);
    -- Clear out
    v_line := NULL;
    v_sr_no := v_sr_no + 1;
    l_cnt := l_cnt + SQL%ROWCOUNT;
    END IF;
    END LOOP;
    COMMIT;
    l_stepid := 20;
    IF l_cnt = 0 THEN
    apex_application.g_print_success_message := apex_application.g_print_success_message || ' Please select a file to upload ' ;
    ELSE
    apex_application.g_print_success_message := apex_application.g_print_success_message || 'File uploaded and processed ' || l_cnt || ' record(s) successfully.';
    END IF;
    l_stepid := 30;
    EXCEPTION WHEN OTHERS THEN
    ROLLBACK;
    apex_application.g_print_success_message := apex_application.g_print_success_message || 'Failed to upload the file. '||REGEXP_REPLACE(SQLERRM,'[('')(<)(>)(,)(;)(:)(")('')]{1,}', '') ;
    END;
    Below is the function which I am using to convert hex to decimal
    create or replace function hex_to_decimal( p_hex_str in varchar2 ) return number
    is
    v_dec number;
    v_hex varchar2(16) := '0123456789ABCDEF';
    begin
    v_dec := 0;
    for indx in 1 .. length(p_hex_str)
    loop
    v_dec := v_dec * 16 + instr(v_hex,upper(substr(p_hex_str,indx,1)))-1;
    end loop;
    return v_dec;
    end hex_to_decimal;
    thanks,
    Orton

  • Its very urgent:how to insert data into database tables

    Hi All,
    I am very new to oaf.
    I have one requirement data insert into database tables.
    here createPG having data that data insert into one custom table.
    but i dont know how to insert data into database tables.
    i wrote the code in am,co as follows.
    in am i wrote the code:
    public void NewoperationManagerLogic()
    ManagerCustomTableVOImpl vo1=getManagerCustomTableVO1();
    OADBTransaction oadbt=getOADBTransaction();
    if(!vo1.isPreparedForExecution())
    vo1.executeQuery();
    Row row=vo1.createRow();
    vo1.insertRow(row);
    in createPG processrequest co:
    public void processRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processRequest(pageContext, webBean);
    ManagerInformationAMImpl am=(ManagerInformationAMImpl)pageContext.getApplicationModule(webBean);
    am.NewoperationManagerLogic();
    process form request:
    public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processFormRequest(pageContext, webBean);
    if(pageContext.getParameter("Submit")!=null)
    ManagerInformationAMImpl am=(ManagerInformationAMImpl)pageContext.getApplicationModule(webBean);
    am.getOADBTransaction().commit();
    please help with an example(sample code).
    its very urgent.
    thanks in advance
    Seshu
    Edited by: its urgent on Dec 25, 2011 9:31 PM

    Hi ,
    1.)You must have to create a EO based on custom table and then VO based on this EO eventually to save the values in DB
    2.) the row.setNewRowState(Row.STATUS_INITIALIZED); is used to set the the status of row as inialized ,this is must required.
    3.) When u will create the VO based on EO the viewattributes will be created in VO which will be assigned to the fields to take care the db handling .
    You must go thtough the lab excercise shipped with you Jdeveloper ,there is a example of Create Employee page ,that will solve your number of doubts.
    Thanks
    Pratap

  • Insert data into multiple tables

    Hi all,
    I've a requirement where i need to insert data into multiple tables using PL/SQL procedure
    Procedure should have two parameters
    1. Table Name (parameter1)
    2. Data (parameter2)
    Based on these two parameters i need to insert data into table (parameter1) using data (parameter2)
    ex:
    Procedure insert_data (p_table  IN VARCHAR2
                          ,p_data   IN -- what should be the datatype?
    IS
    l_statement VARCHAR2(2000);
    BEGIN
    -- insert data into tables
    INSERT INTO p_table
    values (....);
    END insert_data;Thanks in advance!!

    BEDE wrote:
    Amen to that!
    So, I believe a better approach would be the following...
    Suppose you have N datafiles with the same structure, and you wish to insert into the database the data from all those files.
    For that, you should have a single table, named, say incoming_file_data, which should be structured more or less like below:
    create table incoming_file_data (
    filename varchar2(250) not null -- name of the file inserted from
    ,file_time timestamp -- timestamp when the data was inserted
    ,... -- the columns of meaningful data contained in the lines of those files
    );And you will insert the data from all those files in this table, having normally one transaction for each file processed, for otherwise, when shit happens, some file may only get to be partially inserted into the table...
    Maybe one good approach would be to create dynamically an external table for the file to be loaded, and then execute dynamically insert select into the table I said, so that you will have only one insert select for one file instead of using utl_file... RTM on that.If the file structures are the same, and it's just the filename that's changing, I would have a single external table definition, and use the alter table ... location ... statement (through execute immediate) to change the filename(s) as appropriate before querying the data. Of course that's not scalable if there are multiple users intenting to use this, but generally when we talk about importing multiple files, it's a one-user/one-off/once-a-day type of scenario, so multi-user isn't a consideration.

  • How to import data from a text file into a table

    Hello,
    I need help with importing data from a .csv file with comma delimiter into a table.
    I've been struggling to figure out how to use the "Import from Files" wizard in Oracle 10g web-base Enterprise Manager.
    I have not been able to find a simple instruction on how to use the Wizard.
    I have looked at the Oracle Database Utilities - Overview of Oracle Data Pump and the Help on the "Import: Files" page.
    Neither one gave me enough instruction to be able to do the import successfully.
    Using the "Import from file" wizard, I created a Directory Object using the Create Directory Object button. I Copied the file from which i needed to import the data into the Operating System Directory i had defined in the Create Directory Object page. I chose "Entire files" for the Import type.
    Step 1 of 4 is the "Import:Re-Mapping" page, I have no idea what i need to do on this page. All i know i am not tying to import data that was in one schema into a different schema and I am not importing data that was in one tablespace into a different tablespace and i am not R-Mapping datafiles either. I am importing data from a csv file.
    For step 2 of 4, "Import:Options" page, I selected the same directory object i had created.
    For step 3 of 4, I entered a job name and a description and selected Start Immediately option.
    What i noticed going through the wizard, the wizard never asked into which table do i want to import the data.
    I submitted the job and I got ORA-31619 invalid dump file error.
    I was sure that the wizard was going to fail when it never asked me into which table do i want to import the data.
    I tried to use the "imp" utility in command-line window.
    After I entered (imp), i was prompted for the username and the password and then the buffer size as soon as i entered the min buffer size I got the following error and the import was terminated:
    C:\>imp
    Import: Release 10.1.0.2.0 - Production on Fri Jul 9 12:56:11 2004
    Copyright (c) 1982, 2004, Oracle. All rights reserved.
    Username: user1
    Password:
    Connected to: Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Produc
    tion
    With the Partitioning, OLAP and Data Mining options
    Import file: EXPDAT.DMP > c:\securParms\securParms.csv
    Enter insert buffer size (minimum is 8192) 30720> 8192
    IMP-00037: Character set marker unknown
    IMP-00000: Import terminated unsuccessfully
    Please show me the easiest way to import a text file into a table. How complex could it be to do a simple import into a table using a text file?
    We are testing our application against both an Oracle database and a MSSQLServer 2000 database.
    I was able to import the data into a table in MSSQLServer database and I can say that anybody with no experience could easily do an export/import in MSSQLServer 2000.
    I appreciate if someone could show me how to the import from a file into a table!
    Thanks,
    Mitra

    >
    I can say that anybody with
    no experience could easily do an export/import in
    MSSQLServer 2000.
    Anybody with no experience should not mess up my Oracle Databases !

Maybe you are looking for

  • Moving multiple kids to different game center after the fact.

    I currently have multiple I pads in my house (kids) using the same game center account for last few years ipad 2 and ipad 3 .  So far no scores purchases etc have filtered into the wrong i pad but they both do make purchases in same games. Now they b

  • Po tax - condition types defined sequence

    Hi Friends, we have v1 tax code defined for purchase order . There are five conditions typs in the tax code. I have to write some code for each condition type. for this I want to get these condition types in a sequence it is defined in the tax defina

  • Problem with InitialContext Creation in Weblogic 5.1

    Hi all, We are using Weblogic 5.1 on Windows and Solaris. We are trying to get InitialContext by the following code snippet. This piece of code is in a Thread which is kicked off by a startup class. The purpose of getting the initialContext here is t

  • Default settings for activating warranty subscreen

    I have a requirement to activate the warranty subscreen for maintenance equipment.  When this subscreen is activated, the "inherit warranty" and "pass on warranty" options are selected by default for equipment that already exists in the system.  I wa

  • Oracle HRMS to ADP View

    Hi Can anyone let me know is there any standard view for the ADP for the earning elements. I refered the metalink note it is giving details of the deduction but not the earning if anyone could share the details it would be great Thanks Regards Ramesh