Inserting multiple rows using a subquery getting ora error 0097 :Misssing )

Iam getting ora :0097 missing right parenthesis
insert into id_bfs_user_access_proj_racopy
(user_name, project_id)
((Select user_name from id_bfs_user_access_cc Where cost_center_id in (select cost_center_id from ID_COST_CENTER_GROUPS_V where cost_center_group = 'Engineering')), 3)
If i run below sql it is working fine can anyone help me in this
insert into id_bfs_user_access_proj_racopy
(user_name)
(Select user_name from id_bfs_user_access_cc Where cost_center_id in (select cost_center_id from ID_COST_CENTER_GROUPS_V where cost_center_group = 'Engineering'))

"how can it be valid since 3 is another column value and for user name we have to use entire sql"
Did you try it? It is perfectly valid to select a constant as part of a SELECT statement, which is what 516945's solution does.
SQL> CREATE TABLE t (id NUMBER, descr VARCHAR2(10));
Table created.
SQL> INSERT INTO t VALUES (1, 'One');
1 row created.
SQL> INSERT INTO t VALUES (2, 'Two');
1 row created.
SQL> COMMIT;
Commit complete.
SQL> SELECT id, descr, 'This is a constant string' const_str, 42 const_num
  2  FROM t;
        ID DESCR      CONST_STR                  CONST_NUM
         1 One        This is a constant string         42
         2 Two        This is a constant string         42John

