Using collection list in subquery to restrict rows

How can I use a collection list in a subquery?
Something like this:
TYPE listOfIDs_t IS TABLE OF NUMBER;
v_listOfIDs_arr listOfIDs_t;
CURSOR c1 IS
SELECT *
FROM tbl
WHERE id IN (SELECT column_value
FROM TABLE ( CAST(v_listOfIDs_arr AS listOfIDs_t ))
When I try something like this, I get "invalid datatype" on the collection type, listOfIDs_t. Any suggestions? Basically, I want to use the list of values in my collection to restrict my cursor/query without having to loop through my collection and execute the cursor/query each time.

PL/SQL is two languages. PL is a programming language based on ADA. It is a formal procedural declarative language. It is "Turing complete". SQL is neither - not procedural and not Turing complete.
PL/SQL mashes these two in a single integrated coding environment - you can write and mix PL and SQL code and the PL engine will figure out where it needs to make calls to the SQL engine, what PL variables it need to pass to the SQL engine (using SQL bind variables) and so on.
Now you define a structure in the PL engine. The structure resides in the PL engine memory area (the process global area or PGA).
You now want to pass that structure to the SQL engine and run SQL on it. The SQL engine cannot reference that local PL variable directly. PL has to copy it into the SQL engine.. as what?
The SQL engine only supports SQL data types. The SQL engine does not know of the PL engine's existence. Just like it does not know about Java, C/C++, Delphi, C#, Visual Basic etc. Nor does the SQL engine support data types of these languages.
All these languages, including PL, supports the SQL engine in some form or another. Via ODBC, BDE, OCI, JDBC, etc.
Okay, now how does PL pass that local PL structure to the SQL engine? It cannot. That is a custom PL structure. It can contain (and often does) have features that are not supported by the SQL engine. Like boolean fields.
What PL can do and does support is SQL data types. Including user defined data types. And these it can use itself natively inside PL (as you also can as objects in Delphi, Java etc).
And these it can also pass back to the SQL engine for processing.
That all said - the best place for data is inside the SQL engine (i.e. in tables). It is not the best of ideas to create data structures in PL and then continually pass (copy) these to the SQL engine to run SQLs against. It is slow. It does not scale.
So make sure that you have sound technical reasons when actually doing this - creating a PL variable of a SQL table type, stuffing data into it, and then running SQLs on it.

Similar Messages

  • How to use vpd to restrict rows by application and schema_name?

    We have a need to reuse a schema name many times in a test/dev. environment. Normally we just create a new instance so development can test their apps. using the same schema_name, let's call it test_user. This is very tedious and time consuming to create many db's and sometimes we don't have the hardware to support so many db's. So I was wondering if I could use vpd and an application_context to restrict the rows & columns that can be seen. But instead of restricting it by schema_name I want to restrict it by schema_name and another env. variable like app_name or something similar. So when the middle layer connects with test_user user name and the app is called accts_payable they see parts of the rows that pertain to them. But if the middle layer connects with the test_user user name and the app is called accts_payable2 they see completely different rows. Any help would be appreciated.
    Thanks,
    George

    I was hoping someone else had already been down this path so I don't have to re-invent the wheel. But it looks like I'm going to go down that path. I did find something in the manual that may help but again it's not exactly what I was hoping for so I will have to test it. It mentions using dbms_session to set the application name in the environment like this:
    Consider the application server, AppSvr, that has assigned the client identifier 12345 to client SCOTT. It then issues the following statement to indicate that, for this client identifier, there is an application context called RESPONSIBILITY with a value of 13 in the HR namespace.
    DBMS_SESSION.SET_CONTEXT( 'HR', 'RESPONSIBILITY' , '13', 'SCOTT', '12345' );
    Thanks for your help on this. If anyone else has been through a similar situation please reply.
    Thanks,
    George

  • Subquery returns 0 rows-----HELP

    I need to understand something.
    please follow my points:-
    1-If we try to make a NOT IN condition, and one value is NULL, the main query return no result, because the NOT IN condition evaluates to FALSE "NULL" "UNKNOWN".
    example:-
    SELECT 'True' FROM employees
    WHERE department_id NOT IN (10, 20, NULL);
    this query returns no rows, simply because the condition is parsed like this
    department_id != 10 AND department_id != 20 AND department_id != null
    ^^^I have no question regarding this point and it is quite obvious.
    2-If the subquery returns 0 rows, then the value of the scalar subquery expression is NULL.
    example:-
    create table subq_null_test
    num number(4),
    val varchar2(7)
    insert into subq_null_test
    values (1,'one');
    insert into subq_null_test
    values (2, (select 'two' from dual where 2=1));
    insert into subq_null_test
    values (3, 'three');
    commit;
    and by
    select * from subq_null_test;
    we would see a NULL inserted as value for number 2
    NUM VAL
    1     one
    2     (null)
    3     three
    so far so good, indeed the 0 row subquery returned NULL
    ^^^Also I CAN'T have a point here.
    ============================================
    but lets look at these 3 queries
    -------->FIRST
    select department_id, last_name
    from employees
    where department_id not in (10,20,null)
    /*no rows selected*/
    --------->SECOND
    select department_id, last_name
    from employees
    where department_id not in (10,20,(select 10 from dual where 2=1))
    /*no rows selected*/
    -------->THIRD
    select department_id, last_name
    from employees
    where department_id not in (select 10 from dual where 2=1)
    /*ROWS returned*/
    my question is:-
    WHY FIRST and SECOND queries behaved as expected, while the THIRD didn't ???
    -I had a look at the execution plan, and it didn't helped me "am a beginner anyways"
    -I know its something related to the process or parsing the conditions, but am totally unable to locate it...
    Any help would be so much appreciated,
    Thanks for all.
    Ghazal.

    Hi again
    Yes; while I was writing my reply, you corrected it.Now it seems like you're making the same mistake again.I believe I had clarified it enough.
    Once again, I was only talking about the situation where department_id is NULL.Of course "x IN y" can be TRUE, FALSE or UNKNOWN, depending of what x and y are. All I was saying is that "NULL IN y" can be FALSE (depending on y), even though "NULL = q" is always UNKNOWN, regardless of what q is, and I find that a little inconsistent.-now we are on the same side "I hope :)...jk"...well yea we are talking about the department_id "left-hand" operand is NULL.
    -Regarding YOUR point, I can't agree with you Sir.
    I see it pretty much consistent that when the left-hand operand is NULL,,,it is always UNKNOWN even if the right-side operand is a null.
    I would even go further and say if there is a using of word "regardless", it wold be like this
    if the left-hand operand is NULL the condition evaluates to UNKNOWN no matter what is in the right-hand operand REGARDLESS what condition we are using IN or NOT IN.
    so
    "x IN y" can be TRUE, FALSE or UNKNOWN, depending of what x and y are. All I was saying is that so far so good
    "NULL IN y" can be FALSE (depending on y), even thoughNo, it is ALWAYS UNKNOWN 'you can call is FALSE'.
    "NULL = q" is always UNKNOWN, regardless of what q is, and I find that a little inconsistent.I find it okay.
    -"NULL = q" is always UNKNOWN regardless of what q is, is perfect and consistent indeed.
    -"NULL in (q, p, d)" is always UNKNOWN.
    -"NULL NOT in (q, p, d)" is always UNKNOWN.
    I would again dare and go further and say
    -whenever we have NULL on the left-hand operand
    result of the condition is only 2 cases and can never be 3
    1-UNKNOWN :- if we use "=, !=, IN, NOT IN, or anything may exists"
    2-TRUE :- if we use "IS"
    -this case of NULL as our left-hand operand can never have a FALSE case...
    ORACLE does do this for us by her own, and thanks ORACLE for that...alot.
    select 'BANG' from dual where null is null;
    select 'BANG' from dual where (select department_id from employees where last_name = 'kokolala') in (10,20, null);
    select 'BANG' from dual where (select department_id from employees where last_name = 'kokolala') is null ;This all is perfect, consistent, logical and cute.
    Solomon Yakobson : Think about the dirrerence between empty list and list containing a null element.This is cool, correct. this is the actual solution to the matter of having a null in our right-hand operand "BY JUST IGNORING THE NULLS, and is the list have only nulls it becomes an empty list", but in our case we do NOT have an EMPTY list, we have a list with a NULL indeed.
    -ORACLE just under the hood did us a favor of giving us an EMPTY list by ignoring the nulls using "LNNVL", which is doing no good..let him experience it, let him taste it, let him avoid it, him him him design it. and do not give me an inconsistent mechanism. it is good to sell that ORACLE is treating results as lists but that shouldn't intervene with our system-level language, am boooring guy, if its designed to work like this, no am sorry it should be stopped now.
    My point is
    -This theory is great regarding the matter when we are talking about dealing with our result as a LIST of elements, we would take in consideration our NULL values, which what SHOULD be implemented by the coder.
    -BUT the issue of oracle implements "LNNVL" while parsing our codes INCASE and ONLY in the case of subquery as our right-hand operand, I am not buying it and i see it inconsistent.
    They should implements it in all cases, or not at all "not even in one case as an exception", this is logic and it cant be divided or argued.Am still hoping someone have an explanation to the matter, I wouldn't like it at all to know that am 100% correct in my analysis of this case, because if I am I would like to see them changing it.
    Edited by: Ghazal-OCA on Jan 8, 2013 7:04 AM
    Edited by: Ghazal-OCA on Jan 8, 2013 7:10 AM
    Edited by: Ghazal-OCA on Jan 8, 2013 7:19 AM
    Edited by: Ghazal-OCA on Jan 8, 2013 7:20 AM
    Edited by: Ghazal-OCA on Jan 8, 2013 7:23 AM

  • Error in TCode S_ALR_87013431 "Confirmation Using Operation List" selection

    Hello Experts,
    I think I have encountered an error in the functionality of the S_ALR_87013431 "Confirmation Using Operation List" in ECC 6.0.
    When I select the "collective time confirmation" checkbox, the intended functionality is (form the transaction help) "If you select this field, the report program enters the selection result directly in the collective entry screen, without previously displaying a list of results from which you can reselect."
    However, if I check the box, the results still don't appear directly in the collective entry screen, but still as a list of results.
    Is there some configuration missing? Have you encountered a similar error?
    Thanks!
    Andreas

    hi
    i think there is some problem with the transaction ,in easy access menu it is displayed as S_ALR_87013431 confirmation with operation selection.
    i think same screen it has incorporated
    you can use IW48 which fullfil your requirement
    regards
    thyagarajan

  • Using a Infoobject (fiscweek) in columns and rows

    Hi SDN,
    We have a requirement where Zfiscweek of type NUMC to be shown in columns so I have restricted it with a char variable (user entry, and gave a offset value range as 52 weeks) i.e, if a user enters particular week then the O/P must have 52 weeks,
    And
    one row showing past 8 weeks of quantity (basic key figure)
    and another row showing 18 weeks in future (including that week which we have entered).Now after putting the Zfiscweek in columns when I try to restrict row (quantity ) the system is not allowing me to do so. but if I remove the Zfiscweek from columns the design goes wrong. would please give your opinion on this.
    THank you,
    Prasad

    Use structure in rows.
    It should have selction as follows:
    1. Prior 8 weeks
    2. Next 16 weeks
    Use offset settings on value ranges on variable to get those ranges (-8 and +16)..
    Add fisc week in colums.
    Since you don't want to show next 16 weeks in first row, use cell referencing to suppress the display if required.
    Abhijeet

  • Displayed Properties in Collection List Renderer are not displayed

    Hello All,
    I have created one custom property and entered the value for a resource which had that property.
    Now, when I am trying to display the custom property in any layout, its not coming, even though I have added the property name in the Displayed Property of the collection list renderer.
    To check the view is taking the correct layout or not, i changed some other settings of the collection list renderer and the changes are immediately getting reflected. What could be the problem here?
    Any help, deeply appreciated
    Regards
    BP

    Hello Bobu,
    Are you using a different Namespace Alias other than 'Default' in your property definition? If so then you need to specify the property in the 'Displayed Properties' parameter of the collection renderer as <NamespaceAlias>:<propetrty ID>, e.g. rnd:displayname.
    Other than that you should check the 'Folder Validity Patterns' and 'Document Validity Patterns' to make sure they are valid for the content on which you are trying to display this property, you may have already checked this.
    Regards,
    Lorcan.

  • Adding the results of subqueries, where one subquery returns no rows

    I am creating a complex SQL statement- many of the columns consist of the sum of two subqueries. Here is a simplified example:
    SELECT NAME, ID,
    (SELECT AMT1 FROM TABLE1 WHERE ID = 111) + (SELECT AMT2 FROM TABLE2 WHERE ID = 222),
    (SELECT AMT3 FROM TABLE3 WHERE ID = 333) + (SELECT AMT4 FROM TABLE4 WHERE ID = 444),
    FROM TABLE
    WHERE...
    The problem is, within one select item, if one subquery returns no rows and the other returns a row of data, the sum of the two is displayed as zero. For example, if 'SELECT AMT1 FROM TABLE1 WHERE ID = 111' returns a row, with a value of AMT1 = 1000, and 'SELECT AMT2 FROM TABLE2 WHERE ID = 222' returns no rows, the result is displayed as 0, not 1000. It reminds me of when you add a number and a NULL, and get NULL - the number gets ignored.
    Is there a way to embed some conditional logic in the subquery, to say 'if no rows returned, AMT = 0, else AMT = value'? Any help would be appreciated.

    Yikes, you appear to have stumbled upon DMFH!
    You can use NVL like this -
    SQL> select
      2    (select 1 from dual) + (select 2 from dual) x
      3  from dual;
             X
             3
    SQL> edi
    Wrote file afiedt.sql
      1  select
      2    (select 1 from dual) + (select 2 from dual where 0 = 1) x
      3* from dual
    SQL> /
             X
    SQL> edi
    Wrote file afiedt.sql
      1  select
      2    (select 1 from dual) + nvl((select 2 from dual where 0 = 1),0) x
      3* from dual
    SQL> /
             X
             1
    SQL>(DMFH = Data Model From Hell)

  • When subquery returns multiple rows

    I have a doubt in this case. I follow Oracle SQL by example book and I find that "<=" is used in this query.
    He says that when the subquery returns single row,,only then <=, >=, = should be used..
    Why did they not use ANY,ALL or SOME operators.....When I use ANY,ALL ,,,it gives me an error "Invalid Relational operator"...... Please help
    select c.description, s.section_no, c.cost, s.capacity
    from course c, section s
    where c.course_no=s.course_no
    and s.capacity <= (select avg(capacity) from section)
    and c.cost=(select min(cost) from course)

    Hi,
    user11090588 wrote:
    I have a doubt in this case. I follow Oracle SQL by example book and I find that "<=" is used in this query.
    He says that when the subquery returns single row,,only then <=, >=, = should be used..
    Why did they not use ANY,ALL or SOME operators.....If the sub-query returns no more than 1 row, then it doesn't matter which, if any, of the keywords ANY, ALL or SOME you use: they all give the same results. Only when there are 2 or more rows can it matter if you're doing the comparison to any, all or some of the rows.
    When I use ANY,ALL ,,,it gives me an error "Invalid Relational operator"...... Please help
    select c.description, s.section_no, c.cost, s.capacity
    from course c, section s
    where c.course_no=s.course_no
    and s.capacity <= (select avg(capacity) from section)
    and c.cost=(select min(cost) from course)If the problem occurs when you use ANY or ALL, why not post a query where you use ANY or ALL?
    Post a complete script that people can use to re-create the problem and test their ideas. That includes CREATE TABLE and INSERT statements for your tables (unless you can show the problem using commonly available tables, like those in the scott schema).
    Always say which version of Oracle you're using.
    I can't reproduce the problem. I don't get any error using ANY, ALL, SOME or nothing before either sub-query:
    SELECT     d.deptno
    ,     e.ename
    ,     e.sal
    FROM     scott.dept     d
    JOIN     scott.emp     e  ON     d.deptno     = e.deptno
    WHERE     e.sal  <= ANY (
                   SELECT  AVG (sal)
                   FROM     scott.emp
    AND     d.deptno = SOME (
                       SELECT  MIN (deptno)
                       FROM    scott.dept
    ;Output from the query above:
    `   DEPTNO ENAME             SAL
            10 MILLER           1300I'm using Oracle 10.2.0.1.0.
    Don't worry too much about ANY, ALL or SOME before sub-queries. I've never seen them used outside of a textbook (or questions like this, taken from a textbook). In real life, nobody uses them.
    Someone once showed me any example where one of these actually would be useful if you didn't have analytic functions, but I didn't note what it was, or where I saw it. Analytic functions were introduced in Oracle 8.1, so that's only of historical interest now.

  • Restricting rows in table control.

    I only want 4 rows in my table control but it is coming as a number of rows...I want to restrict row in my table control,Please tell me how do that?

    Hi priya
         I am sending the code which i used in my screen see weather it will suite you.if any doubts let me know as well this is for 10 lines
    MODULE COUNT_UPDATE INPUT.
      data cnt(10).
       DESCRIBE TABLE itab1 lines cnt.
    append itab1 TO ITAB2.
    LOOP AT itab2.
       IF itab2-srno is INITIAL.
         cnt = cnt + 1.
         CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
           EXPORTING
             INPUT         = cnt
          IMPORTING
            OUTPUT        = itab2-srno
        itab2-srno = cnt.
       ENDIF.
       READ TABLE itab1 WITH TABLE KEY srno = itab2-srno aufnr = itab2-aufnr." vbeln = itab2-vbeln.
       IF sy-subrc eq 0.
         MOVE-CORRESPONDING itab2 to itab1.
        MODIFY itab2.
        MOVE itab2[] to itab1[].
       else.
         MOVE-CORRESPONDING itab2 to itab1.
        append itab1.
       ENDIF.
    ENDLOOP.
    PERFORM operations.
    REFRESH CONTROL 'TCL' FROM SCREEN '1000'.*
    tcl-lines = 10.  " for 10 lines
    clear itab2.
    CLEAR itab2[].
    ENDLOOP.
    ENDMODULE.

  • Subquery Unnest Restrictions

    Whenever oracle make a hard parse ,will consider subquery unnest and view merge during query merge ,but what are subquery Unnesting Restrictions,when oracle can't make subquery unnest ???

    I am not sure that I understand the question.
    In general, Oracle cannot unnest a subquery if doing so would change (or would potentially change) the results. The classic example here is when the subquery contains something like the ROWNUM function or some sort of aggregate. If you have
    SELECT e.empno, d.deptno, d.rn
      FROM (SELECT deptno, dname, rownum rn
            FROM dept) d,
           emp e
    WHERE e.deptno = d.deptnothe subquery cannot be unnested because you only want the ROWNUM pseudocolumn evaluated for the rows in the subquery, not all the rows that the entire query would return.
    Justin

  • Using Collections

    HI EXPERTS
    i want to implement the below procedure using pl/sql collections can any one suggest for the followinG
    create or replace procedure test_proc
    is
    cursor c1 is select * from temp;
    cursor c1 is select * from MONITORING;
    i temp%rowtype;
    j MONITORING%type;
    begin
    open c1
    loop
    if (I.RES_CODE = '02' and i.CUST_ACCNO = j.CUST_ACCNO and i.CUST_MMID = j.CUST_MMID and i.CUST_MOBNO = j.CUST_MOBNO) then
    Insert into APP
    (CUST_ACCNO,CUST_MOBNO,CUST_MMID,REMARKS,RES_CODE)
    SELECT I.CUST_ACCNO,I.CUST_MOBNO,I.CUST_MMID,i.RES_CODE,'03'
    FROM temp I
    WHERE EXISTS (SELECT NULL FROM MONITORING M WHERE M.CUST_ACCNO = I.CUST_ACCNO AND M.CUST_MOBNO = I.CUST_MOBNO AND M.CUST_MMID = I.CUST_MMID)
    AND I.RES_CODE = '02';
    elsif (I.RES_CODE = '02' and (i.CUST_ACCNO != j.CUST_ACCNO or i.CUST_MMID != j.CUST_MMID or i.CUST_MOBNO != j.CUST_MOBNO)) then
    Insert into APP
    (CUST_ACCNO,CUST_MOBNO,CUST_MMID,REMARKS,RES_CODE)
    SELECT I.CUST_ACCNO,I.CUST_MOBNO,I.CUST_MMID,i.RES_CODE,'04'
    FROM temp I
    WHERE NOT EXISTS (SELECT NULL FROM MONITORING M WHERE M.CUST_ACCNO = I.CUST_ACCNO AND M.CUST_MOBNO = I.CUST_MOBNO AND M.CUST_MMID = I.CUST_MMID)
    AND I.RES_CODE = '02';
    elsif I.RES_CODE != '02' then
    Insert into APP
    (CUST_ACCNO,CUST_MOBNO,CUST_MMID,REMARKS,RES_CODE)
    SELECT I.CUST_ACCNO,I.CUST_MOBNO,I.CUST_MMID,i.RES_CODE,'02'
    FROM temp I
    WHERE I.RES_CODE != '02';
    exit whenc1
    end loop;
    close c1;
    end;
    /

    Didn't you have a discussion just yesterday about Re: Collections:?
    As was discussed in your previous thread, if the goal is to improve efficiency, it would be more efficient to get rid of the cursors and to just issue SQL statements to insert all the rows at once. Using collections may be an improvement over slow row-by-row processing but set-based processing will be even more efficient.
    In yesterdays thread, multiple people showed you how to use collections. Is there some specific problem/ question that you have? Presumably, the goal of you posting here is to learn how to use collections on your own, not to post all of your procedures one at a time and ask others to rewrite them using collections.
    The code you posted can't possibly compile. For example, you have two different declarations of the c1 cursor that query two completely different tables. There is an "exit whenc1" call that doesn't appear to match to any loop. Your code is also rather hard to follow since it is not formatted. If you put the tag \ (6 characteers all lower case) immediately before and after a code snippet, the forum will maintain all the spacing.  That makes the code much, much easier to read.
    Justin                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to use collections

    Hi
    i'm still quite the novice on APEX so bare with me.
    my problem is as follows:
    I have to develop a page for mass registration of sales, in APEX, and the client would like a tabular form with 20 empty rows in which the client can insert sales data.
    i'm developing on apex version 3.0.0.00.20 on a 10g Enterprise Edition Release 10.1.0.5.0 database.
    i've tried using collections for the job, but my problem is that i can't get the code to save any changes to the collection??
    i've created a on load before header process
    that creates a collection named SALGSBUFREG using apex_collection.create_collection_from_query where no rows are returned.
    the table i query is the table that the sales data eventually is inserted into.
    /** on-load before header process start */
    declare
    c_coll_name constant varchar2(100) := 'SALGSBUFREG';
    c_number_of_rows constant number := 20;
    begin
    if apex_collection.collection_exists(p_collection_name=>c_coll_name) then
    apex_collection.delete_collection(p_collection_name=>c_coll_name);
    end if;
    apex_collection.create_collection_from_query(
    p_collection_name=>c_coll_name,
    p_query=>'SELECT varenummer,
    antal,
    aip_omsaetning,
    apotekskode ,
    salgsdato,
    salgsperiode,
    dlibruger_id,
    salgsbatch_id,
    sygehuskode,
    afvist,
    indsat,
    updateret,
    registreringsdato
    FROM salgsbuffere
    WHERE 1 = 2');
    /** create c_number_of_rows empty rows*/
    for i in 1 .. c_number_of_rows
    loop
    apex_collection.add_member (p_collection_name => c_coll_name,
    p_c001 => ' ',
    p_c002 => ' ',
    p_c003 => ' ',
    p_c004 => ' ',
    p_c005 => null,
    p_c006 => ' ',
    p_c007 => ' ',
    p_c008 => ' ',
    p_c009 => ' ',
    p_c010 => ' ',
    p_c011 => ' ',
    p_c012 => ' ',
    p_c013 => null
    end loop;
    end;
    /** on-load before header process stop */
    i've created a report region called salgs_buf based on the following query:
    select c001, c002, c003, c004, c005, c006, c007, c008,c009,c010,c011, c012,c013
    from apex_collections
    where collection_name = 'SALGSBUFREG'
    i've made the report attributes c001 - c005 editable.
    finally i've made a on submit - after computations and validations process with the following content:
    declare
    c pls_integer := 0;
    c_coll_name constant varchar2(100) := 'SALGSREGBUF';
    begin
    for c1 in (
    select seq_id from apex_collections
    where collection_name = c_coll_name
    order by seq_id) loop
    c := c+1;
    apex_collection.update_member_attribute (p_collection_name=> c_coll_name,
    p_seq=> c1.seq_id,p_attr_number =>4,p_attr_value=>wwv_flow.g_f01(c));
    apex_collection.update_member_attribute (p_collection_name=> c_coll_name,
    p_seq=> c1.seq_id,p_attr_number =>5,p_attr_value=>wwv_flow.g_f02(c));
    apex_collection.update_member_attribute (p_collection_name=> c_coll_name,
    p_seq=> c1.seq_id,p_attr_number =>6,p_attr_value=>wwv_flow.g_f03(c));
    apex_collection.update_member_attribute (p_collection_name=> c_coll_name,
    p_seq=> c1.seq_id,p_attr_number =>7,p_attr_value=>wwv_flow.g_f04(c));
    end loop;
    end;
    For some reason the collection dosen't get updated????
    any idears why, or am I using the wrong apporach.

    first off thanks for your help.
    I seem to have cracked the nut so to speak, i'm just posting my solution
    I've changed the process so that exisisting collections aren't deleted.
    /** before header process start**/
    DECLARE
    c_coll_name CONSTANT VARCHAR2 (100) := 'SALGSBUFREG';
    c_number_of_rows CONSTANT NUMBER := 20;
    v_row_count_diff NUMBER;
    v_row_count NUMBER;
    BEGIN
    IF NOT apex_collection.collection_exists (c_coll_name)
    THEN
    apex_collection.create_collection_from_query
    (p_collection_name => c_coll_name,
    p_query => 'SELECT varenummer,
    antal,
    aip_omsaetning,
    apotekskode,
    salgsdato,
    salgsperiode,
    dlibruger_id,
    salgsbatch_id,
    sygehuskode,
    afvist,
    indsat,
    updateret,
    registreringsdato
    FROM salgsbuffere
    WHERE 1 = 2'
    -- create c_number_of_rows empty rows
    FOR i IN 1 .. c_number_of_rows
    LOOP
    apex_collection.add_member (p_collection_name => c_coll_name,
    p_c001 => ' ',
    /** vare nr*/
    p_c002 => ' ',
    /** antal */
    p_c003 => ' ',
    /** aip_omsaetning*/
    p_c004 => ' ',
    /** apotekskode */
    p_c005 => NULL,
    /** salgsdato*/
    p_c006 => ' ',
    /** salgsperiode */
    p_c007 => ' ',
    /** dlibruger_id*/
    p_c008 => ' ',
    /** salgsbatch_id*/
    p_c009 => ' ',
    /** sygehuskode*/
    p_c010 => ' ',
    /** afvist*/
    p_c011 => ' ',
    /** indsat*/
    p_c012 => ' ',
    /** updateret*/
    p_c013 => NULL
    /** registrerings dato*/
    END LOOP;
    -- the empty collection is set to unchanged
    apex_collection.reset_collection_changed (c_coll_name);
    END IF;
    END;
    /** before header process stop**/
    i've made a on submit and before computation process that populates the collection with the values that i input in the updatable rport region on my page, and it works just fine:
    /** on submit and before computation start**/
    /* Formatted on 2008/06/11 09:37 (Formatter Plus v4.8.8) */
    DECLARE
    c_coll_name CONSTANT VARCHAR2 (100) := 'SALGSBUFREG';
    c_row_count CONSTANT NUMBER := 20;
    v_member_count NUMBER;
    BEGIN
    IF apex_collection.collection_exists (c_coll_name)
    THEN
    FOR i IN 1 .. apex_collection.collection_member_count (c_coll_name)
    LOOP
    apex_collection.update_member_attribute
    (p_collection_name => c_coll_name,
    p_seq => i,
    p_attr_number => 1,
    p_attr_value => apex_application.g_f01
    (i)
    apex_collection.update_member_attribute
    (p_collection_name => c_coll_name,
    p_seq => i,
    p_attr_number => 2,
    p_attr_value => apex_application.g_f02
    (i)
    apex_collection.update_member_attribute
    (p_collection_name => c_coll_name,
    p_seq => i,
    p_attr_number => 3,
    p_attr_value => apex_application.g_f03
    (i)
    apex_collection.update_member_attribute
    (p_collection_name => c_coll_name,
    p_seq => i,
    p_attr_number => 4,
    p_attr_value => apex_application.g_f04
    (i)
    apex_collection.update_member_attribute
    (p_collection_name => c_coll_name,
    p_seq => i,
    p_attr_number => 5,
    p_attr_value => apex_application.g_f05
    (i)
    END LOOP;
    END IF;
    END;
    /** on submit and before computation start**/

  • Subquery with multiple rows

    i'm using the following select-query:
    select distinct a.ID,
    a.date,
    c.seg,
    a.critical,
    b.status,
    a.Lnr,
    (select pnr from vs_parts where vs = a.ID) as partnr,
    a.prob
    from VS a, VS_STATUS b, VS_Seg c, WE_B e
    where a.status_id = b.id
    and a.seg_id = d.VS_Seg_ID
    the problem is, that the subquery (select pnr from vs_parts where vs = a.ID) returns multiple rows, which i need and want to show in one cell in the report.
    but apex returns error: "ORA-01427: Subquery for one row returns more the one row" (Berichtsfehler: ORA-01427: Unterabfrage für eine Zeile liefert mehr als eine Zeile).
    How can i get these multiple rows from the subquery in one cell in the report?
    simison

    Simplest way is to write a function, then you can format the output however you want it as well.
    Pseudo:
    myFunc(theID)
    define strOutput varchar(2)
    select pnr from vs_parts where vs = theID
    for each row
    strOutput = strOutput + pnr
    loop
    return strOutput
    Message was edited by:
    BigPhil

  • How to know the the list of tables with no rows inside a schema?

    with reference to
    http://www.ss64.com/orad/USER_TABLES.html
    How to know the the list of tables with no rows inside a schema?
    I try this select table_name from user_tables where num_rows=0;
    I can found one table that is empty.
    So what's the query to return list of tables in a schema which has no rows?
    thanks

    You can do that only if your have collected the stats properly. Otherwise its going to show you wrong information.
    Check this out...
    SQL> drop table t
      2  /
    Table dropped.
    SQL> create table t
      2  as
      3  select level no from dual connect by level <=100
      4  /
    Table created.
    SQL> select table_name,num_rows from user_tables where table_name = 'T'
      2  /
    TABLE_NAME                       NUM_ROWS
    T
    SQL> begin
      2      dbms_stats.gather_table_stats(user,'T');
      3  end;
      4  /
    PL/SQL procedure successfully completed.
    SQL> select table_name,num_rows from user_tables where table_name = 'T'
      2  /
    TABLE_NAME                       NUM_ROWS
    T                                     100
    SQL>Thanks,
    Karthick.

  • Using collection fetch the employeeid

    Dear all,
    The below code can't fetch employee_id using collection. can you please tell me where i did wrong.
    DECLARE
    TYPE emp_table_type IS TABLE OF
    employees.employee_id%type;
    my_emp_table emp_table_type;
    BEGIN
    SELECT employee_id INTO my_emp_table FROM employees;
    FOR i IN 1..my_emp_table.count
    LOOP
    DBMS_OUTPUT.PUT_LINE(my_emp_table(i).employee_id);
    END LOOP;
    end;

    See the section 'Querying Data Into Collections of Records' in the PL/SQL doc
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/collections.htm#i36282
    Querying Data Into Collections of Records
    You can use the BULK COLLECT clause with a SELECT INTO or FETCH statement to retrieve a set of rows into a collection of records.
    That doc section shows you how to use BULK COLLECT when querying MULTIPLE values.
    You use INTO for single values. You use BULK COLLECT INTO for multiple values.

Maybe you are looking for

  • Target System in transport request is blank

    Hi I set the transport system in a scenario DEV, QAS and PRD. When I create an order request, the field target system is blank. Where should I set it for me automatically display the system QAS as a system target ? Thanks, Enrique

  • CD rom does not appear in boot menu in lenovo G500 windows 8

    Hello I want to format my lenovo G500 windows 8 and install windows 7 but I can't because the CD rom does not appear in the boot menu Solved! Go to Solution.

  • Tresury management urgent

    hi fico experts can u pls send me the fund management and invest management configuration steps it is very urgent regards Venkataswamy

  • How to get current Cell's Row & Col in a Dynamic Table??

    Hi all, I would to know if is possible, when I pass with a mouse over a specific cell's table (the table is created dynamically), to get the currents Row & Column. My target is to set a tooltip for any cell of that table that says to user the label o

  • I applaud you all NEVER to use BT!!!!!

    Please see below all of the problems i have faced in the last 7 months of being with BT.  Sub par internet for the last 5 months that cuts off around 4-5 times an hour (EVERY HOUR) that costs me £57 per month spending what must now be 7+ hours on the