Error in RETURNING clause in INSERT.....SELECT query

Hi Friends
I am having an error: "SQL stmt not properly ended" when i run the below code.
Cant i fetch multiple values from the returning clause into a collection variable??
insert into consumption__C
     (SITECODE, SALESORG, PRODFAM,CAMPCODE, CYEAR, MDATE, SYSENV, MTYPE, ACCOUNT__C, SUPPLIER__C,
PRODUCT_PER_UNIT__C, PRODUCT__C, UNIT__C, AMOUNT_Y__C, VOLUME_Y__C, CURRENCY__C,SUPPLYMODE__C)
     select      ' '                    Sitecode,
                    ' '          Salesorg,
' '                    Prodfam,
                    ' '                    campcode,
                    ' '                    cyear,
                    pcurr_mig               MDATE,
                    psysenv                    SYSENV,
                    'NSet'                    MTYPE,                          
                    c.sitecode               Account__c,
                    ' '                    supplier__c,
                    ' '                    Product_per_unit__c,
                    c.material               Product__c,
                    ' '                    unit__c,
                    c.Amount           Amount_y__c,
                    ' '                    Volume__c,
                    'Euro'                    Currency__c,
                    ' '                    Supply_Mode__c
from load_sales_customer_site c     returning c.customer_code bulk collect INTO temp;
Kindly guide...... what is the problem!!
Thanks in advance

nice idea, but you can't use returning into with
insert as select:
SQL> select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
CORE    10.2.0.1.0      Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
SQL> create table exm(id primary key) as select object_id from all_objects
  2  where rownum <=100;
Table created.
SQL> declare
  2  type num_tbl is table of number;
  3   ll_num_tbl num_tbl;
  4   begin
  5   insert into exm(id)
  6  (select object_id * 100 from all_objects where rownum
  7   <=100) returning id into ll_num_tbl;
  8  end;
  9  /
<=100) returning id into ll_num_tbl;
ERROR at line 7:
ORA-06550: line 7, column 9:
PL/SQL: ORA-00933: SQL command not properly ended
ORA-06550: line 5, column 2:
PL/SQL: SQL Statement ignoredAmiel