Similar Messages

  • Inserting multiple rows using a single Insert statement without using dual

    Hi all,
    i am trying to insert multiple rows using a single insert statement like the below one.
    The below one works fine..
    But is there any other change that can be done in the below one without using dual...
    insert all
    into ps_hd_samp (num1,num2) values (1,1)
    into ps_hd_samp (num1,num2) values (2,2)
    into ps_hd_samp (num1,num2) values (3,3)
    select 1 from dual;

    NiranjanSe wrote:
    Hi all,
    i am trying to insert multiple rows using a single insert statement like the below one.
    The below one works fine..
    But is there any other change that can be done in the below one without using dual...
    insert all
    into ps_hd_samp (num1,num2) values (1,1)
    into ps_hd_samp (num1,num2) values (2,2)
    into ps_hd_samp (num1,num2) values (3,3)
    select 1 from dual;
    SQL> create table ps_hd_samp (num1 number,num2 number);
    Table created.
    SQL> insert all
      2  into ps_hd_samp (num1,num2) values (1,1)
      3  into ps_hd_samp (num1,num2) values (2,2)
      4  into ps_hd_samp (num1,num2) values (3,3)
      5  select count(*)
      6  from ps_hd_samp;
    3 rows created.
    SQL> select * from ps_hd_samp;
          NUM1       NUM2
             1          1
             2          2
             3          3

  • Insert multiple rows using Cursors.

    I am trying to insert rows into a table based on information from another table.
    For example:
    When Table 1: Num_Rows = 100 my proc will insert 100 rows into Table 2 with relevent data.
    Do I need to use a Cursor and iterate through Num_Rows doing an INSERT each time? Is there a better way to do it other than using Cursors?
    Rob.

    It is not about using cursors or not using cursors. All SQLs wind up as cursors in the Oracle Shared Pool. So there is no such concept as not using cursors. Oracle needs to parse and compile and execute SQLs as cursors.
    The issue is WHERE* you do the work?
    Do you use the cursor (SQL) to do it for you? Or do you pull the data into another language, like PL or Java and process it there?
    And the performance mantra in this case is a very fundemantal Maximize SQL and minimize PL/Java/etc+.
    So do not do in PL/SQL what you can do in SQL only. It is a lot slower to pull data from the SQL engine into the PL engine. And then push that very same data from the PL engine back to the SQL engine. Like the following for example:
    -- poor design, poor performance
    for employee in (select e.* from emp e where e.deptid = 123 )
    loop
      insert into tab2 values( employee.empid, employee.name );
    end loop;You do not need to use PL (or Java) in this case. The SQL language is more than able to do this better and faster than any other language... as it is closer to the data.
    So the following is far more optimal code. Instead of the above PL/SQL code, we can simply do it as:
    -- optimal design: maximizing SQL and letting it to as much of the work as possible
    insert into tab2 select e.empid, e.name from emp e where e.deptid = 123;

  • Insert multiple rows using sql at the same time

    I have searched a lot from the forum, but found nothing.
    There are two tables in oracle scheme: TableA(ID_A, column2,column3),
    TableB(ID_B, column2, column3); and TableA has multiply rows already, TableB is empty. TableB's ID_B has a
    Now I want to copy values from TableA.column2 and TableA.column3 to TableB.column2, TableB.column3.
    INSERT INTO SYSTEM_USER_GROUP (ID_user_group,ID_USER,ID_GROUP) values(((SELECT seq_system_user_group.NEXTVAL FROM DUAL),(SELECT U.ID_USER FROM SYSTEM_USER U),(SELECT U.ID_GROUP FROM SYSTEM_USER U)));
    ORA-00907: missing right parenthesis
    Any suggestion will be great appreciate!

    INSERT INTO SYSTEM_USER_GROUP (ID_user_group,ID_USER,ID_GROUP)
    (SELECT seq_system_user_group.NEXTVAL, ID_USER, ID_GROUP,
    FROM SYSTEM_USER)
    ORA-00936: missing expression
    ------------>>>
    I think that seq_system_user_group is a scheme level of oracle, so if you select it from a table, there will not work.
    Thank you all the same!
    Can i create that sequence as a column of one table? if that is the case, then my problem will be resolved.

  • Get ORA-32157 when dml on multiple rows using iterations

    I've used setMaxIterations() of oracle::occi::Statement to insert 50 rows successfully but sometimes throws exception: "ORA-32157: Infinity not supported". I don't know clauses. Please help me to fix it.

    Hi,
    I try test with Non Oracle Spatial no problem. But i inserted multiple rows include geometry value, this occurs errors "ORA-32157: Infinity not supported"
    According code:
    // I has table in Oracle Spatial 10g: PARCEL(ID, NAME, AREA, VARCANT, CREATEDDATE, SHAPE)
    //conn is instance of oracle::occi::Connection
    // ID: NUMBER(10,0):
    // NAME: VARCHAR(255)
    //AREA: NUMBER(20,8) // double
    //VACANT: VARCHAR(255);
    //CREATEDDATE: DATE
    // SHAPE: MDSYS.SDO_GEOMETRY
    conn ->OCCI_CreateStatement("INSERT INTO PARCEL(ID, NAME, AREA, VACANT, CREATEDDATE, SHAPE) VALUES (:1, :2, :3,:4, :5,:6)");
    oracle::occi::Statement* occi_stm=NULL;
    occi_stm->setMaxIterations(200);
    occi_stm->setMaxParamSize(2,255);
    occi_stm->setMaxParamSize(4,255);
    int count = 200;
    for(int i=0; i< count; i++)
    occi_stm->setInt(1, i+1);
    occi_stm->setString(2,"PARCEL");
    occi_stm->setDouble(3,100);
    occi_stm->setString(4,"FALSE");
    oracle::occi::Date val(conn ->GetOcciEnvironment(),2008,4,1,12,0,0);
    //set date = 01/04/2008 12:00:00
    occi_stm->setDate(5,val);
    //sdogeom is oracle::occi::PObject*. it stores shape data
    cci_stm->setObject(6,sdogeom);
    if (i<count-1)
    occi_stm->addIteration();
    int update_num = occi_stm->executeUpdate();
    conn ->OCCI_TerminateStatement(occi_stm);
    conn ->OCCI_Commit();
    //End code.
    Please help me. Thanks.

  • How to insert multiple rows in a single shot using insert command?

    Hi,
    If we insert one row, we can use "insert into" command. I want to insert multiple rows into the table in a single shot. Is there any SQL command for insert multiple rows into the table?
    Plese give the solution.
    Thanks,
    chelladurai

    If you would like to do it with SQL, this would be one of the ways to achive it:
    SQL*Plus: Release 10.2.0.4.0 - Production on Fri Sep 25 10:12:59 2009
    Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, Data Mining and Real Application Testing options
    SQL>
    SQL> desc leap
    Name                                      Null?    Type
    FIRST_PRICE                                        NUMBER(16,6)
    NEXT_PRICE                                         NUMBER(16,6)
    SQL>
    SQL> select * from leap;
    no rows selected
    SQL>
    SQL>
    SQL> !vi multirow_insert.sql
    SQL> !cat multirow_insert.sql
    insert into leap(first_price, next_price) values (1,2);
    insert into leap(first_price, next_price) values (3,4);
    insert into leap(first_price, next_price) values (5,6);
    SQL>
    SQL> @multirow_insert.sql
    1 row created.
    1 row created.
    1 row created.
    SQL> commit;
    Commit complete.
    SQL>
    SQL>
    SQL> select * from leap;
    FIRST_PRICE NEXT_PRICE
              1          2
              3          4
              5          6
    SQL>

  • Inserting Multiple Rows into Database Table using JDBC Adapter - Efficiency

    I need to insert multiple rows into a database table using the JDBC adapter (receiver).
    I understand the traditional way of repeating the statement multiple times, each having its <access> element. However, I am just wondering whether this might be performance-inefficient, as it might insert records one by one.
    Is there a way to ensure that the records are inserted into the table as a block, rather than record-by-record?

    Hi Bhavesh/Kanwaljit,
    If we have multiple ACCESS tags then what happens is that the connection to the database is made only once. But the data is inserted row by row.
    Why i am saying this?
    If we add the following in JDBC Adapter..logSQLStatement = true. Then incase of multiple inserts we can see that there are multiple
    <i>Insert into tablename(EMP_NAME,EMP_ID) VALUES('J','1000')
    Insert into tablename(EMP_NAME,EMP_ID) VALUES('J','2000')</i>
    Doesnt this mean that rows are inserted one by one?
    Correct me if i am wrong.
    This does not mean that the transaction is not guaranted. Either all the rows will be inserted or rolled back.
    Regards,
    Sumit

  • Inserting multiple rows into a table using a multiple-select list

    I'm trying to figure out how to take the output of a multiple-select list (":" separated list of values) and use that to update a table by inserting multiple rows based on the values. Is there a straight-forward way to do that in APEX?
    Thanks.
    Chris

    Hi Chris,
    I think this should give you what you need: Working with a Multiple Select List Item
    --Jennifer                                                                                                                                                                                                                                                                                                                                                                                                   

  • Inserting multiple rows into a table (using sequences)

    Hi!
    I want to insert multiple rows into a db table, but I don't know how.
    I know how to insert 1 row using a sequence:
    I put all the fields in the jsp form's page and in the submit page I put something like this:
    <jbo:Row id="myRow" datasource="ds" action="Update" rowkeyparam="MyRowKey" >
    <jbo:SetAttribute dataitem="*" />
    </jbo:Row>
    But how can I insert multiple rows like this:
    Id          Name
    1          ana
    2          monteiro
    3          maria
    Thanks!

    Hi Chris,
    I think this should give you what you need: Working with a Multiple Select List Item
    --Jennifer                                                                                                                                                                                                                                                                                                                                                                                                   

  • Want to insert multiple rows in table using EO

    Hi,
    I have one requirement where I need to insert multiple rows at once in table lets say Previous Employers.
    What I am trying to do is I have created few textinputboxes and getting there values and putting in HashMap.
    And manually inserting the rows to EO. I am not getting any error but the data is not populating in Table.
    here is the code snap ...please suggest!!
    public void updateKoelHrPreEmpVO(HashMap map)
    OADBTransaction txn = getOADBTransaction();
    //HashMap map = new HashMap();
    KoelHrPreEmpVOImpl empVO = getKoelHrPreEmpVO1();
    KoelHrPreEmpVORowImpl fetchedRow = null;
    int fetchedRowCount = empVO.getFetchedRowCount();
    RowSetIterator deleteIter = empVO.createRowSetIterator("deleteIter");
    if (fetchedRowCount > 0)
    if(txn.isLoggingEnabled(2))
    txn.writeDiagnostics(this,"Removing rows from KoelHrPreEmpVO :: Current count :: " + fetchedRowCount ,2);
    //System.out.println("Removing rows from KoelHrPreEmpVO :: Current count :: " +fetchedRowCount);
    deleteIter.setRangeStart(0);
    deleteIter.setRangeSize(fetchedRowCount-1);
    for (int i = 0; i < fetchedRowCount; i++)
    //System.out.println("Removing Row :: "+i);
    if(txn.isLoggingEnabled(2))
    txn.writeDiagnostics(this,"Removing row :: " + i ,2);
    fetchedRow = (KoelHrPreEmpVORowImpl)deleteIter.getRowAtRangeIndex(i);
    fetchedRow.remove();
    getTransaction().commit();
    deleteIter.closeRowSetIterator();
    if(empVO.getRowCount() == 0) {
    Row row = null;
    KoelHrPreEmpVORowImpl insertRow = null;
    empVO.first();
    if(txn.isLoggingEnabled(2))
    txn.writeDiagnostics(this,"Inserting rows to KoelHrPreEmpVO :: " ,2);
    try
    for(int i=1; i<=4; i++) {
    insertRow = (KoelHrPreEmpVORowImpl)empVO.createRow();
    insertRow.setEmployeeNumber(map.get("EmployeeNumber").toString());
    insertRow.setPersonId(new Number(map.get("PersonId").toString()));
    insertRow.setEmployer(map.get("Employer"+i+"").toString());
    insertRow.setStartDate(Date.toDate(map.get("StartDate"+i+"").toString()));
    insertRow.setEndDate(Date.toDate(map.get("EndDate"+i+"").toString()));
    insertRow.setEmployer(map.get("Designation"+i+"").toString());
    empVO.insertRow(insertRow);
    insertRow.setNewRowState(Row.STATUS_INITIALIZED);
    getTransaction().commit();
    catch(SQLException ex)
    ex.printStackTrace();
    Regards,
    Mukesh

    1. Pls check if the create() methos in EOImpl is in place, setting the primary key.
    2. Even though we insert values in this fashion , it only gets inserted if user performs any action, like manipulates some column. Pls check if there is any mechansm to make the row dirty ( as if done by user).
    Srikanth

  • To insert multiple rows by getting the values from the user

    Hi
    I want to insert multiple rows into a table using user given values dynamically.
    I am a beginner to PL/SQL. Below code is part of my big code. A_row_insert is 2 and A_count is 1 (initially). While i execute , it asks for input only once and insert the same data 2 times. I want to enter two different rows. Please guide/advise me on this.
    while (A_count<=A_row_insert) loop
    dbms_output.put_line('Enter the value  for the row#'||A_count||' of the table '||v_req_tab_name||':');
    begin
    INSERT INTO customers (
    customer# ,
    lastname ,
    firstname ,
    address ,
    city ,
    state ,
    referred ,
    region
    +)+
    VALUES
    +(+
    +&customer,+
    +'&lastname' ,+
    +'&firstname' ,+
    +'&address' ,+
    +'&city' ,+
    +'&state' ,+
    +&referred ,+
    +'&region'+
    +);+
    end;
    A_count := A_count 1;+
    end loop;
    regards
    Sakthivel

    hi,
    You need to write a procedure and call it from front end for n number of time..... check the parameters you need to pass to execute the procedure.... try given sample....
    CREATE OR REPLACE PROCEDURE InsertData(i_code IN VARCHAR2,i_code_desc IN VARCHAR2,i_code_type IN VARCHAR2)
    AS
    BEGIN
         INSERT INTO CODE_MASTER (code,code_desc,code_type)
    VALUES(i_code,i_code_desc,i_code_type);
    EXCEPTION WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE ( 'Error during Insert code - '||i_code );
    END;
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    exec InsertData('code1','desc1','type1');
    Thnx MB

  • Inserting multiples rows into a table using function or procedure..

    How do i insert multiples rows into a table using function or procedure?
    Please provide me query..

    Use FORALL bulk insert statement...
    eg:
    procedure generate_test_data as
    type cl_itab is table of integer index by pls_integer;
    v_cl_itab cl_itab;
    type cl_vtab is table of varchar2(25) index by pls_integer;
    v_cl_vtab cl_vtab;
    type cl_dtab is table of date index by pls_integer;
    v_cl_dtab cl_dtab;
    begin
    for i in 1.. 100 loop
              v_cl_itab(i):= dbms_random.value(1,1000);
              v_cl_vtab (i):=dbms_random.string('a',20);
              v_cl_dtab (i):=to_date(trunc(dbms_random.value(2453737, 2454101)),'j');          
         end loop;
         forall i in v_cl_itab.first .. v_cl_itab.last
              execute immediate 'insert into test_order values( :n, :str , :dt ) ' using v_cl_itab(i), v_cl_vtab (i), v_cl_dtab (i);          
         commit;
    end;

  • How to insert multiple rows in oracle forms when using TEMPLATE FORM

    I got a case study on PO creation nd in that I have to insert multiple rows in form especally when PO creation screen is there.
    I tried by different syntaxes but its not working.I need correct syntax to insert the multiple rows in to the table in oracle forms

    Please Oracle EBS queries on EBS forums.

  • How do I insert multiple rows from a single form ...

    How do I insert multiple rows from a single form?
    This form is organised by a table. (just as in an excel format)
    I have 20 items on a form each row item has five field
    +++++++++++ FORM AREA+++++++++++++++++++++++++++++++++++++++++++++++++++++
    +Product| qty In | Qty Out | Balance | Date +
    +------------------------------------------------------------------------+
    +Item1 | textbox1 | textbox2 | textbox3 | date +
    + |value = $qty_in1|value= &qty_out1|value=$balance1|value=$date1 +
    +------------------------------------------------------------------------+
    +Item 2 | textbox1 | textbox2 | textbox4 | date +
    + |value = $qty_in2|value= $qty_out1|value=$balance2|value=$date2 +
    +------------------------------------------------------------------------+
    + Item3 | textbox1 | textbox2 | textbox3 | date +
    +------------------------------------------------------------------------+
    + contd | | | +
    +------------------------------------------------------------------------+
    + item20| | | | +
    +------------------------------------------------------------------------+
    + + + SUBMIT + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Database Structure
    +++++++++++++++++
    + Stock_tabe +
    +---------------+
    + refid +
    +---------------+
    + item +
    +---------------+
    + Qty In +
    +---------------+
    + Qty Out +
    +---------------+
    + Balance +
    +---------------+
    + Date +
    +++++++++++++++++
    Let's say for example user have to the use the form to enter all 10 items or few like 5 on their stock form into 4 different textbox field each lines of your form, however these items go into a "Stock_table" under Single insert transaction query when submit button is pressed.
    Please anyone help me out, on how to get this concept started.

    Hello,
    I have a way to do this, but it would take some hand coding on your part. If you feel comfortable hand writing php code and doing manual database calls, specificaly database INSERT calls you should be fine.
    Create a custom form using the ADDT Custom Form Wizard that has all the rows and fields you need. This may take a bit if you are adding the ability for up to 20 rows, as per your diagram of the form area. The nice thing about using ADDT to create the form is that you can setup the form validation at the same time. Leave the last step in the Custom Form Wizard blank. You can add a custom database call here, but I would leave it blank.
    Next, under ADDT's Forms Server Behaviors, select Custom Trigger. At the Basic tab, you enter your custom php code that will be executed. Here you are going to want to put your code that will check if a value has been entered in the form and then do a database INSERT operation on the Stock_table with that row. The advanced tab lets you set the order of operations and the name of the Custom Trigger. By default, it is set to AFTER. This means that the Custom Trigger will get executed AFTER the form data is processed by the Custom Form Transaction.
    I usually just enter TEST into the "Basic" tab of the Custom Trigger. Then set my order of operations in the "Advanced" tab and close the Custom Trigger. Then I go to the code view for that page in Dreamweaver and find the Custom Trigger function and edit the code manually. It's much easier this way because the Custom Trigger wizard does not show you formatting on the code, and you don't have to keep opening the Wizard to edit and test your code.
    Your going to have to have the Custom Trigger fuction do a test on the submitted form data. If data is present, then INSERT into database. Here's a basic example of what you need to do:
    In your code view, the Custom Trigger will look something like this:
    function Trigger_Custom(&$tNG) {
    if($tNG->getColumnValue("Item_1")) {
    $item1 = $tNG->getColumnValue("Item_1");
    $textbox1_1 = $tNG->getColumnValue("Textbox_1");
    $textbox1_2 = $tNG->getColumnValue("Textbox_2");
    $textbox1_3 = $tNG->getColumnValue("Textbox_3");
    $date1 = $tNG->getColumnValue("Textbox_3");
    $queryAdd = "INSERT INTO Stock_table
    (item, Qty_In, Qty_Out, Balance, Date) VALUES($item1, $textbox1_1, $textbox1_2, $textbox1_3, $date1)"
    $result = mysql_query($queryAdd) or die(mysql_error());
    This code checks to see if the form input field named Item_1 is set. If so, then get the rest of the values for the first item and insert them into the database. You would need to do this for each row in your form. So the if you let the customer add 20 rows, you would need to check 20 times to see if the data is there or write the code so that it stops once it encounters an empty Item field. To exit a Custom Trigger, you can return NULL; and it will jump out of the function. You can also throw custom error message out of triggers, but this post is already way to long to get into that.
    $tNG->getColumnValue("Item_1") is used to retrieve the value that was set by the form input field named Item_1. This field is named by the Custom Form Wizard when you create your form. You can see what all the input filed names are by looking in the code view for something like:
    // Add columns
    $customTransaction->addColumn("Item_1", "STRING_TYPE", "POST", "Item_1");
    There will be one for each field you created with the Custom Form Wizard.
    Unfortunately, I don't have an easy way to do what you need. Maybe there is a way, but since none of the experts have responded, I thought I would point you in a direction. You should read all you can about Custom Triggers in the ADDT documentation/help pdf to give you more detailed information about how Custom Triggers work.
    Hope this helps.
    Shane

  • How to insert multiple rows in a single insert statement in MaxDB?

    hi,
    I was looking at syntax but i could not get it right.. may be some could help me.
    // Insert single row works fine
    INSET INTO test_table(column_name) values (value1) IGNORE DUPLICATES
    // Insert multiple rows, doesn't
    INSET INTO test_table(column_name) values (value1), (value2), (value3) IGNORE DUPLICATES
    Can somebody help me with this.
    thanks,
    sudhir.

    Multiple inserts do only work with parametrized statements, usually used in interfaces like JDBC, ODBC etc.
    With static SQL statements it is not possible.
    Regards Thomas

Maybe you are looking for

  • Damaged SSD, need to delete user folder - permission denied

    Hi everyone, this is my first post. I have installed SL onto my Kingston ssdnow v100 128GB solid-state drive (SSD) and used it as my primary OS drive along side of optibay in my first generation Macbook Pro Core Duo 2.0. It has been funcioning perfec

  • Not all Prefixes in VRF Tables are Reachable?

    Hello, During my studies with an MPLS VPN [MP-BGP] lab I found something unexpected.  I wonder if I am mistaken in my comprehension or if this normal: Not all prefixes in a VRF Table are pingable/reachable ? Seems that in the standard routing tables,

  • Can't import RAW files from Canon Powershot S50.

    iPhoto6 will not import RAW files from my Canon Powershot S50. It says the files are "unreadable". Image capture will import to the desktop, but neither iPhoto nor Photoshop Elements can open the file. I checked and the S50 is supposed to be compatib

  • 9_04 or 9_2 should I choose

    Hi All, Our company will start to use OWB to build a project. We have some experience about 9_04 and Oracle has 9_2 released. Shall we use 9_2 to do development for our Data Warehouse. Rd, CH

  • Retrieve Outlook lite recent recipient list

    Team, Am new to the OWA integration with Android. In our application we are using Global Address List search evertime. But in outlook OWA lite version, on a email compose there is a list that contains recent recipients. Is there any way to get the re