PL/SQL array passed to SQL IN

Hi,
I have a PL/SQL array which type is defined like this:
create or replace type type_id_array as table of number(6, 3);
then i create a variable and initilaize:
var_1 type_id_array;
var_1 := .....
then i have a select statement.
select * from table t where t.id in(var_1)
That's it, i want to use the array in an SQL in. This seems not possible.
Can you explain why? Any alternate solutions?
Thanks

user610868 wrote:
That's it, i want to use the array in an SQL in. This seems not possible.
Can you explain why? Any alternate solutions?SQL supports set commands specifically for arrays (in addition to the using the TABLE() method mentioned). For example:
SQL> create or replace type TNumbers is table of number;
  2  /
Type created.
SQL>
SQL> declare
  2          numList TNumbers;
  3          cnt     integer;
  4  begin
  5          numList := new TNumbers(1,2,3,4,5,6,7);
  6          select
  7                  count(*) into cnt
  8          from    user_objects
  9          where   TNumbers(object_id) member of numList;
10          DBMS_OUTPUT.put_line( 'cnt='||cnt );
11  end;
12  /
cnt=0
PL/SQL procedure successfully completed.Obviously there are performance considerations when using arrays/collections in SQL. So before choosing a method, evaluate the performance.

Similar Messages

  • Error of passing of oracle.sql.ARRAY in PL/SQL function at work under OC4J

    Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)
    Error occured at working with DataSource based on com.evermind.sql.DriverManagerDataSource and oracle.jdbc.pool.OracleDataSource.
    Error:
    java.lang.AbstractMethodError: com.evermind.sql.OrclCMTConnection.physicalConnectionWithin()Loracle
    /jdbc/internal/OracleConnection;
    at oracle.sql.TypeDescriptor.setPhysicalConnectionOf(TypeDescriptor.java:660)
    at oracle.sql.TypeDescriptor.<init>(TypeDescriptor.java:212)
    at oracle.sql.ArrayDescriptor.<init>(ArrayDescriptor.java:376)
    at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:237)
    at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:192)
    at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:177)
    at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:114)
    What to do?
    Thank you.

    The issue is resolved by change classes12dms.jar for OC4J. The jdbc driver was changed from version (read from manifest):
    Manifest-Version: 1.0
    Specification-Title: Oracle JDBC driver classes for use with JDK12
    Created-By: 1.4.2_08 (Sun Microsystems Inc.)
    Implementation-Title: classes12dms_g.jar
    Specification-Vendor: Oracle Corporation
    Specification-Version: Oracle JDBC Driver version - "10.2.0.1.0"
    Implementation-Version: Oracle JDBC Driver version - "10.2.0.1.0"
    Implementation-Vendor: Oracle Corporation
    Implementation-Time: Wed Jun 22 19:11:35 2005
    to:
    Manifest-Version: 1.0
    Name: javax/sql/ConnectionEvent.class
    Digest-Algorithms: SHA MD5
    SHA-Digest: GQ5KFq39ybZzmgVThMOVSb6DDL8=
    MD5-Digest: uryrGtwsbgYBwoQDl0I85A==
    Name: javax/sql/ConnectionEventListener.class
    Digest-Algorithms: SHA MD5
    SHA-Digest: gh9/m94g05tRid8f4mhmEnJ5als=
    MD5-Digest: x63DZ5tPqdiCaLP0z1GHew==
    Probably the Oracle has compiled OC4J with other version of this library.

  • Evaluate Expression from PL/SQL without passing it SQL engine

    I have an expression similar to '1+2+(3*6)/12*ROUND(10*3, 3)' which I generate programatically in VARCHAR2 variable. One way to calculate the expression is execute immediate 'select '||exp||' from dual' into lv_x; which would return the value. But my shared pool is filling up as I do this thousands of times may more in some cases. I unsuccessfully tried to use bind variables.
    1. Is there a way to temporarily turn shared pool off before the query an enable it after executing the query?
    2. Is there a simple function in PL/SQL which evaluvates the expression? If not I may have to painfully write one.
    Please advice

    few additional coffee breaks to put together a functions version (not heavily tested)
    create or replace function evaluate_expression(p_expression in varchar2) return number is
      ret_val number;
      sep varchar2(1) := '|';
      operand_stack varchar2(4000) := sep;
      operator_stack varchar2(4000) := sep;
      function_stack varchar2(4000) := sep;
      w_expression varchar2(4000) := replace(p_expression,' ','');
      i pls_integer := 1;
      next_char varchar2(1);
      num_in boolean := false;
      opr_in boolean := false;
      fun_in boolean := false;
      top_function varchar2(100);
      top_operator varchar2(100);
      left_operand varchar2(100);
      right_operand varchar2(100);
      function pop_stack(p_stack in out varchar2) return varchar2 is
        ret_val varchar2(4000);
      begin
        ret_val := rtrim(substr(p_stack,instr(p_stack,sep,-1,2) + 1),sep);
        p_stack := substr(p_stack,1,instr(p_stack,ret_val||sep,-1,1) - 1);
    dbms_output.put_line('pop stack: '''||ret_val||''' = '||substr(p_stack,1,100));
        return ret_val;
      end;
      function peek_stack(p_stack in varchar2) return varchar2 is
        ret_val varchar2(4000);
      begin
        ret_val := substr(rtrim(p_stack,sep),instr(rtrim(p_stack,sep),sep,-1) + 1);
    dbms_output.put_line('peek stack = '''||ret_val||''' '||substr(p_stack,1,100));
        return ret_val;
      end;
      procedure push_stack(p_stack in out varchar2,p_item in varchar2) is
      begin
        p_stack := replace(p_stack || p_item || sep,sep || sep,sep);
    dbms_output.put_line('push stack: '''||p_item||''' = '||substr(p_stack,1,100));
      end;
      function is_empty(p_stack in varchar2) return boolean is
        ret_val boolean;
      begin
        if p_stack = sep then
          ret_val := true;
        else
          ret_val := false;
        end if;
        return ret_val;
      end;
      function precedence(p_operator in varchar2) return pls_integer is
        ret_val pls_integer;
      begin
        if p_operator in ('+','-') then
          ret_val := 1;
        elsif p_operator in ('*','/') then
          ret_val := 2;
        elsif p_operator in ('^') then
          ret_val := 3;
        elsif p_operator in ('(') then
          ret_val := 0;
        elsif p_operator in (')') then
          ret_val := 0;
        elsif p_operator in ('F') then
          ret_val := -1;
        else
          ret_val := 4;
        end if;
        return ret_val;
      end;
      function evaluate_operation(p_left in varchar2,p_right in varchar2,p_operator in varchar2) return number is
        ret_val number := to_number(null);
      begin
        if p_operator = '+' then
          ret_val := to_number(p_left) + to_number(p_right);
        elsif p_operator = '-' then
          ret_val := to_number(p_left) - to_number(p_right);
        elsif p_operator = '*' then
          ret_val := to_number(p_left) * to_number(p_right);
        elsif p_operator = '/' then
          ret_val := to_number(p_left) / to_number(p_right);
        elsif p_operator = '^' then
          ret_val := power(to_number(p_left),to_number(p_right));
        end if;
    dbms_output.put_line('evaluate operation: ('||p_left||')'||p_operator||'('||p_right||') = '||to_char(ret_val));
        return ret_val;
      end;
      function evaluate_function(p_function in varchar2) return number is
        ret_val number := to_number(null);
      begin
        if p_function = 'ROUND' then
          right_operand := pop_stack(operand_stack);
          left_operand := pop_stack(operand_stack);
          ret_val := round(to_number(left_operand),to_number(right_operand));
    dbms_output.put_line('evaluate function: round['||left_operand||';'||right_operand||']');
        elsif p_function = 'TRUNC' then
          right_operand := pop_stack(operand_stack);
          left_operand := pop_stack(operand_stack);
          ret_val := trunc(to_number(left_operand),to_number(right_operand));
    dbms_output.put_line('evaluate function: trunc['||left_operand||';'||right_operand||']');
        end if;
        return ret_val;
      end;
      procedure treat_operand(p_char in varchar2) is
      begin
        operand_stack := operand_stack || p_char;
      end;
      procedure treat_operator(p_char in varchar2) is
        done boolean := false;
        result number;
      begin
        if num_in then
          push_stack(operand_stack,'');
          num_in := false;
        end if;
        while not done loop
          if is_empty(operator_stack) or p_char = '(' then
            push_stack(operator_stack,p_char);
            done := true;
          else
            top_operator := peek_stack(operator_stack);
            if precedence(p_char) > precedence(top_operator) then
              push_stack(operator_stack,p_char);
              done := true;
            else
              top_operator := pop_stack(operator_stack);
              if top_operator = '(' then
                done := true;
              else
                right_operand := pop_stack(operand_stack);
                left_operand := pop_stack(operand_stack);
                result := evaluate_operation(left_operand,right_operand,top_operator);
                push_stack(operand_stack,to_char(result));
              end if;
            end if;
          end if;
        end loop;
      end;
      procedure treat_function(p_char in varchar2) is
        result number;
      begin
        if p_char = '[' then  -- function parameters in square brackets
          push_stack(function_stack,'');
          push_stack(operator_stack,'F');
        elsif p_char = ';' then  -- ';' function parameter separator (my decimal point is comma)
          push_stack(operand_stack,'');
          while peek_stack(operator_stack) != 'F' loop
            top_operator := pop_stack(operator_stack);
            right_operand := pop_stack(operand_stack);
            left_operand := pop_stack(operand_stack);
            ret_val := evaluate_operation(left_operand,right_operand,top_operator);
            push_stack(operand_stack,to_char(ret_val));
          end loop;
        elsif p_char = ']' then  -- function parameters in square brackets
          push_stack(operand_stack,'');
          while peek_stack(operator_stack) != 'F' loop
            top_operator := pop_stack(operator_stack);
            right_operand := pop_stack(operand_stack);
            left_operand := pop_stack(operand_stack);
            ret_val := evaluate_operation(left_operand,right_operand,top_operator);
            push_stack(operand_stack,to_char(ret_val));
          end loop;
          top_operator := pop_stack(operator_stack);
          top_function := pop_stack(function_stack);
          ret_val := evaluate_function(upper(top_function));
          push_stack(operand_stack,to_char(ret_val));
          while peek_stack(operator_stack) not in ('F','(') loop
            top_operator := pop_stack(operator_stack);
            right_operand := pop_stack(operand_stack);
            left_operand := pop_stack(operand_stack);
            ret_val := evaluate_operation(left_operand,right_operand,top_operator);
            push_stack(operand_stack,to_char(ret_val));
          end loop;
        else
          function_stack := function_stack || p_char;
        end if;
      end;
    begin
      if substr(w_expression,1,1) = '-' then
        w_expression := '0' || w_expression;
      elsif substr(w_expression,1,1) = '+' then
        w_expression := substr(w_expression,2);
      end if;
      w_expression := replace(replace(replace(w_expression,'(-','(0-'),'(+','('),'[-','[0-');
      while true loop
        next_char := substr(w_expression,i,1);
    dbms_output.put_line('loop next_char('||to_char(i)||') = '''||next_char||'''');
        exit when next_char is null;
        if next_char in ('0','1','2','3','4','5','6','7','8','9',',') then -- ',' = decimal point
          treat_operand(next_char);
          num_in := true;
        elsif next_char in ('+','-','*','/','^','(',')') then
          treat_operator(next_char);
          if not fun_in then
            opr_in := true;
          end if;
        else
          treat_function(next_char);
          fun_in := true;
        end if;
        i := i + 1;
      end loop;
      push_stack(operand_stack,'');
      while not is_empty(operator_stack) loop
        top_operator := pop_stack(operator_stack);
        if top_operator = 'F' then
          top_function := pop_stack(function_stack);
          ret_val := evaluate_function(upper(top_function));
        else
          if top_operator != '(' then
            right_operand := pop_stack(operand_stack);
            left_operand := pop_stack(operand_stack);
            ret_val := evaluate_operation(left_operand,right_operand,top_operator);
          end if;
        end if;
        push_stack(operand_stack,to_char(ret_val));
      end loop;
      left_operand := pop_stack(operand_stack);
      ret_val := to_number(left_operand);
    dbms_output.put_line('operand_stack = '||substr(operand_stack,1,100));
    dbms_output.put_line('operator_stack = '||substr(operator_stack,1,100));
    dbms_output.put_line('function_stack = '||substr(function_stack,1,100));
    dbms_output.put_line(w_expression||' = '||to_char(ret_val));
      if is_empty(operand_stack) and is_empty(operator_stack) and is_empty(function_stack) then
        return ret_val;
      else
        return to_number(null);
      end if;
    end;Regards
    Etbin
    some comments added
    to keep it simple:
    - stacks are just strings (elements separated by pipes) on developing everything is revealed at first glance
    - function parameters are specified in square brackets separated by semicolons (comma is our decimal point)
    - dbms_output.put_line intentionally kept in place as on developing provided sufficient trace info
    Edited by: Etbin on 9.6.2009 21:07

  • Problem passing oracle.sql.ARRAY to Oracle

    I am having ClassCastException when I try to pass a oracle.sql.ARRAY to a Oracle Package.
    Here is my code:
    PreparedStatement stmt = null;
    String strArray[] = { "1,2,3,4,5" };
    ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor( "TEST_PAC_1.TEST_COLL_2", dbConnection );
    //encounter Exception on the line below.
    ARRAY array_to_pass = new ARRAY( descriptor, dbConnection, strArray );
    String queryStr = "begin TEST_PAC_1.TEST_PROC_2(?); end;";
    stmt = dbConnection.prepareStatement(queryStr);
    stmt.setArray( 1, array_to_pass );
    stmt.execute();
    I understand that oracle.sql.ARRAY has been replaced by weblogic.jdbc.vendor.oracle.OracleArray in Weblogic.
    MY QUESTION IS: HOW DO I INSERT MY STRING ARRAY INTO THE OracleArray and pass it to the plsql.
    Really frustrated searching through the forums for the whole day,
    Thanks,

    Try this if you are at weblogic 8.1:
    Connection con = getConnectionFromDataSource();
    Connection vendorConnection = ((WLConnection)con).getVendorConnection();
    // use direct oracle connection.
    ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor( "TEST_PAC_1.TEST_COLL_2", dbConnection );
    vendorConnection.close();
    Beware that you should be very careful as you are going to use a direct vendor
    connection.
    The better aproach is to pass the string array as a delimited string to your storad
    procedure and parse it in the SP - then you don't have to mess up with vendor-specific
    handling.
    Hope this helps.
    Regards,
    Slava Imeshev
    "Daddy Daddy" <[email protected]> wrote in message news:24349835.1097143668312.JavaMail.root@jserv5...
    I am having ClassCastException when I try to pass a oracle.sql.ARRAY to a Oracle Package.
    Here is my code:
    PreparedStatement stmt = null;
    String strArray[] = { "1,2,3,4,5" };
    ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor( "TEST_PAC_1.TEST_COLL_2", dbConnection );
    //encounter Exception on the line below.
    ARRAY array_to_pass = new ARRAY( descriptor, dbConnection, strArray );
    String queryStr = "begin TEST_PAC_1.TEST_PROC_2(?); end;";
    stmt = dbConnection.prepareStatement(queryStr);
    stmt.setArray( 1, array_to_pass );
    stmt.execute();
    I understand that oracle.sql.ARRAY has been replaced by weblogic.jdbc.vendor.oracle.OracleArray in Weblogic.
    MY QUESTION IS: HOW DO I INSERT MY STRING ARRAY INTO THE OracleArray and pass it to the plsql.
    Really frustrated searching through the forums for the whole day,
    Thanks,

  • How to bind arrays to PL/SQL stored procedure using OCI?

    Hi,
    We are having problems trying to bind arrays to PL/SQL stored procedure using OCI. Here is the situation:
    - We have a stored procedure called "GetVEPFindTasks" with the following interface:
    PROCEDURE GetVEPFindTasks (
    p_ErrorCode OUT NUMBER,
    p_ErrorMsg OUT VARCHAR2,
    p_RowCount OUT NUMBER,
    p_VEPFindTasks OUT t_VEPFindTaskRecordTable,
    p_MaxTask IN NUMBER);
    t_VEPFindTaskRecordTable is a record with the following entries:
    TYPE t_VEPFindTaskRecord IS RECORD (
    RTCID NUMBER,
    TransNum NUMBER,
    TransTimestamp VARCHAR2(20),
    Pathname1 image_data.pathname%TYPE,
    Pathname2 image_data.pathname%TYPE,
    Pathname3 image_data.pathname%TYPE,
    OperatorID operator.id%TYPE);
    - Now, we are trying to call the stored procedure from C++ using OCI (in UNIX). The call that we use are: OCIBindByName and OCIBindArrayOfStruct to bind the parameters to the corresponding buffers. We bind all parameters in the interface by name. Now, we do bind the record's individual item by name (RTCID, TransNum, etc.), and not as a record. I don't know if this is going to work. Then, we use the bind handles of the binded record items (only record items such as RTCID, TransNum, and NOT error_code which is not part of the record) to bind the arrays (using OCIBindArrayOfStruct).
    All of the parameters that are binded as arrays are OUTPUT parameters. The rest are either INPUT or INPUT/OUTPUT parameters. Now, when we try to execute, OCI returns with an error "Invalid number or types of arguments" (or something to that sort... the number was something like ORA-06550). Please help...
    Is there any sample on how to use the OCIBindArrayOfStruct with PL/SQL stored procedures? The sample provided from Oracle is only for a straight SQL statement.
    Thank's for all your help.
    ** Dannil Chan **

    As you said:
    You have to pass in an array for every field and deconstruct/construct the record in the procedure. There is no support for record type or an array of records. Can you give me a example? I'am very urgently need it.
    thanks
    email: [email protected]

  • Updating array data in sql database

    HI,
    Im facing problems in updating array data in SQL database.
    As of now, i am able to write an "insert" query and insert array data in an image datatype field. Im using image datatype because the array size is very big(around 80,000 x and y values).
    Althoug inserting data is easy im unable to write a query to update this data.
    Referring to the help of SQL server and Labview database connectivity toolkit, i came across a method of accessing image datatype....using textpointers, which are 16 bit binary values and using the WRITETEXT function instead of the UPDATE function.
    but the problem im facing is that ive to pass the array as a 2d string array in the query as a result the updated array is retrieved in the form of a string a
    nd not as an array. how do I get over this problem?

    Hi Pavitra,
    I'm not very clear on how you have inserted the data into your application, but I do know that when you call the UPDATETEXT or WRITETEXT function you use the TEXTPOINTERS to point to the first location of a 1d array. So, depending on how you've stored the data, you may have problems updating your data if you're looking at it as a 1d array instead of how you originally formatted it. If you are able to successfully access the data as a 1d array, you can use the database variant to data type vi and pass in a string array constant for the data type. This will convert the variant datatype into whatever you specify. You may have to index the row and column of the variant (you receive a 2d array of variant) first before you convert. If possible, can yo
    u provide some more detail and maybe some example code of how you perform the insert and plan to do the update? I can probably give you a better solution if I know how you are formatting the data. Thanks!
    Jeremy L.
    National Instruments
    Jeremy L.
    National Instruments

  • Can't we pass java.sql.Connection as parameter toDatum() method

    I am in mid of java 1.3 to 1.4 migration, now I am getting the below error.can't we pass java.sql.Connection as a param to toDatum(), but I did the same before for another module and it worked fine, now I am getting the error.
    any changes need to be done?
    [b]toDatum(oracle.jdbc.driver.OracleConnection,java.lang.String) in oracle.jpub.runtime.MutableArray cannot be applied to (java.sql.Connection,java.lang.String)
    return array.toDatum(c, SQL_NAME);
    ^
    1 error
    I changed to use
    import oracle.sql.ORAData;
    import oracle.sql.ORADataFactory;
    instead of
    import oracle.sql.CustomDatum;
    import oracle.sql.CustomDatumFactory;

    In general, it's bad practice to be that "open" with regards to parameters to methods, especially when using remote invocations. However, if you really, really, really, really need to - and I doubt you do - you can use Serializable for the type of parameter. But that's still inelegant and, well, raises all sorts of issues, starting with your design...

  • How to create oracle.sql.array

    I need to create an oracle.sql.array to pass in my custom objects array to the database. I know you can create it using the ArrayDescriptor class but the problem with that is the connection object is need.
    I am using the writeSql() method of the SQLData interface. I therefore dont have the connection object. Any ideas?

    haha
    you misunderstand. i have in my code:
    <code>
         // update the organisation
         public boolean setOrganisation(Organisation pOrg) {
              Organisation org = pOrg;
              OracleCallableStatement callStat = null;
              Connection conn = null;
              boolean OK = false;
              try {
                   conn = getConnection(getUserName());
                   pOrg.setConnection(conn);
                   callStat = (OracleCallableStatement) conn.prepareCall("{call p_cmt.update_organisation(?)}");
                   callStat.setObject(1, org);
                   callStat.execute();
                   OK = true;
              } catch (Exception e) {
                   logger.severe("error writing organisation with id " + org.getId() + ". " + e);
              } finally {
                   cleanUpConnections(conn, callStat);
              return OK;
    </code>
    This writes the object organisation to the database. Now in the class organisation i have the following method which is called automatically when writing the organisation object to the database:
    <code>
         public void writeSQL(SQLOutput p_stream) throws SQLException {
              p_stream.writeInt(id);
              p_stream.writeObject(country);
         if (finIndexArr == null)
              finIndexArr = new ListElement[0];
         ArrayDescriptor af = ArrayDescriptor.createDescriptor(
         ObjectMapper.elementList, conn);
         ARRAY arr = new ARRAY(af, conn, finIndexArr);          
              p_stream.writeArray(arr);
    </code>
    The problem is the last bit. To put the finIndexArr into an array i need the connection object. So i have to pass into the organisation object the connection object which seems unneccessary and pointless to me. I was just looking at an alternative way of creating the array without the need of the connection object. Since the setOrganisation() above has the connection to the database i dont see why i need to specify it in the array as well

  • ABAP/4 Open SQL array insert results in duplicate database records in SM58

    Hi Everyone,
    I am testing a file to idoc scenario in my Quality system. When I passed the input file, the mapping executed successfully and there are no entries in SMQ2 but still the idoc wasn't created in the ECC system. When I have checked in TRFC, I am getting the error  ABAP/4 Open SQL array insert results in duplicate database records for IDOC_INBOUND_AYNCHRONOUS function module. I thought this is a data issue and I have tested with a fresh data which was never used for testing in Quality but even then I am getting the same error.Kindly advise.
    Thanks,
    Laawanya

    use FM idoc_status_write_to_database to change the IDoc status from 03 to 30 and then  run WE14 or  RSEOUT00 to change the status back to 03
    resending idoc from status 03 ...is a data duplicatino issue on receiving side...why do u need to do that ?
    Use WE19 tcode to debug
    In we19
    1)U can choose your Idoc number in existing Idoc textbox
    2)Press execute
    3)u will display ur Idoc struct
    4)Dbl click on any field then u can modify its content
    5)PressStd Outbound Processing Btn to process modified Idoc
    Thats it

  • The ABAP/4 Open SQL array insert results in duplicate database records

    Hi,
    Iam getting following error :
    The ABAP/4 Open SQL array insert results in duplicate database records.
    Error in ABAP application program.
    The current ABAP program "SAPLV60U" had to be terminated because one of the
    statements could not be executed.
    This is probably due to an error in the ABAP program.
    " Information on where terminated
    The termination occurred in the ABAP program "SAPLV60U" in "VBUK_BEARBEITEN".
    The main program was "SAPMSSY4 ".
    The termination occurred in line 503 of the source code of the (Include)
    program "LV60UF0V"
    of the source code of program "LV60UF0V" (when calling the editor 5030).
    Processing was terminated because the exception "CX_SY_OPEN_SQL_DB" occurred in
    the
    procedure "VBUK_BEARBEITEN" "(FORM)" but was not handled locally, not declared
    in the
    RAISING clause of the procedure.
    The procedure is in the program "SAPLV60U ". Its source code starts in line 469
    of the (Include) program "LV60UF0V "."
    Please assist how to proceed further ..
    Many thanks
    Mujeeb.

    Sorry, THe correct note is 402221.
    Description from the note
    << Please do not post SAP notes - they are copyrighed material >>
    Edited by: Rob Burbank on Feb 22, 2009 3:46 PM

  • ABAP/4 Open SQL array insert results in duplicate databaserecordsfor pk13

    Hi Experts, when I am working with pk13n tranaction iam getting an error message stating that update was terminated by user. when i am checking with st22 it gives the following message. please give the solution , iam sending the code as well.
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_SY_OPEN_SQL_DB', was not caught
    in
    procedure "SAVE_DATA" "(FORM)", nor was it propagated by a RAISING clause.
    Since the caller of the procedure could not have anticipated that the
    exception would occur, the current program is terminated.
    The reason for the exception is:
    If you use an ABAP/4 Open SQL array insert to insert a record in
    the database and that record already exists with the same key,
    this results in a termination.
    (With an ABAP/4 Open SQL single record insert in the same error
    situation, processing does not terminate, but SY-SUBRC is set to 4.) please find the below code please give the solution for this error message.
    1 *eject
    2 *----
    3 *   Verbuchen der Daten                                           *
    4 *----
    5 FORM SAVE_DATA.
    6
    7   DATA: lf_menge LIKE ekpo-menge VALUE 0,                   "717464
    8         lf_netwr LIKE ekpo-netwr VALUE 0.
    9
    10 * Einteilungen löschen --> Array Delete aus Tabelle DEKET
    11   DESCRIBE TABLE DEKET LINES SY-TFILL.
    12   IF SY-TFILL GT 0.
    13     DELETE EKET FROM TABLE DEKET.
    14     IF SY-SUBRC NE 0.
    15       MESSAGE A865.
    16     ENDIF.
    17     EKET_DELETE = EKET_DELETE + SY-DBCNT.
    18     REFRESH: DEKET.
    19     CLEAR  : DEKET.
    20   ENDIF.
    21
    22 * Einteilungen hinzufügen --> Array Insert aus Tabelle IEKET
    23   DESCRIBE TABLE IEKET LINES SY-TFILL.
    24   IF SY-TFILL GT 0.
    >>     INSERT EKET FROM TABLE IEKET.
    26     IF SY-SUBRC NE 0.
    27       MESSAGE A864.
    28     ENDIF.
    29     EKET_INSERT = EKET_INSERT + SY-DBCNT.
    30     REFRESH: IEKET.
    31     CLEAR  : IEKET.
    32   ENDIF.
    33
    34 * Check whether the qty in EKPO-MENGE is correct: note 717464
    35   SELECT SUM( menge ) FROM eket INTO lf_menge
    36                       WHERE ebeln = ekpo-ebeln
    37                       AND   ebelp = ekpo-ebelp.
    38   IF sy-subrc = 0 AND ekpo-menge <> lf_menge.
    39     IF ekpo-ktmng <> 0.
    40       refe1 = ekpo-zwert * lf_menge / ekpo-ktmng.
    41     ELSE.
    42       refe1 = ekpo-zwert * lf_menge / 1000.
    43     ENDIF.
    44     IF refe1 > maxwert.

    Hi,
    Well I don't know why you have duplicates, this is a functionnal issue. But you get the dump due the the message number 864 that triggers the abend... Changing the message type to 'E', 'S' or 'I' will prevent the dump but I guess this message has a good reason to be
    Kr,
    Manu.

  • Problem Encountering in oracle.sql.ARRAY type

    Hi,
    i am using one stored procedure to get a set of records.
    i am getting it by mapping those things with java.sql.Array. And after that i am getting the values as ResultSet from that Array. The same thing is working fine in Windows platform. If i posted those thing into Unix - AIX, i am facing an ArrayIndexOutofBoundsException while getting ResultSet from oracle.sql.ARRAY class. I checked out ARRAY instance.it is not null. Both Application and Database are same except O.S.
    Can Anybody help me. I need it imm.
    Thanks in Advance
    Regards
    Eswaramoorthy.G

    Hi
    Did you ever figure out what the problem was with this? We have a client that is experiencing the same problem on AIX but we cannot reproduce using their database running under NT nor Sun. Any information would be appreciated. You can respond directly to [email protected]
    Thanks in adavance
    Rick DeMilia
    Sungard DataSystems

  • The ABAP/4 Open SQL array insert results in duplicate Record in database

    Hi All,
    I am trying to transfer 4 plants from R/3 to APO. The IM contains only these 4 plants. However a queue gets generated in APO saying 'The ABAP/4 Open SQL array insert results in duplicate record in database'. I checked for table /SAPAPO/LOC, /SAPAPO/LOCMAP & /SAPAPO/LOCT for duplicate entry but the entry is not found.
    Can anybody guide me how to resolve this issue?
    Thanks in advance
    Sandeep Patil

    Hi Sandeep,
              Now try to delete ur location before activating the IM again.
    Use the program /SAPAPO/DELETE_LOCATIONS to delete locations.
    Note :
    1. Set the deletion flag (in /SAPAPO/LOC : Location -> Deletion Flag)
    2. Remove all the dependencies (like transportation lane, Model ........ )
    Check now and let me know.
    Regards,
    Siva.
    null

  • Conversion of java Array to oracle SQL Array while calling Stored Procedure

    How java Array can be converted to oracle SQL array while calling Stored procedure with callable statement.
    i.e java Array ---> Sql Array in Oracle while setting the datatypes to callable statement arguments.

    Look at:
    http://forum.java.sun.com/thread.jsp?forum=48&thread=376735&tstart=0&trange=15
    Paul

  • What may be the cause of this error java.sql.SQLException: invalid sql type passed to callable statement in iplanet ussing JNDI

     

    Hi,
    The possibilities can be of various reasons, with the sql statements,
    xml descriptors, data sources, improper drivers anything. To crack down
    the solution, kindly let me know the error messages and what exactly are
    you trying to accomplish.
    Thanks & Regards
    Raj
    manimaran t wrote:
    what may be the cause of this error java.sql.SQLException: invalid sql
    type passed to callable statement in iplanet ussing JNDI
    Try our New Web Based Forum at http://softwareforum.sun.com
    Includes Access to our Product Knowledge Base!

Maybe you are looking for

  • Import failed with canon 6d footage after latest update

    After I updated to Final Cut X 10.0.8, I've been getting "Import Failed" messages during the import process when taking in footage from my Canon 6D The import process also seems to be going very slow (slower than usual) I've tried duplicating the SD

  • Creating cluster trying to remove disks.

    Hi I am going through the pain of trying to create a whole cloud environment using scvmm2012r2 so that it can then link in to the whole windows azure pack. I have created what I think is the whole fabric which has been very very painful. My question

  • Preview 5.0 - Case sensitive search

    Is it possible to do case sensitive search in Preview 5.0? I am searching a PDF file for a combination of capital letters but I get hundreds of results of the same letters inside words. Is there any "advanced find" in Preview? thanks!

  • MobileMe turn to iCloud where my ipod is ios 4.3

    i just bought a new ipod touch with ios 4.3 and i think i should install "find my ipod" apps. but they need a mobileMe account and i don't have one and mobileMe no longer accepting any new member cause it turns to icloud (and it's only compatible wit

  • Why is my mac discontecting from the wireless router

    My wifi disconnects for no reason, seems to be connected one minute then it disconnects.  The router is in the same room so the signal is strong and stable.  Phones etc connected to the router do not have this issue.