Insert into table using dynamic data

Oracle form 6i
Hai
I need to insert my data into a table. I have generated my data from text file and data in a form now i need to insert these data into one table. How can insert my field to that table if there is data in table i need to update and there is no data i need to insert.. Pls tell me the solution..
Regards
Srikkanth.M

Create the on-insert trigger and check the data is thre or not through the Primary key value in this trigger. If data is thre then update or it not there then insert in the same trigger.
Thanks,
SUN

Similar Messages

  • Read text file insert into table using utl_file

    Hi
    i have script for read and insert into table but i want error records load into error table so i sent you my script and please fix the error log table
    script
    DECLARE
    v_line VARCHAR2(2000);
    v_file utl_file.file_type;
    v_dir VARCHAR2(250);
    v_filename VARCHAR2(50);
    BEGIN
    v_dir :='MID5010_DOC1TP';
    v_filename := 'OPT_CM_BASE.txt';
    v_file := utl_file.fopen(v_dir, v_filename, 'r');
    LOOP
    BEGIN
    utl_file.get_line(v_file, v_line);
    EXCEPTION
    WHEN no_data_found THEN
    EXIT;
    END ;
    v_line := REPLACE(v_line,'|','|~');
    INSERT
    INTO optum_icd10cm_base VALUES
    ( REPLACE(TRANSLATE(regexp_substr(v_line,'[^|~]+',1,1),'a~','a'),'.'),
    TRANSLATE(regexp_substr(v_line,'[^|~]+',1,2),'a~','a'),
    TRANSLATE(regexp_substr(v_line,'[^|~]+',1,3),'a~','a'),
    TRANSLATE(regexp_substr(v_line,'[^|~]+',1,4),'a~','a'),
    TRANSLATE(regexp_substr(v_line,'[^|~]+',1,5),'a~','a'),
    CASE
    WHEN LENGTH(regexp_substr(v_line,'[^|~]+',1,6)) < 10
    THEN to_date(ltrim(TRANSLATE(regexp_substr(v_line,'[^|~]+',1,6),'a~','a'),'0'),'mm-yyyy')
    ELSE to_date(TRANSLATE(regexp_substr(v_line,'[^|]+',1,6),'a~','a'),'mm-dd-yyyy')
    END,
    CASE
    WHEN LENGTH(regexp_substr(v_line,'[^|~]+',1,7)) < 10
    THEN to_date(ltrim(TRANSLATE(regexp_substr(v_line,'[^|~]+',1,7),'a~','a'),'0'),'mm-yyyy')
    ELSE to_date(TRANSLATE(regexp_substr(v_line,'[^|]+',1,7),'a~','a'),'mm-dd-yyyy')
    END,
    CASE
    WHEN LENGTH(regexp_substr(v_line,'[^|~]+',1,8)) < 10
    THEN to_date(ltrim(TRANSLATE(regexp_substr(v_line,'[^|~]+',1,8),'a~','a'),'0'),'mm-yyyy')
    ELSE to_date(TRANSLATE(regexp_substr(v_line,'[^|]+',1,8),'a~','a'),'mm-dd-yyyy')
    END,
    CASE
    WHEN LENGTH(regexp_substr(v_line,'[^|~]+',1,9)) < 10
    THEN to_date(ltrim(TRANSLATE(regexp_substr(v_line,'[^|~]+',1,9),'a~','a'),'0'),'mm-yyyy')
    ELSE to_date(TRANSLATE(regexp_substr(v_line,'[^|]+',1,9),'a~','a'),'mm-dd-yyyy')
    END,
    CASE
    WHEN LENGTH(regexp_substr(v_line,'[^|~]+',1,10)) < 10
    THEN to_date(ltrim(TRANSLATE(regexp_substr(v_line,'[^|~]+',1,10),'a~','a'),'0'),'mm-yyyy')
    ELSE to_date(TRANSLATE(regexp_substr(v_line,'[^|]+',1,10),'a~','a'),'mm-dd-yyyy')
    END,
    TRANSLATE(regexp_substr(v_line,'[^|~]+',1,11),'a~','a')
    -----commit;
    END LOOP;
    utl_file.fclose(v_file);
    END;
    text file
    A50.0||Short|Long|Full|01-01-2009|01-2009||01-01-2013|09-18-2012|C|
    A50.1||Short|Long|Full|01-01-2009|01-01-2009||001-2013|09-18-2012|C|
    A50.2||Short|Long|Full|01-01-2009|01-01-2009|67|01-01-2013|09-18-2012|C|
    A50.3||Short|Long|Full|011-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A50.4||Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|5|
    A50.5|R|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A50.6||Short|Long||01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A50.7||Short||Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    2345||Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.0|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.1|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.2|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.3|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.4|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.5|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.6|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.7|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.8|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A60.9|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A70.0|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A70.1|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A70.2|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A70.3|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A70.4|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    B222|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.1|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.2|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.3|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.4|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.5|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.6|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.7|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.8|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A4.9|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A5.0|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A5.1|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A5.2|D|Short|Long|Full|01-01-2009|01-01-2009|01-10-2013|01-01-2013|09-18-2012|C|
    A5.3|D|Short|Long|Full|01-01-2009|01-01-2009|01-10-2013|01-01-2013|09-18-2012|C|
    D642|D|Short|Long|Full|01-01-2009|01-01-2009|01-10-2013|01-01-2013|09-18-2012|C|
    A5.5|D|Short|Long|Full|01-01-2009|01-01-2009|01-10-2013|01-01-2013|09-18-2012|C|
    A5.6|D|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A5.7|C|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A001|C|Short Updated|Long Updated|Full Updated|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A009|C|Short Updated|Long Updated|Full Updated|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A5.10|C|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A0109|C|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    F10.0|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    F10.1|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    F10.2|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    F10.3|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    F10.4|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    F10.5|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    F10.6|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    F10.7|N|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A30|C|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A316|C|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    A317|C|Short|Long|Full|01-01-2009|01-01-2009||01-01-2013|09-18-2012|C|
    ----clearly read text file insert into table and error records load into error table
    please help me

    hI
    i am using utl_file prepared script but i got error like 01861. 00000 - "literal does not match format string"
    script:
    DECLARE
    f utl_file.file_type;
    s VARCHAR2(32000);
    f1 VARCHAR2(100);
    f2 varchar2(100);
    F3 VARCHAR2(100);
    F4 VARCHAR2(100);
    F5 VARCHAR2(100);
    F6 DATE;
    F7 DATE;
    F8 DATE;
    F9 DATE;
    F10 DATE;
    f11 CHAR(1);
    BEGIN
    --DBMS_OUTPUT.ENABLE(100000);
    f := utl_file.fopen('MID5010_DOC1TP', 'OPT_CM_BASE.txt', 'R');
    LOOP
    BEGIN
    UTL_FILE.GET_LINE(f, s);
    f1 := REGEXP_SUBSTR (s,'[^|]+',1,1);
    f2 := REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+', 1,2);
    F3 := REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+', 1,3);
    F4 := REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+', 1,4);
    F5 := REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+', 1,5);
    F6 := to_date(REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+',1,6),'mm-dd-yyyy');
    F8 := to_date(REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+',1,8),'mm-dd-yyyy');
    F7 := to_date(REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+',1,7),'mm-dd-yyyy');
    F9 := to_date(REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+',1,9),'mm-dd-yyyy');
    F10 :=to_date(REGEXP_SUBSTR (REPLACE(s,'||','||') ,'[^|]+',1,10),'mm-dd-yyyy');
    f11 := REGEXP_SUBSTR (REPLACE(s,'||','||'),'[^|]+', 1,11);
    INSERT
    INTO OPTUM_ICD10CM_BASE
    ( CODE,
    STATUS,
    SHORT_DESCRIPTION,
    LONG_DESCRIPTION,
    FULL_DESCRIPTION,
    CODE_EFFECTIVE_DATE,
    CHANGE_EFFECTIVE_DATE,
    TERMINATION_DATE,
    RELEASE_DATE,
    CREATION_DATE,
    VALIDITY
    VALUES
    F1,
    F2,
    F3,
    F4,
    F5,
    F6,
    F7,
    F8,
    F9,
    F10,
    f11
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    EXIT;
    END;
    END LOOP;
    UTL_FILE.FCLOSE(F);
    END;
    please help me(in my org looks utl_file standards only)

  • How to INSERT into table using CORRELATED subquery

    I have 3 tables:
    1.TEMP_PHONE(person_id, phonenumber, phone_type) - this holds all phone numbers relating to a person(just a temporary holding area)
    2.PHONE_CONNECT(PERSON_ID, PHONE_ID) this table shows all the phone numbers relating to an individual. Phone_id is a unique number to identify a phonenumber and type(cell, work, home) - so in this table a person can have multiple phone ids)
    3.MASTER_PHONE(PHONE_ID, PHONENUMBER, PHONE_TYPE) this is a master phone table. each combination of phone number and type has a unique identifier-phone_id.
    What i need to figure out is how to populate PHONE_CONNECT with the information from TEMP_PHONE IF PERSON_ID already exists but phone_id is different. In other words, if the person gets a new phone number, i need to insert a new row into phone_connect.
    Before that step is started, the master_phone is populated first with a new phone_id associated to the phonenumber/type
    any help would be much appreciated. Thanks in advance.
    So far, this is what i have come up with, but not sure if it makes sense:
    insert into phone_connect(person_id)
    select a.person_id
    from temp_phone a
    where
    person_id = (select b.person_id from phone_connect b, master_phone c
    where
    a.person_id=b.person_id
    and b.phone_id <> c.phone_id
    and c.phonenumber||c.phone_type=a.phonenumber||a.phone_type);
    update phone_connect c
    set phone_id=(
    select b.phone_id
    from temp_phone a, master_phone b
    where a.person_id = c.person_id
    and a.phonenumber||a.phone_type = b.phonenumber||b.phone_type)
    where phone_id is null;

    It does. You are right. But that's what i need help with. I don't think my code is correct. After the insert, the code is actually updating the same exact record I just inserted. I'm sure this all can be done with one insert. I just really don't know how to show that in my code.
    I need to insert a new record into phone_connect with person_id and phone_id. phone_id is already populated in master_phone. I guess my problem is how to go about creating the joins to all three tables to make sure im inserting the data correctly, or not inserting data that already exists.

  • INSERT INTO TABLE using SELECT takes long time

    Hello Friends,
    --- Oracle version 10.2.0.4.0
    --- I am trying to insert around 2.5 lakhs records in a table using INSERT ..SELECT. The insert takes long time and seems to be hung.
    --- When i try to SELECT the query fetches the rows in 10 seconds.
    --- Any clue why it is taking so much time

    vishalrs wrote:
    Hello Friends,hello
    >
    >
    --- Oracle version 10.2.0.4.0
    alright
    --- I am trying to insert around 2.5 lakhs records in a table using INSERT ..SELECT. The insert takes long time and seems to be hung.
    I don't know how a lakh is, but it sounds like a lot...
    --- When i try to SELECT the query fetches the rows in 10 seconds.
    how did you test this? and did you fetch the last record, or just the first couple of hundred.
    --- Any clue why it is taking so much timeWithout seeing anything, it's impossible to tell the reason.
    Search the forum for "When your query takes too long"

  • Error While Inserting Data into table using OAF

    Hi Experts,
    I am learning OAF; i am trying into insert the data into table using OAF. I followed the below procedure.
    My table(OLF_TEST_TBL) Columns:
    EmpID (Number), Ename(VARCHAR2 100), Sal Number, and who columns.
    1. created Application Module (AM).
    package: oracle.apps.mfg.simplepg.server
    name: oaf_test_tbl_am
    2. created simple page
    name:EmployeePG
    package:oracle.apps.mfg.simplepg.webui
    3. Assigned the Application Module to Page
    4. Created Entity Object(EO)
    name:oaf_test_tbl_eo
    package:oracle.apps.mfg.simplepg.schema.server
    schema:apps
    table:OLF_TEST_TBL
    note:
    1. EMPID column is selected as primary key
    2. selected create method, remove method and validation method.
    3.checked generate default view object
    VO:
    name:olf_test_tbl_vo
    note: Entity Object was assigned to VO
    Coming To page:
    page main region:EmployeeMainRN
    1.under main region i created one more region using wizard
    selected AM and VO, region style-default single column
    2. under main region i created one more region
    region style- pagebuttonbar, ID:pagebutoonsRN
    3. under pagebuttonRN, created two submit buttons(ID:SUBMIT, ID:CANCEL).
    In AM java page:
    created a method to insert row and for commit.
    Insert Method:
    public void insertrow(){
    OAViewObject vo=(OAViewObject)getoaf_test_tbl_vo1();
    if(!vo.isPreparedForExecution()){
    vo.executeQuery();
    Row row=vo.createRow();
    vo.insertRow(row);
    row.setNewRowState(Row.STATUS_INITIALIZED);
    Commit Method:
    public void savaDataTooaftesttable(){
    getDBTransaction().commit();
    In EmployeeMainRN, created a controller.
    In this controller process request method, 'insertrow' method was called.
    import oracle.apps.fnd.framework.OAApplicationModule;
    public void processRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processRequest(pageContext, webBean);
    if (!pageContext.isFormSubmission())
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    am.invokeMethod("insertrow");
    To commit the transaction when SUBMIT button pressed, commit method was called in process form request method.
    import oracle.apps.fnd.framework.OAViewObject;
    public void processformRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processFormRequest(pageContext, webBean);
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    if (pageContext.getParameter("SUBMIT") != null)
    am.invokemethod("savaDataTooaftesttable");
    Error After clicking the submit button_
    I ran the page, page was opened successfully. Once i enter data and click submit button, it's giving the following error.
    The requested page contains stale data. This error could have been caused through the use of the browser's navigation buttons (the browser Back button, for example). If the browser's navigation buttons were not used, this error could have been caused by coding mistakes in application code. Please check Supporting the Browser Back Button developer guide - View Object Primary Key Comparison section to review the primary causes of this error and correct the coding mistakes.
    Cause:
    The view object oaf_test_tbl_am.oaf_test_tbl_vo1700_oaf_test_tbl_vo1_practice_test_prc1_oracle_apps_mfg_simplepg_server_oaf_test_tbl_am.oaf_test_tbl_vo1 contained no record. The displayed records may have been deleted, or the current record for the view object may not have been properly initialized.
    To proceed, please select the Home link at the top of the application page to return to the main menu. Then, access this page again using the application's navigation controls (menu, links, and so on) instead of using the browser's navigation controls like Back and Forward.
    Experts, Kindly help me why i am getting this error.
    Awating your replies.
    Thanks in advance.

    If you dont want to create message. You can throw exception like below as well
              throw new OAException("Emp Id is "+empId+" and employee name is "+empName, OAException.CONFIRMATION);Thanks
    --Anil                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Data is not inserting into table

    Hi Team,
    I am inserting data into a custom table.
    but my records are not inserting into table
    //CO File
    public void processRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processRequest(pageContext, webBean);
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    am.invokeMethod("createEmployee");
    // am.invokeMethod("init");
    * Procedure to handle form submissions for form elements in
    * a region.
    * @param pageContext the current OA page context
    * @param webBean the web bean corresponding to the region
    public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processFormRequest(pageContext, webBean);
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    if (pageContext.getParameter("Apply") != null)
    OAViewObject vo = (OAViewObject)am.findViewObject("TestEmpVO1");
    String NAME = (String)vo.getCurrentRow().getAttribute("Name");
    Number employeeNumber = (Number)vo.getCurrentRow().getAttribute("Num");
    String NUM = String.valueOf(employeeNumber.intValue());
    am.invokeMethod("apply");
    MessageToken[] tokens = { new MessageToken("EMP_NAME", NAME),
    new MessageToken("EMP_NUMBER", NUM) };
    OAException confirmMessage = new OAException("AK", "FWK_TBX_T_EMP_CREATE_CONFIRM", tokens,
    OAException.CONFIRMATION, null);
    pageContext.putDialogMessage(confirmMessage);
    else if (pageContext.getParameter("Cancel") != null)
    am.invokeMethod("rollbackEmployee");
    TransactionUnitHelper.endTransactionUnit(pageContext, "empCreateTxn");
    // End CO
    //AMImpl
    package oracle.apps.fnd.framework.toolbox.labsolutions.server;
    import oracle.jbo.Row;
    import oracle.jbo.Transaction;
    import oracle.jbo.RowSetIterator;
    import oracle.jbo.domain.Number;
    import oracle.apps.fnd.common.MessageToken;
    import oracle.apps.fnd.common.VersionInfo;
    import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
    import oracle.apps.fnd.framework.OAException;
    import oracle.apps.fnd.framework.OARow;
    import oracle.apps.fnd.framework.OAViewObject;
    import oracle.apps.fnd.framework.server.OAViewObjectImpl;
    // --- File generated by Oracle Business Components for Java.
    public class TestEmpAMImpl extends EmployeeAMImpl
    * This is the default constructor (do not remove)
    public TestEmpAMImpl()
    * Container's getter for TestEmpVO1
    public TestEmpVOImpl getTestEmpVO1()
    return (TestEmpVOImpl)findViewObject("TestEmpVO1");
    * Creates a new employee.
    public void createEmployee()
    OAViewObject vo = (OAViewObject)getTestEmpVO1();
    // Per the coding standards, this is the proper way to initialize a
    // VO that is used for both inserts and queries. See View Objects
    // in Detail in the Developer's Guide for additional information.
    if (!vo.isPreparedForExecution())
    vo.executeQuery();
    Row row = vo.createRow();
    vo.insertRow(row);
    // Required per OA Framework Model Coding Standard M69
    row.setNewRowState(Row.STATUS_INITIALIZED);
    } // end createEmployee()
    public void apply()
    getDBTransaction().commit();
    * Sample main for debugging Business Components code using the tester.
    public static void main(String[] args)
    launchTester("oracle.apps.fnd.framework.toolbox.labsolutions.server", "TestEmpAMLocal");
    //End AmImpl
    Please suggest.
    Thanks,
    Ajit

    Ajit,
    Its always a good idea to close the thread with an explanation. It will help others whenever they are into similar situation.
    --Shiv                                                                                                                                                                                                                                                                                               

  • System getting hanged whilst using Insert into table select * from table

    I have a peculiar problem.
    I am using the below statements:
    Query 1:
    insert into table ppms.erin_out@ppms_dblink select * from erin_out;
    Query 2:
    insert into table ppms.erin_out@ppms_dblink values(23,'dffgg',12',dfdfdgg,dfdfdg);
    I am in 'interfaces' schema (testing server) and executing above statements. We have testing server and development server, both are identical, i.e one is clone of the other.
    ppms_dblink is created in interfaces schema. ppms_dblink points to different database server which has two schemas 'clarity' and 'ppms'. ppms_dblink is create through authentication details of clarity schema.
    erin_out table is created on ppms schema on the same dababase server pointed by ppms_dblink.
    Question is :
    TOAD hangs while running query 1.
    Query 2 is working perfectly.
    As I have pl/sql script which is using query 1. I want to know why query 1 is creating problem.
    If I use query 2 in my pl/sql query then it may create performance issue as i have to use cursor then.
    On clarity schema, I have insert, update, select, modify rights on ppms.erin_out.
    I have tried same queries from another database server.
    That is I tried queries from 'interfaces' schema of development server ( clone of the testing server ). Its working perfectly.
    Message was edited by:
    user484158

    Dhanchik:
    The table from which I select rows, to insert into table on dblink, is having only one record. It may contatin maximum 100 rows at a time because I am scheduling the procedure through daemon process. Anyway transaction is not more than 100 records. I am trying with just 1 record for testing.
    So 1) Problem is not about the cost, TOAD is getting hanged ( to insert 1 record, cost does not mean much)
    2) there is no large amount of data, so no question of deteriorated performance
    Aron Tunzi:
    I think that should not be problem, because I am able to insert a record through query 2.
    Warren Tolentino :
    I am testing with 1 record only. Its not performance issue.
    Message was edited by:
    &#2352;&#2330;&#2367;&#2340;

  • Unable to perform "insert into table select ...." using DBF_JDBC30

    below i post my code :
    import java.util.*;
    import java.sql.*;
    import java.io.*;
    import com.hxtt.sql.*;
    public class backofficeDbfVerification {
    public backofficeDbfVerification(String path) throws SQLException {
    Properties prop = new Properties();
    prop.setProperty("user", "");
    prop.setProperty("OtherExtensions","true");
    prop.setProperty("Version Number", "03");
    try {
    Class.forName("com.hxtt.sql.dbf.DBFDriver").newInstance();
    connection = DriverManager.getConnection("jdbc:DBF:/"+path, prop);
    catch (ClassNotFoundException classnotfoundexception) {
    System.out.println("could ot find HXTT class, make sure the classpath have been defined in your system !");
    catch(Exception e) {
    System.out.println(e.getMessage());
    public void createBadRecord(String table, String newtable, int blth) throws SQLException {
    Statement stmt = connection.createStatement();
    String insert = "insert into \""+newtable+"\" select * from \""+table+"\"";
    boolean bInsert = stmt.execute(insert);
    stmt.close();
    public static void main (String args[]) {
         String path = "C:\\MASTER\\SOURCEDATA\\AREA";
    try {
    backofficeDbfVerification test = new backofficeDbfVerification(path);
    test.createBadRecord("source\\area\\123.AA2","source\\area\\others\\89964568.AA1");
    catch(SQLException sqx) {
    System.out.println("Error "+sqx.getMessage());
    i try to perform simple query : insert into tablea select from tableb which has same structure. the source table has only 9 rows, but the process ran very long time, no error message raised,it just run and never end (which make me upset for the whole day).
    i have tried another simple query : insert into table1 values (1,2) using the same driver and execute successfully.
    is it becoz of function limitation since i used evaluation copy ?

    Copy the answer from HXTT's support forum:
    No function limitation. I just tested:
    create table testa1 select * from test;
    insert into testa1 select * from test;
    Passed.
    I also run your backofficeDbfVerification.java sample. Passed too. I'm using the same code as you. The difference is only my 89964568.AA1 and 123.AA2 is simulative tables files. If possible, please zip your 89964568.AA1 and 123.AA2 and email to [email protected] Thanks.
    BTW, I pasted the little modified backofficeDbfVerification.java below:
    import java.sql.*;
    import java.util.*;
    public class backofficeDbfVerification {
    Connection connection;
    public backofficeDbfVerification(String path) throws SQLException {
    Properties prop = new Properties();
    prop.setProperty("user", "");
    prop.setProperty("OtherExtensions", "true");
    prop.setProperty("Version Number", "03");
    try {
    Class.forName("com.hxtt.sql.dbf.DBFDriver").newInstance();
    connection = DriverManager.getConnection("jdbc:DBF:/" + path, prop);
    catch (ClassNotFoundException classnotfoundexception) {
    System.out.println("could ot find HXTT class, make sure the classpath have been defined in your system !");
    catch (Exception e) {
    System.out.println(e.getMessage());
    public void createBadRecord(String table, String newtable) throws
    SQLException {
    Statement stmt = connection.createStatement();
    String insert = "insert into \"" + newtable + "\" select * from \"" +
    table + "\"";
    boolean bInsert = stmt.execute(insert);
    stmt.close();
    public static void main(String args[]) {
    String path = "f:\\dbffiles";
    try {
    backofficeDbfVerification test = new backofficeDbfVerification(path);
    test.createBadRecord("source\\area\\123.AA2",
    "source\\area\\others\\89964568.AA1");
    catch (SQLException sqx) {
    System.out.println("Error " + sqx.getMessage());
    }

  • Duplicate insert into table

    hello all,
    i am having problem when insert data into table. my first value will insert into table once again and again when i refresh page or logged in as another person.
    is it because i am using JavaScript onChange on my page? here is my script..
    <html>
    <head>
    <title>Post New Offer</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script language="JavaScript" src="ts_picker.js"></script>
    </head>
    <body>
    <%@ page import ="java.sql.*" %>
    <%@ page import ="java.lang.*" %>
    <%@ page import ="java.util.*" %>
    <%@ page import ="java.io.*" %>
    <%@ page import ="java.text.SimpleDateFormat"%>
    <script language="JavaScript">
    function select_offer() {
    document.formoffer.submit();
    </script>
    <%!
    String username;
    String otype="";
    String submitform;
    String submitsave="";
    String bizid="";
    String contperson="";
    String ocategory="";
    String otitle="";
    String odesc="";
    String oposted="";
    String oexpiry="";
    String oprice;
    String ocheck="";
    String oqty;
    String ounit="";
    String oneeded="";
    String odelivery="";
    String opackaging="";
    String ostatus="";
    float price;
    int qty;
    int columns =0;
    int col =0;
    int vd =0;
    int columncate =0;
    int colcate =0;
    int rowcate =0;
    int vdcate=0;
    %>
    <jsp:useBean id="insertinto" class="ita.InsertNewOffer" scope="request" />
    <jsp:setProperty name="insertinto" property="*" />
    <% insertinto.connect();
    insertinto.setQueryInfo(username);
    col = insertinto.getColumn();
    Vector recordVector = insertinto.getVectorRow();
    insertinto.setQuery();
    colcate = insertinto.getColumn();
    rowcate = insertinto.getRow();
    Vector outVector = insertinto.getVectorRow();
    %>
    <!-- Header Menu -->
    <%@ include file="headermenu.jsp"%>
    <hr size="1">
    <br>
    <table width="100%" border="0">
    <tr>
    <td width="23%"><div align="right"><font size="2" face="Arial, Helvetica,
    sans-serif">Post by <b><% out.println(username); %></b></font></div>
    </td>
    </tr>
    </table>
    <!-- Left Menu -->
    <%@ include file="leftmenu.jsp"%>
    <%
    submitform = request.getParameter("submitform");
    if((submitform != null) && (submitform.equals("Post Offer")) && (!(otype.equals("none"))) && (!(bizid.equals(""))))
    ostatus = "posted";
    if((submitform != null) && (submitform.equals("Save Offer")) && (!(otype.equals("none"))) && (!(bizid.equals(""))))
    ostatus = "saved";
    bizid = request.getParameter("bizid"); if (bizid == null) { bizid = ""; }
    bizid = bizid.trim();
    otype = request.getParameter("otype"); if (otype == null) { otype = "none"; }
    ocategory = request.getParameter("ocategory"); if (ocategory == null) { ocategory = ""; }
    String cat="";
    String[] cat2 = request.getParameterValues("ocategory");
    if (cat2 != null)
    for(int i=0;i<cat2.length;i++) {
    cat += cat2[i] +";";
    //out.println("choose1 : "+cat2+"<br>");
    //out.println("choose2 : "+cat2[i]+"<br>");
    //out.println("choose3 : "+cat+"<br>");
    otitle = request.getParameter("otitle"); if (otitle == null) { otitle = ""; }
    odesc = request.getParameter("odesc"); if (odesc == null) { odesc = ""; }
    oposted = request.getParameter("oposted");
    oexpiry = request.getParameter("oexpiry");
    oexpiry = oexpiry.trim();
    oprice = request.getParameter("oprice");
    float price = 0;
    if (oprice != null) {
    try {
    price = Float.parseFloat(oprice);
    catch(NumberFormatException e) {}
    oqty = request.getParameter("oqty");
    int qty = 0;
    if (oqty != null) {
    try {
    qty = Integer.parseInt(oqty);
    catch(NumberFormatException e) {}
    ocheck = request.getParameter("ocheck"); if (ocheck == null) { ocheck = "no"; }
    ounit = request.getParameter("ounit"); if (ounit == null) { ounit = "none"; }
    oneeded = request.getParameter("oneeded"); if (oneeded == null) { oneeded = ""; }
    odelivery = request.getParameter("odelivery"); if (odelivery == null) { odelivery = ""; }
    opackaging = request.getParameter("opackaging"); if (opackaging == null) { opackaging = ""; }
    contperson = request.getParameter("contperson"); if (contperson == null) { contperson = ""; }
    contperson = contperson.trim();
    insertinto.InsertNew(bizid,otype,cat,otitle,odesc,oposted,oexpiry,price,ocheck,qty,ounit,oneeded,odelivery,opackaging,ostatus,contperson);
    insertinto.disconnect();
    %>
    <td width="77%">
    <form name="formoffer" method="post" action="NewOffer.jsp?username=<% out.println(username);%> ">
    <table width="100%" border="0" cellpadding="2">
    <tr>
    <td width="77%">
    <table width="100%" border="0">
    <tr>
    <td><font size="5" face="Arial, Helvetica, sans-serif">My Offer</font></td>
    </tr>
    <tr bgcolor="#FFCC00">
    <td colspan="3"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <b>1) Offer Detail</b></font> </td>
    </tr>
    <tr>
    <td valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Offer
    date :</font></td>
    <td width="61%" colspan="2"><font color="#336600" size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <%= new java.util.Date() %></font>
    <input type="hidden" name="oposted" value="<%= dateString %>"> </td>
    </tr>
    <tr>
    <td width="39%" valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Offer
    type :</font></td>
    <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <select name="otype" onChange="select_offer()">
         <%
         if (otype.equals("")||otype.equals("none")) { %>
    <option selected value="none">Select one</option>
    <option value="Buy">Buy</option>
         <option value="Sell">Sell</option>
         <option value="Biz Opportunity">Biz Op</option>
    <option value="Excess Stock">Excess Stock</option>
         <% }
    else if (otype.equals("Buy")) { %>
    <option value="none">Select one</option>
    <option selected value="Buy">Buy</option>
         <option value="Sell">Sell</option>
         <option value="Biz Opportunity">Biz Op</option>
    <option value="Excess Stock">Excess Stock</option>
         <% }
    else if (otype.equals("Sell")) { %>
    <option value="none">Select one</option>
    <option value="Buy">Buy</option>
         <option selected value="Sell">Sell</option>
         <option value="Biz Opportunity">Biz Op</option>
    <option value="Excess Stock">Excess Stock</option>
         <% }
    else if (otype.equals("Biz Opportunity")) { %>
    <option value="none">Select one</option>
    <option value="Buy">Buy</option>
         <option value="Sell">Sell</option>
         <option selected value="Biz Opportunity">Biz Op</option>
    <option value="Excess Stock">Excess Stock</option>
         <% }
    else if (otype.equals("Excess Stock")) { %>
    <option value="none">Select one</option>
    <option value="Buy">Buy</option>
         <option value="Sell">Sell</option>
         <option value="Biz Opportunity">Biz Op</option>
    <option selected value="Excess Stock">Excess Stock</option>
         <% } %>
    </select>
    </font> </td>
    </tr>
    <tr>
    <td valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Category
    : </font></td>
    <td colspan="2">
    <% vdcate=0; %>
    <select name="ocategory" size="4" multiple>
    <% while (vdcate<outVector.size()) {
    for (int j=0; j<colcate; j++) {
    if (j==0) {
    String catid = (String)outVector.elementAt(vdcate) ;
    String mainlevel = (String)outVector.elementAt(vdcate+1) ;
    String level1 = (String)outVector.elementAt(vdcate+2) ;
    String level2 = (String)outVector.elementAt(vdcate+3) ;%>
    <option value=<% out.println(catid); %> >
    <% out.println(mainlevel); %>  - 
              <% out.println(level1); %>  - 
              <% out.println(level2); %>
    <% }
    if (j > 0) {}
    vdcate++;
    } %>
    </option>
    </select>
    </td>
    </tr>
    <tr>
    <td valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Title
    :</font></td>
    <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <input name="otitle" type="text" size="35">
    </font> </td>
    </tr>
    <tr>
    <td valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Offer
    description :</font></td>
    <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <textarea name="odesc" cols="30"></textarea>
    </font> </td>
    </tr>
    <tr>
    <td valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Expiry date :</font></td>
    <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <input type="Text" name="oexpiry" readOnly style="BACKGROUND-COLOR: #eeeeee">
    <img src="img/cal.gif" width="16" height="16" border="0" alt="Click to select date">
    </font>
    </td>
    </tr>
    <%
    System.out.println("display form" +otype);
    if (otype.equals("Buy")) { %>
    <tr>
    <td valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    Target price : </font></td>
    <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">RM
    <input name="oprice" type="text" size="7">
    <input type="checkbox" name="ocheck" value="yes">
    <font color="#FF0000">*<font color="#000000" size="1">Negotiable</font></font></font>
    </td>
    </tr>
    <tr>
    <td valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Minimum
    quantity :</font></td>
    <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <input name="oqty" type="text" size="10">
    <select name="ounit" size="1">
    <option selected value="none">Choose one</option>
    <option>Kg</option>
    <option>Pack</option>
    <option>Ton</option>
    <option>Boxes</option>
    <option>Carton</option>
    </select>
    </font></td>
    </tr>
    <tr>
    <td valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">When
    needed / Supply period :</font></td>
    <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <select name="oneeded">
    <option selected value="none">Select one</option>
    <option>Daily</option>
    <option>1 week</option>
    <option>2 weeks</option>
    <option>1 month</option>
    <option>2 months</option>
    <option>3 months</option>
    <option>6 months</option>
    </select>
    </font></td>
    </tr>
    <% } %>
    <%
    if (otype.equals("Sell")) { %>
    <tr>
    <td valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Delivery
    : </font></td>
    <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <select name="odelivery" size="1">
    <option selected value="none">Choose one</option>
    <option>Own transport</option>
         </select>
    </font></td>
    </tr>
    <tr>
    <td valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Packaging
    : </font></td>
    <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <select name="opackaging" size="1">
    <option selected value="none">Choose one</option>
    <option>Included</option>
    <option>Not included</option>
         </select>
    </font></td>
    </tr>
    <tr>
    <td valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    Selling price : </font></td>
    <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">RM
    <input name="oprice" type="text" size="7">
    <input type="checkbox" name="ocheck" value="yes">
    <font color="#FF0000">*<font color="#000000" size="1">Negotiable</font></font></font>
    </td>
    </tr>
    <tr>
    <td valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Available
    quantity :</font></td>
    <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <input name="oqty" type="text" size="10">
    <select name="ounit" size="1">
    <option selected value="none">Choose one</option>
    <option>Kg</option>
    <option>Pack</option>
    <option>Ton</option>
    <option>Boxes</option>
    <option>Carton</option>
    </select>
    </font></td>
    </tr>
    <% } %>
    <%
    if (otype.equals("Excess Stock")) { %>
    <tr>
    <td valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Delivery
    : </font></td>
    <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <select name="odelivery" size="1">
    <option selected value="none">Choose one</option>
    <option>Own transport</option>
         </select>
    </font></td>
    </tr>
    <tr>
    <td valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Packaging
    : </font></td>
    <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <select name="opackaging" size="1">
    <option selected value="none">Choose one</option>
    <option>Included</option>
    <option>Not included</option>
         </select>
    </font></td>
    </tr>
    <tr>
    <td valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    Offer price : </font></td>
    <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">RM
    <input name="oprice" type="text" size="7">
    <input type="checkbox" name="ocheck" value="yes">
    <font color="#FF0000">*<font color="#000000" size="1">Negotiable</font></font></font>
    </td>
    </tr>
    <tr>
    <td valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Available
    quantity :</font></td>
    <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <input name="oqty" type="text" size="10">
    <select name="ounit" size="1">
    <option selected value="none">Choose one</option>
    <option>Kg</option>
    <option>Pack</option>
    <option>Ton</option>
    <option>Boxes</option>
    <option>Carton</option>
    </select>
    </font></td>
    </tr>
    <% } %>
    <tr>
    <td valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> </font></td>
    <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> </font></td>
    </tr>
    <% vd=0; %>
    <% for (int vd=0; vd<col; vd++) {  %>
    <tr bgcolor="#FFCC00">
    <td colspan="3" valign="top"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>2)
    Contact Information</b></font></td>
    </tr>
    <tr>
    <td valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Business
    ID : </font></td>
    <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <% String bizid = (String)recordVector.elementAt(vd); vd++; %>
    <% out.println(bizid); %></font>
    <input type="hidden" name="bizid" value="<% out.println(bizid); %>">
    </td>
    </tr>
    <tr>
    <td valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Contact person : </font></td>
    <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <% String conttitle = (String)recordVector.elementAt(vd); vd++; %>
    <% String contperson = (String)recordVector.elementAt(vd); vd++; %>
    <% out.println(conttitle);
    out.println( contperson);%>
    <input type="hidden" name="contperson" value="<% out.println(contperson); %>"></font></td></tr>
    <tr>
    <td valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Company name :</font></td>
    <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <% out.println(recordVector.elementAt(vd));vd++; %></font>
    </td>
    </tr>
    <tr>
    <td valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Address
    : </font></td>
    <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
         <% out.println(recordVector.elementAt(vd));vd++; %>,
    <% out.println(recordVector.elementAt(vd));vd++; %>, 
    <% out.println(recordVector.elementAt(vd));vd++; %>
    <% out.println(recordVector.elementAt(vd));vd++; %></font></td>
    </tr>
    <tr>
    <td valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Telephone
    : </font></td>
    <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
         <% out.println(recordVector.elementAt(vd));vd++; %></font></td>
    </tr>
    <tr>
    <td valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Mobile phone
    : </font></td>
    <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
         <% out.println(recordVector.elementAt(vd));vd++; %></font></td>
    </tr>
    <tr>
    <td valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Fax
    :</font></td>
    <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <% out.println(recordVector.elementAt(vd));vd++; %></td>
    </tr>
    <tr>
    <td valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Email
    : </font></td>
    <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <a href ="mailto:<% out.println(username);%>@b2bxchange.com.my">
    <% out.println(username);%>@b2bxchange.com.my</a></font></td>
    </tr>
    <tr>
    <td valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Website
    : </font></td>
    <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <% String website = (String)recordVector.elementAt(vd); vd++; %>
    <a href="<% out.println(website); %>"><% out.println(website); %></a></font></td>
    </tr>
    <tr>
    <td colspan="3"><font face="Arial, Helvetica, sans-serif"> </font></td>
    </tr>
    <tr>
    <td colspan="3"><div align="center"> <font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <input type="submit" name="submitform" value="Post Offer"> 
    <input type="submit" name="submitform" value="Save Offer"> 
    <input type="reset" name="resetform" value="Reset">
    </font></div></td>
    </tr>
    </table>
    </form>
    </td></tr>
    <% } %>
    <% vd=0; %>
    </table>
    </body>
    </html>

    I'm not going to try to read all your code, but I will take your hint about the "onChange".
    What I would suggest is that you set a boolean variable, such as "changed", set to false at the beginning (perhaps in the "onLoad" event). Your "onChange" event can simply change the "changed" variable to true. Then, when the user leaves the page, or clicks Submit or whatever, test that variable to see if any changes were made, then take the appropriate action.

  • How do i insert into table through forms

    Hi
    I have developed a custom form based on custom table.
    the only way to insert data into database table is through form.
    there are two tables: one table is to store all contract details & second table is to maintain history forthis.
    one condition(col1,col2,col3,col4) are unique combination,we are not creating any PK or FK at database level.evrythng is captured at form level.
    if all 4 columns combination exist thn e should not insert that record.
    if 4 columns combination doesnot exist then insert into table.
    I have used just pre insert,pre update triggers.
    I think its a basic form functionality ,by itself it inserts ,update record.now it is doing the same thng.
    But I have to add the above condition ,how can i do that.
    Pl provide me some ex code .
    Thank you.
    Hope any one can help me

    SQL> create table t
      2  (object_id    number
      3  ,object_name  varchar2(30));
    Table created.
    SQL>
    SQL> create sequence t_seq;
    Sequence created.
    SQL>
    SQL> insert into t (object_id, object_name)
      2  select t_seq.nextval
      3        ,object_name
      4  from   all_objects
      5  ;
    52637 rows created.

  • Insert into tables in different schemas

    hi,
    I insert into few tables through stored procedures, now there is a scenario wherein,
    by passing parameters to the stored procedures i should be able to insert into table in another schema.
    Eg.,
    Table EMP in Schema Dev
    Table EMP in Schema Test
    MY stored procedures should insert into dev's emp or Test's EMP table based on the parameter.
    The procedures are combined as a package and will be run through CONTROL M scheduler with the help of environment files.
    Thanks in advance

    A) Double your procedures/packages and let Control-M run it in Test and in Production environment.
    B) Avoid dynamical calls. This will usually create problems later on. E.g. if column ename is dropped from table emp, your package will not invalidate. Furthermore each dynamic SQL has a potential risk for code injection if not used with binding. Imagine somebode calls this with v_schema = ' dual values (''hacked db''); insert into test'
    C) There is some ALTER SESSION command to switch the current schema. Maybe this helps.

  • Reg: read excel column and insert into table.

    hi Friends,
          i wanted to read the data from Excel and insert into in my oracle tables.
          can you provide the link or example script.
        how to read the column value from excel and insert into table.
      please help.

    < unnecessary reference to personal blog removed by moderator >
    Here are the steps:
    1) First create a directory and grant read , write , execute to the user from where you want to access the flat files and load it.
    2) Write a generic function to load PIPE delimited flat files:
    CREATE OR REPLACE FUNCTION TABLE_LOAD ( p_table in varchar2,
    p_dir in varchar2 DEFAULT ‘YOUR_DIRECTORY_NAME’,
    P_FILENAME in varchar2,
    p_ignore_headerlines IN INTEGER DEFAULT 1,
    p_delimiter in varchar2 default ‘|’,
    p_optional_enclosed in varchar2 default ‘”‘ )
    return number
    is
    – FUNCTION TABLE_LOAD
    – PURPOSE: Load the flat files i.e. only text files to Oracle
    – tables.
    – This is a generic function which can be used for
    – importing any text flat files to oracle database.
    – PARAMETERS:
    – P_TABLE
    – Pass name of the table for which import has to be done.
    – P_DIR
    – Name of the directory where the file is been placed.
    – Note: The grant has to be given for the user to the directory
    – before executing the function
    – P_FILENAME
    – The name of the flat file(a text file)
    – P_IGNORE_HEADERLINES
    – By default we are passing 1 to skip the first line of the file
    – which are headers on the Flat files.
    – P_DELIMITER
    – Dafault “|” pipe is been passed.
    – P_OPTIONAL_ENCLOSED
    – Optionally enclosed by ‘ ” ‘ are been ignored.
    – AUTHOR:
    – Slobaray
    l_input utl_file.file_type;
    l_theCursor integer default dbms_sql.open_cursor;
    l_lastLine varchar2(4000);
    l_cnames varchar2(4000);
    l_bindvars varchar2(4000);
    l_status integer;
    l_cnt number default 0;
    l_rowCount number default 0;
    l_sep char(1) default NULL;
    L_ERRMSG varchar2(4000);
    V_EOF BOOLEAN := false;
    begin
    l_cnt := 1;
    for TAB_COLUMNS in (
    select column_name, data_type from user_tab_columns where table_name=p_table order by column_id
    ) loop
    l_cnames := l_cnames || tab_columns.column_name || ‘,’;
    l_bindvars := l_bindvars || case when tab_columns.data_type in (‘DATE’, ‘TIMESTAMP(6)’) then ‘to_date(:b’ || l_cnt || ‘,”YYYY-MM-DD HH24:MI:SS”),’ else ‘:b’|| l_cnt || ‘,’ end;
    l_cnt := l_cnt + 1;
    end loop;
    l_cnames := rtrim(l_cnames,’,');
    L_BINDVARS := RTRIM(L_BINDVARS,’,');
    L_INPUT := UTL_FILE.FOPEN( P_DIR, P_FILENAME, ‘r’ );
    IF p_ignore_headerlines > 0
    THEN
    BEGIN
    FOR i IN 1 .. p_ignore_headerlines
    LOOP
    UTL_FILE.get_line(l_input, l_lastLine);
    END LOOP;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    v_eof := TRUE;
    end;
    END IF;
    if not v_eof then
    dbms_sql.parse( l_theCursor, ‘insert into ‘ || p_table || ‘(‘ || l_cnames || ‘) values (‘ || l_bindvars || ‘)’, dbms_sql.native );
    loop
    begin
    utl_file.get_line( l_input, l_lastLine );
    exception
    when NO_DATA_FOUND then
    exit;
    end;
    if length(l_lastLine) > 0 then
    for i in 1 .. l_cnt-1
    LOOP
    dbms_sql.bind_variable( l_theCursor, ‘:b’||i,
    ltrim(rtrim(rtrim(
    regexp_substr(l_lastLine,’([^|]*)(\||$)’,1,i),p_delimiter),p_optional_enclosed),p_optional_enclosed));
    end loop;
    begin
    l_status := dbms_sql.execute(l_theCursor);
    l_rowCount := l_rowCount + 1;
    exception
    when OTHERS then
    L_ERRMSG := SQLERRM;
    insert into BADLOG ( TABLE_NAME, ERRM, data, ERROR_DATE )
    values ( P_TABLE,l_errmsg, l_lastLine ,systimestamp );
    end;
    end if;
    end loop;
    dbms_sql.close_cursor(l_theCursor);
    utl_file.fclose( l_input );
    commit;
    end if;
    insert into IMPORT_HIST (FILENAME,TABLE_NAME,NUM_OF_REC,IMPORT_DATE)
    values ( P_FILENAME, P_TABLE,l_rowCount,sysdate );
    UTL_FILE.FRENAME(
    P_DIR,
    P_FILENAME,
    P_DIR,
    REPLACE(P_FILENAME,
    ‘.txt’,
    ‘_’ || TO_CHAR(SYSDATE, ‘DD_MON_RRRR_HH24_MI_SS_AM’) || ‘.txt’
    commit;
    RETURN L_ROWCOUNT;
    end TABLE_LOAD;
    Note: when you run the function then it will also modify the source flat file with timestamp , so that we can have the track like which file was loaded .
    3) Check if the user is having UTL_FILE privileges or not :
    SQL> SELECT OWNER,
    OBJECT_TYPE
    FROM ALL_OBJECTS
    WHERE OBJECT_NAME = ‘UTL_FILE’
    AND OWNER =<>;
    If the user is not having the privileges then grant “UTL_FILE” to user from SYS user:
    SQL> GRANT EXECUTE ON UTL_FILE TO <>;
    4) In the function I have used two tables like:
    import_hist table and badlog table to track the history of the load and another to check the bad log if it occurs while doing the load .
    Under the same user create an error log table to log the error out records while doing the import:
    SQL> CREATE TABLE badlog
    errm VARCHAR2(4000),
    data VARCHAR2(4000) ,
    error_date TIMESTAMP
    Under the same user create Load history table to log the details of the file and tables that are imported with a track of records loaded:
    SQL> create table IMPORT_HIST
    FILENAME varchar2(200),
    TABLE_NAME varchar2(200),
    NUM_OF_REC number,
    IMPORT_DATE DATE
    5) Finally run the PLSQL block and check if it is loading properly or not if not then check the badlog:
    Execute the PLSQL block to import the data from the USER:
    SQL> declare
    P_TABLE varchar2(200):=<>;
    P_DIR varchar2(200):=<>;
    P_FILENAME VARCHAR2(200):=<>;
    v_Return NUMBER;
    BEGIN
    v_Return := TABLE_LOAD(
    P_TABLE => P_TABLE,
    P_DIR => P_DIR,
    P_FILENAME => P_FILENAME,
    P_IGNORE_HEADERLINES => P_IGNORE_HEADERLINES,
    P_DELIMITER => P_DELIMITER,
    P_OPTIONAL_ENCLOSED => P_OPTIONAL_ENCLOSED
    DBMS_OUTPUT.PUT_LINE(‘v_Return = ‘ || v_Return);
    end;
    6) Once the PLSQL block is been executed then check for any error log table and also the target table if the records are been successfully imported or not.

  • Problem inserting into tables

    Hello All, I hope that someone out there may be able to shed some light on my problem!!
    I have developed a series of JSP pages for my web site (using Tomcat 4.1)to allow a Customer to register themselves with the site. I have developed 3 corresponding JavaBeans to hold the details that the customer enters; a Customer bean, an Address bean and a Payment bean. In my database (MySQL) i have tables corresponding to each of these beans, which simply take the data inserted into a field by the user and create a new instance of each.
    Now, the above is all working fine and the database tables populate themselves exactly as they should; however, to allow a customer to add more than one address, or more than one payment method, I have developed the relationship tables 'hasaddress' and 'haspaymentdetails' to store the relevant id numbers in the database (i.e. hasaddress stores a customerid from the customer bean and an addressid from the address bean).
    Finally, i get round to my question!!..
    I am using the following jsp code to insert data into one such table:
    <------------------------------------------------------------------->
    <jsp:useBean id="registration" class="projectBeans.RegistrationBean" scope="session"/>
    //set the connection
    registration.setConnection(c);
    //retrieve the customer attribute
    projectBeans.Customer customer = (projectBeans.Customer)session.getAttribute("newCust");
    //retrieve the address attribute
    projectBeans.AddressBean address = (projectBeans.AddressBean)session.getAttribute("newAddr");
    //use the addCustomer method in the bean to create a new customer     
    registration.addCustomer(customer);
    //ditto for address
    registration.addAddressDetails(address);
    //populate the hasaddress table with the correct ids
    String table = "hasaddress";
    int customerid = customer.getCustomerId();
    int addressid = address.getAddressId();
    registration.updateRelationship(table, customerid, addressid);Both the addCustomer and addAddressDetail methods work fine, so below is just the code for updateRelationship method in the registrationBean:
    public void updateRelationship(String table, int id1, int id2) throws SQLException
       sta = c.prepareStatement("INSERT INTO "+table +" VALUES(?,?)");
       sta.setInt(1, id1);
       sta.setInt(2, id2);
       sta.executeUpdate();
    }I would expect this method to retrieve the newly assigned customer and address ids and enter them into the hasaddress table; however, when the page compiles and i look at the table it enters 0 for each of the fields (when it should, for example be entering 14 and 16):
    ----------+
    | cid | aid |
    ----------+
    | 0 | 0 |
    ----------+
    so my question is: does anyone have an idea as to why this is happening, or what may be wrong with my code for this to occur?
    Alternatively, am i being dumb and is there some way of getting MySql to handle the updates to the relationship table internally?
    Thanks in advance for any ideas,
    Cheers

    Try to specify you database field as SQL need field names to do updating
    sta = c.prepareStatement("INSERT INTO "+table + "("+ id1+","+id2+ ")"+ VALUES(?,?)");

  • How can one  read a Excel File and Upload into Table using Pl/SQL Code.

    How can one read a Excel File and Upload into Table using Pl/SQL Code.
    1. Excel File is on My PC.
    2. And I want to write a Stored Procedure or Package to do that.
    3. DataBase is on Other Server. Client-Server Environment.
    4. I am Using Toad or PlSql developer tool.

    If you would like to create a package/procedure in order to solve this problem consider using the UTL_FILE in built package, here are a few steps to get you going:
    1. Get your DBA to create directory object in oracle using the following command:
    create directory TEST_DIR as ‘directory_path’;
    Note: This directory is on the server.
    2. Grant read,write on directory directory_object_name to username;
    You can find out the directory_object_name value from dba_directories view if you are using the system user account.
    3. Logon as the user as mentioned above.
    Sample code read plain text file code, you can modify this code to suit your need (i.e. read a csv file)
    function getData(p_filename in varchar2,
    p_filepath in varchar2
    ) RETURN VARCHAR2 is
    input_file utl_file.file_type;
    --declare a buffer to read text data
    input_buffer varchar2(4000);
    begin
    --using the UTL_FILE in built package
    input_file := utl_file.fopen(p_filepath, p_filename, 'R');
    utl_file.get_line(input_file, input_buffer);
    --debug
    --dbms_output.put_line(input_buffer);
    utl_file.fclose(input_file);
    --return data
    return input_buffer;
    end;
    Hope this helps.

  • How to select data from a table using a date field in the where condition?

    How to select data from a table using a date field in the where condition?
    For eg:
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
                                                      and bdatu = '31129999'.
    thanks.

    Hi Ramesh,
    Specify the date format as YYYYMMDD in where condition.
    Dates are internally stored in SAP as YYYYMMDD only.
    Change your date format in WHERE condition as follows.
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
    and bdatu = <b>'99991231'.</b>
    I doubt check your data base table EQUK on this date for the existince of data.
    Otherwise, just change the conidition on BDATU like below to see all entries prior to this date.
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
    and <b> bdatu <= '99991231'.</b>
    Thanks,
    Vinay
    Thanks,
    Vinay

Maybe you are looking for

  • How do I delete an already existing apple id account on my iphone if i do not have the old password

    In my Settings>Itunes & Apps, my current Apple Id is stated and exists but in my Settings>Icloud, the Id is my previous Id which is a deactivated account and an unknown password. In order to delete this previous icloud account or change it to my curr

  • Install Leopard on a Macbook with Windows

    I recently purchased a used 2007 Macbook and it came with only one partition and Windows XP installed. I am new to the Mac world and unfamiliar with BootCamp. How would I go about partitioning and installing Leopard on this machine without killing th

  • Compare Date in where clause

    Hi, I have query which i used to display the new status that happend. Here in the where clause i am checking the dates for comparisiion but the query say no data found But data found in the table Please suggest how to put a join condition on dates. o

  • Object failed to run due to insufficient security privileges

    Recently migrated from BO XI and Crystal XI to bo 4.1sp2 and Crystal 2013.The recurring crystal reports were migared to new environemnt and schulded to run 1st of the month.There are 300+ reports.The report detail says all these reports are schduled

  • Need procedure -Load txt,csv,xls pdf file to db

    Could you please share me the procedure for loading the csv,xls,txt,pdf files into oracle database