Similar Messages

  • Error coming while running  Hibernate HQL  select query in jdeveloper

    Hi ,
    I have created hibernate application with just create query its running fine, i also writeen HQL select query below exception is coming,
    CharScanner; panic: ClassNotFoundException: org.hibernate.hql.ast.HqlToken
    i also checked org.hibernate.hql.ast.HqlToken , its thr in jar file, eventhough it is throwing error.
    plz give sollution

    Hi dvohra,
    I have written below code
    List l1=new ArrayList();
    try{
    HibClass hib = new HibClass();
    Session session = hib.currentSession();
    Transaction tx = session.beginTransaction();
    Manager m;
    System.out.println("server------------------------");
    //Using from Clause
    String SQL_QUERY ="from Manager manager";
    Query query = session.createQuery(SQL_QUERY);
    List list = query.list();
    for (int i = 0; i < list.size();
    i++) {
    Manager manager =
    (Manager) list.get(i);
    System.out.println(
    "MId " +
    manager.getMid() +
    " Manager Name: " +
    manager.getMname());
    m=new Manager();
    m.setMid(manager.getMid());
    m.setMname(manager.getMname());
    l1.add(m);
    session.close();
    }catch(Exception e){
    System.out.println("helo-------------error---------"+e.getMessage());
    }finally{
    return l1;
    still below exception is coming
    CharScanner; panic: ClassNotFoundException: org.hibernate.hql.ast.HqlToken
    oc4j is shutting down
    i am trying from 4 days , help me

  • How to capture all the rows returned from a sql select query in CPO

    Hi,
      I am executing an sql select query which returns multiple rows. I need to capture the values of each row to specific variables. How do I proceed.
    Thanks,
    Swati

    The select activities  ("Select from Oracle," Select from SQL Server," etc.) against database already return tables.  Use one of the database adapters to do your select, and it will already be in a table form.  Just put your query in the select and identify the columns in your result table. The online help or the database adapter guides in the product documentation can help.

  • Runtime error(Time limit exceeds)after executing select query

    Dear experts, whenever i executing the select query in this zprogram i am getting runtime error that time limit exceeds.i am using inner join and into table.after that also i am geetting error. how can i resolve it??
    SELECT LIKP~VBELN LIKP~WADAT_IST LIKP~VEHICLE_NO LIKP~TRNAME
              LIKP~VEHI_TYPE LIKP~LR_NO LIKP~ANZPK LIKP~W_BILL_NO
              LIKP~SEALNO1                                       " Seal NO1
              LIKP~SEALNO2                                       " Seal NO2
              LIPS~LFIMG
              VBRP~VBELN VBRP~VGBEL VBRP~MATNR VBRP~AUBEL VBRP~FKIMG
              VBAK~AUART
              VBRK~FKART VBRK~KNUMV VBRK~FKSTO
              FROM LIKP INNER JOIN LIPS ON LIKP~VBELN EQ LIPS~VBELN
                        INNER JOIN VBRP ON LIKP~VBELN EQ VBRP~VGBEL
                        INNER JOIN VBAK ON VBRP~AUBEL EQ VBAK~VBELN
                        INNER JOIN VBRK ON VBRP~VBELN EQ VBRK~VBELN
              INTO TABLE  I_FINAL_TEMP
              WHERE LIKP~VSTEL = '5100' AND
                 LIKP~WADAT_IST IN S_WADAT  AND
                    VBRP~AUBEL IN S_AUBEL AND
                    VBAK~AUART IN ('ZJOB','ZOR') AND
                    VBRK~FKART IN S_FKART AND
    *               VBRK~FKART IN ('ZF8','ZF2','ZS1') AND
                    VBRK~FKSTO NE 'X'.
    When I am debugging the select query.the cursor will not go to next step.after 15-20 minutes i am getting runtime error(time limit exceeds).
    how can i resolve it for that scenario??

    Looks like whole SD flow you trying to fetch in single query
    First you check the database statistic of these table are upto date in system ( Check with basis team )
    if this query was working fine earlier.
    Most of table involved are huge volume tables which queried with any primary key
    Any secondary index on created for LIKP on VSTEL WADET ?
    My suggestion would be split the selection queries and make use of primary or existing secondary index to fetch the desired result if possible. For testing purpose split the queries and find which is taking more time and which needs index by taking squel trace in ST05.
    Also take ST05 trace of this query in debugger ( New debugger -> special tool -> trace > ST05/SE30)

  • Error when included Order in Insert Select

    Dear oracle guru's
    I am working with Oracle 10g both forms and database . in one of my forms i try to insert values in a table from other table
    the code is
    insert into sstab(paramnam) select CP.Parameter_Object.Parameter_Name
    from Customer_Parameters cp
    order by cp_display_order;               
    earlier there was no order but to enhance further i added the order by command to the existing Insert-Select. But this threw an error while compiling the module itself .
    Encounterd the symbol ORDER when expecting one of the ,;...
    Kindly guide me in this regardd
    with warm regards
    ssr

    Hi,
    All DDL operations will automatically commit all the pending transaction.
    But in the care of FORMS_DDL, if you are running an insert or update statement, then the pending transactions won't commit. For that you have to pass a DDL statement through FORMS_DDL.
    If I am wrong, then please correct me.
    Regards,
    Manu.
    Edited by: Manu. on Jan 7, 2010 5:57 PM

  • Multiple values in where clause(IN) of select query in Cisco Cloud Portal using single field

    I can actually pass multiple values in the IN statement of select query using multiple dictionary fields in the data retrieval rule of the AFC in Cisco cloud portal like
    #dictionary.field1# = 1 and
    #dictionary.field2#=2
    select col1,col2 from table1 where col3 in (#dictionary.field1#,dictionary.field2#).
    but I want to pass mutiple values in a single field as
    #dictionary.field1#=1,2
    select col1,col2 from table1 where col3 in (#dictionary.field1#) and the query gives no data because it is taking as '1,2' instead of '1','2'.
    Please give the solution for passing multiple values in a single variable to use in IN operator of WHERE clause

    Ok, I now understand what you are trying to do. Unfortunately, you cannot inject parts of a SQL statement into a DDR through a dictionary field, which always represents a specific value (the comma in your case is attempting injection of a SQL construct to refer to multiple values). One possible solution is to arbitrarily consolidate your list of values using a delimiter that you know will not be in the values themselves such as a colon (:). Let's use 3 values as it serves as a better example.
    Set your dictionary field to a single reference to all 3 values of interest, say 'a', 'b', 'c' as:
    :a:b:c:  (you can use javascript to create this consolidated dictionary field)
    Now your query would look something like the following:
    select col1,col2 from table1 where #dictionary.field1t# like '%:'+col3+':%'
    This should achieve the desired result.

  • Can we use concatenate in where clause of a select query

    I have a select query as follows....
        SELECT ebeln ebelp belnr vgabe bwart DMBTR
                                 FROM ekbe
                                 INTO TABLE i_ekbe
                                 FOR ALL ENTRIES IN i_blck
                                 WHERE ebeln =  i_blck-ebeln AND ebelp =                                                                               
    i_blck-ebelp.
    Now i want to retrieve data from BKPF ..can i write a select query something like....
    select * from BKPF into itab
                FOR ALL ENTRIES IN i_ekbe
                where awkey = ( conatenate i_ekbe-belnr i_ekbe-gjahr )
    OR ELSE...is there any other way to link table ekbe and bseg ???

    Hi Poonam,
    SELECT ebeln ebelp belnr vgabe bwart DMBTR
    FROM ekbe
    INTO TABLE i_ekbe
    FOR ALL ENTRIES IN i_blck
    WHERE ebeln = i_blck-ebeln
    AND ebelp = i_blck-ebelp.
    select *
    from BKPF
    into  table itab
    FOR ALL ENTRIES IN i_ekbe
    where belnr = i_ekbe-belnr.
    If u want to check with AWKEY concatenate into seperate field and then use to check in where condition.
    data: lw_awkey(20) type c.
    CONCATENATE  i_ekbe-belnr  i_ekbe-gjahr  INTO lw_awkey.
    select *
    from BKPF
    into  table itab
    FOR ALL ENTRIES IN i_ekbe
    where awkey = lw_awkey
    Best regards,
    raam

  • OPEN CURSOR using a WITH clause in the select query

    Hi,
    I am using Oracle 9i. I have a requirement where I have a REFCURSOR as an OUT parameter for my procedure. I have declared the TYPE and created the procedure.
    In the procedure, I am using OPEN <cursor_name> FOR <query>;
    Ideally this works in most of the cases that I have tried earlier. However, in the current case I am using a WITH clause in my query to get the results.
    I need help in understanding if the above mentioned syntax would not allow me to use the WITH clause in the query.

    What error do you get , seems to work ok for me on 10g
    SQL> begin
      2  open :cv for 'with x as (select * from emp)  select * from x';
      3  end;
      4  /
    PL/SQL procedure successfully completed.
    SQL> print :cv
         EMPNO
    ENAME
    JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7521
    WARD
    SALESMAN        7698 22-FEB-81       1250        500         30
          7566
    JONES
    MANAGER         7839 02-APR-81       2975                    20
         EMPNO

  • How to improve on insert-select query performance

    Hi,
    Would like to get some opinion on how to improve this query inside my stored proc.
    This insert stmt has run more than 4 hours for inserting around 62k records.
    I have identified the bottleneck is in the function within the select stmt.
    Could anyone help to finetune?
    INSERT INTO STG_PRICE_OUT
    (     ONPN,
         EFFECTIVE_DT,
         PRICE_CATENAME,
         QUEUE_ID
    SELECT P.ONPN, P.EFFECTIVE_DT,
         gps_get_catename(P.PART_STATUS ,P.PROGRAM_CD ,P.MARKET_CD),
         '1'
    FROM      PRICE P,
         GPS_INV_ITEMS GII
    WHERE P.ONPN = GII.ONPN
    FUNCTION Gps_Get_Catename
         p_status      VARCHAR2,
         p_pgm           VARCHAR2,
         p_market      VARCHAR2
    RETURN VARCHAR2
    IS
         catename VARCHAR2(30);
    BEGIN
         SELECT PRICE_CATENAME
         INTO catename
         FROM PRICE_CATEGORY PC
         WHERE NVL(PC.PART_STATUS,' ')= NVL(p_status,' ')
         AND NVL(PC.PROGRAM_CD,' ') = NVL(p_pgm,' ')
         AND NVL(PC.MARKET_CD,' ') = NVL(p_market,' ')
         RETURN catename;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    RETURN NULL;
    WHEN OTHERS
    THEN
    DBMS_OUTPUT.PUT_LINE('gps_get_catename: Exception caught!! (' || SQLCODE || ') : ' || SQLERRM);
         RETURN catename;
    END;
    STG_PRICE_OUT has around 1 mil records
    GPS_INV_ITEMS has around 140K records
    PRICE has around 60k records
    INDEX:
    STG_PRICE_OUT - INDEX 1(ONPN), INDEX2(ONPN,QUEUE_ID)
    GPS_INV_ITEMS - INDEX 3(ONPN)
    PRICE - INDEX 4(ONPN)
    PRICE_CATEGORY - INDEX 5(PART_STATUS ,PROGRAM_CD ,MARKET_CD)
    Thanks and regards,
    WH

    Only use PL/SQL when you can't do it all in SQL...
    INSERT INTO STG_PRICE_OUT
    ( ONPN,
    EFFECTIVE_DT,
    PRICE_CATENAME,
    QUEUE_ID
    SELECT P.ONPN, P.EFFECTIVE_DT,
    PC.PRICE_CATENAME,
    '1'
    FROM PRICE_CATEGORY PC, PRICE P,
    GPS_INV_ITEMS GII
    WHERE P.ONPN = GII.ONPN
    AND PC.PART_STATUS(+) = P.PART_STATUS
    AND PC.PROGRAM_CD(+) = P.PROGRAM_CD
    AND PC.MARKET_CD(+) = P.MARKET_CD
    /Cheers, APC
    P.S. You may need to tweak the outer joins - I'm not quite sure what your business rule is.

  • Where clause priority in Select Query

    Hi All,
    I have one doubt, Pls clarify
    SELECT empno, ename, sal, comm
    FROM emp E, dept D -- (deptno is pk for DEPT)
    WHERE D.deptno = E.deptno
    AND E.sal >= 3000
    In WHERE clause which one will execute first (right to left or left to right
    OR[b] First join conditions then after filter conditions or vice versa)
    D.deptno = E.deptno
    OR
    E.sal >= 3000
    (this is the example tables)
    Because I have large volume of data with 5 tables with joins
    so, pls. kindly give me the sugession for where clause.
    Thanks
    Naresh

    It depends, the order the where clause is written in makes no difference to how the statement is processed.
    In the section on Developing Efficient SQL Statements in the Performance Tuning Guide changing the order of statements in the where clause is notably missing.
    There is more information in the Understanding Joins section of the same manual.

  • Desktop apps: Report Builder 3.0 (x86) that does not let me allow query result which I created Customers Report. Here is the error message returns.:

    Desktop apps: Report Builder 3.0 (x86) that does not let me allow query result which I created Customers Report. Here is the error message returns as following.
    Database query from: AdventureWorks2014
    System.Web.Services.Protocols.SoapException: The permissions granted to user 'SQLServer2014\Mubs' are insufficient for performing this operation. ---> Microsoft.ReportingServices.Diagnostics.Utilities.AccessDeniedException: The permissions granted to
    user 'mujb-HP\mujb' are insufficient for performing this operation.
       at Microsoft.ReportingServices.Library.ReportingService2010Impl.CreateReportEditSession(String Report, String Parent, Byte[] Definition, String& EditSessionID, Warning[]& Warnings)
       at Microsoft.ReportingServices.WebServer.ReportingService2010.CreateReportEditSession(String Report, String Parent, Byte[] Definition, String& EditSessionID, Warning[]& Warnings)
    The permissions granted to user 'mujb-HP\mujb' are insufficient for performing this operation.
    Is there anybody help me out, pl
    My MSSQL Server express 2014 edition x64  and My desktop "Report Builder (RB) 3.0' is 32bit (x86).
    Does Report Builder x64 exist? I didn't see anywhere so I downloaded x86 RB

    Hi mujb,
    Per my understanding you are using the report builder 3.0 to design the report and when you click the query designer button to execute the query you got the error message above, right?
    I have tested on my local envornment and your issue can be caused by the user "SQLServer2014\Mubs"  and "mujb-HP\mujb"  haven't grant permission to the report server or the shared dataeource/dataset if you have used this.
    I would like to confirm if you have assigned both the Item-Level and System-Level role of the user above to sucessfully access the report server, If you haven't grant any access to the above user and when you connect to the report server in the report builder,
    you may got the error message:
    More details information below for your reference:
    Please execute the query in the microsoft SQL Server Management Studio to see if you have permission to execute the query.
    If the query works fine in step1, please run the report builder as Administrator and if you are using the shared datasource/dataset the issue can be cause by the you haven't grant access the share datasource, Double click to open the Datasource
    and click the "Test Connection" as below to test if it can connect successfully:
    If the "Test Connection" failed, please click the shared datasource/dataset on Report Server to check if you have grant correct permission.
    Related information about the grant permission to report server for your reference:
    https://msdn.microsoft.com/en-us/library/ms156034.aspx
    http://www.allenkinsel.com/archive/2013/01/adventures-in-ssrs/
    If your issue still exists, please try to provide more details information.
    Regards,
    Vicky Liu
    Vicky Liu
    TechNet Community Support

  • Problem in the "select" query....Just check out and help me

    Hi there !!
    I am getting the following errors while trying to execute the "select" query from JSP page:
    java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state
    My code is :
    String reg_no=(String)session.getAttribute("reg_no");
    ResultSet rs=stmt.executeQuery("SELECT * FROM reg WHERE regno = "+reg_no);
    (Note: the "regno" in the database is of numeric datatype)
    Try to help me...
    Thanx,
    Ram.

    Just so everyone knows:
    Ram Mohan joined the forum on 7-Sep-2003 and received
    his 25 Dukes for joining.
    Since then, he's posted three questions, each one
    promising 5-10 Dukes, and never once awarded them.
    His strategy seems to be to wave Dukes, ask his
    hit-and-run question, and then bolt.
    Answer his questions if you wish, but don't do it
    expecting Dukes. - MODDuffy, you're getting just as cranky as I have. See what hanging around these forums does to oneself? :)

  • Dyanamic Select Query

    Hi,
    Can you pls guide me on the use of Dyanamic WHERE Clause in a Select Query?
    I came across the syntax:
    SELECT * FROM za004 INTO TABLE ia004 WHERE (options).
    Here Options is an internal table of type 'RFC_DB_OPT'
    But I am unable to fill this internal table correctly.
    Can some one pls guild me with sample code.
    Regards,
    Pankaj Bist.

    Check this :
      DATA: BEGIN OF lt_options OCCURS 10.
              INCLUDE STRUCTURE rfc_db_opt.
      DATA: END OF lt_options.
    CONCATENATE 'PERIV EQ ' '''' 'V8' '''' ' AND' INTO   " <-- PERIV is the field name
    lt_options-text.
    APPEND lt_options.
    CONCATENATE 'BDATJ EQ ' '''' l_pyear ''''  INTO
    lt_options-text.
    APPEND lt_options.
    Use lt_options in where condition.

  • May returning Clause be used w/ INSERT INTO...SELECT FROM

    Hi,
    I use Oracle 8i: 8.1.7.2.0.
    I'd like to insert multiple rows into a table, and get back certain inserted columns into a collection variable. Is this possible?
    Eg:
    INSERT INTO foo
    f1
    , f2
    SELECT b1, b2...
    FROM bar
    RETURNING f1 bulk collect into collection
    This compiles, but yields a "command not properly ended" error at runtime--I assume because the "returning" binds to the SELECT subquery, and not to the main INSERT query.
    Is there a way to do this?
    By the way, I already know this works when INSERTing just 1 row via the "values" clause.
    Regards,
    --IG                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi,
    Try this way:
    Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
    Connected as hr
    SQL>
    SQL> SET SERVEROUTPUT ON
    SQL> DECLARE
      2     TYPE emp_t IS TABLE OF VARCHAR2(30);
      3     emp_list emp_t;
      4 
      5     TYPE emp_t2 IS TABLE OF NUMBER;
      6     emp_code emp_t2;
      7  BEGIN
      8 
      9     emp_list := emp_t('John',
    10                       'Doe',
    11                       'Max');
    12 
    13     FORALL i IN emp_list.FIRST .. emp_list.LAST
    14        INSERT INTO emp
    15           (id,
    16            NAME)
    17        VALUES
    18           (employees_seq.NEXTVAL,
    19            emp_list(i))
    20        RETURNING id BULK COLLECT INTO emp_code;
    21 
    22     FOR i IN emp_code.FIRST .. emp_code.LAST LOOP
    23        dbms_output.put_line(emp_code(i));
    24     END LOOP;
    25  END;
    26  /
    213
    214
    215
    PL/SQL procedure successfully completed
    SQL> commit;
    Commit complete
    SQL> select * from emp;
            ID NAME
           213 John
           214 Doe
           215 Max
    SQL>Regards,
    Edited by: Walter Fernández on May 8, 2009 12:59 PM -- Adding query on emp table...

  • Error ORA-01652 while running select query

    A select query returning millions of records is returning the following error.
    SQL Error [
    ORA-01652: unable to extend temp segment by 128 in tablespace TEMP
    We requested DBA to increased the TEMP tablespace. He increased it to 20GB and also, changed to Autoextent.
    When we executed the query again, we got the same error ?
    What could be the reason of this issue and how it can be resolved ?

    All sort operations that don't fit into the SORT_AREA_SIZE will go to the temp tablespace (they can be seen as direct writes in the trace file).
    It can easy be the case, that your temp tablespace needs to be many GB in size [we have a table with millions of rows and for the loading/merging our temp is 80GB in size].
    May be you can change your process of loading i.e. with this select you fill a intermediate table (with CTAS) and do your processing there or even try to do the processing in SQL while building the table. You could also try to do the processing with a cursor and BULK COLLECT LIMIT 100 and then inserting into the target table with the FORALL statement.

Maybe you are looking for

  • Change in Standard VAT Report :  S_alr_87012385

    Dear All, In  VAT summary report - S_ALR_87012385 I need some additions and changes as listed below- 1. Document wise line level tax detail is displayed - need at document level 2. Vendor TIN number is not getting displayed in the standard VAT report

  • HT3209 high def vs standard def

    Just purchased a tv series in high def and it looks like it will take 11h per episode to download.  Would standard def be much faster, and would it be likely that the folks at the itunes store would change this for me?

  • RETRIVAL OF TIME DATA

    i have used logical data base pnp but in internal table zl it is not returning any data so output data is not displayng. can anybody help me in retriving the time data? plz see the code and let me know what i have to change so that i can retrive ZL T

  • MacBook Air osx 10.7.5  ...    iPhoto, does not recognize  my email or passwords...email working on all others

    I have iPhoto 9.4.3 version,  not letting me email from iPhotos  error ..email and password not recognized  tried  everything  that I know thank you   bobbie

  • Intenal table with out headerline

    hi, i have a doubt,please clarify. data:itab like <databse table> occurs 0 with header line. or data:itab like <databse table>occurs 0,         wa like line type of itab. in above two cases , in my view  no difference. in first case there will be one