CREATE_COLLECTION_FROM_QUERY performannce

I'm using the following CREATE_COLLECTION_FROM_QUERY function to populate a query as this saves effort as the resultset is available for the user to work with.
PROCEDURE CREATE_COLLECTION_FROM_QUERY_B
Argument Name Type In/Out Default?
P_COLLECTION_NAME VARCHAR2 IN
P_QUERY VARCHAR2 IN
However, like execute immediate, can I use bind variables to improve performance or is this not possible for collections?
Phil

Hi Phil,
That's a great question and a great idea for an enhancement. But as it is today in APEX 3.0, the string passed in as argument P_QUERY cannot contain bind variables.
Joel

Similar Messages

  • Apex_collection.create_collection_from_query ---- ORA-01008

    I am creating a collection from a query and am having trouble referencing my page items in the query. I have already tried &My_ITEM. / V('My_ITEM') / :MY_ITEM with no success.
    Error Message recieved:
    ORA-20104: create_collection_from_query Error:ORA-20104: create_collection_from_query ExecErr:ORA-01008: not all variables bound
    Sample of my apex_collection query :
    BEGIN
    apex_collection.create_collection_from_query(
    p_collection_name => 'TEST',
    p_query => 'SELECT CASE
    WHEN d.visits = 0
    THEN 0
    ELSE ROUND (d.tot_usage / d.visits)
    END THHP
    FROM (SELECT SUM (CASE
    WHEN b.fac_produsage = 0
    THEN 0
    ELSE ROUND(d.fac_prodsize
    * (SELECT TO_NUMBER (piyc_codeval)
    FROM schema.table1 z
    WHERE table1_codetype = ''PRODUOM_CONV''
    AND z.table1_codedesc = ltrim(rtrim(d.fac_produom)))
    / d.fac_prod_useratio) * b.fac_produsage
    END ) tot_usage,
    MAX (b.fac_ptcaredays) visits,
    b.fac_datasdate || b.fac_dataedate period,
    a.fac_unitcode || a.fac_unitdesc area,
    d.fac_prodtype prodtype
    FROM schema.table2_facdata b,
    schema.table3_facusers c,
    schema.table4_facunits a,
    schema.table5_facprod d
    WHERE c.fac_id = b.fac_id
    AND b.facprod_id = d.facprod_id
    AND b.fac_id = d.fac_id
    AND a.fac_unitcode = b.fac_unitcode
    AND a.fac_id = b.fac_id
    AND b.fac_datasdate >= :P14_fac_datasdate -- page item
    AND b.fac_dataedate <= :P14_fac_datasdate -- page item2
    AND a.fac_unittype = :P14_fac_unittype -- page item3
    GROUP BY b.fac_datasdate || b.fac_dataedate,
    a.fac_unitcode , a.fac_unitdesc) d ',
    p_generate_md5 => 'YES');
    end;
    Any Suggestions??

    Working Solution:
    http://kr.forums.oracle.com/forums/thread.jspa?threadID=580016

  • Apex_collection.create_collection_from_query, dbms_Sql and ORA-29470 on 11g

    Hi there,
    I was very happy to know that you can pass a DBMS_SQL cursor to the procedure apex_collection.create_collection_from_query but my contentment lasted only until I actually tried it.
    I am using Apex 4.0.2.00.06 on DB 11.1.0.7.0 and when I tried to run a simple page based on it I got:
    ORA-20104: create_collection_from_query Error:
    ORA-20104: create_collection_from_query ExecErr:
    ORA-29470: Effective userid or roles are not the same as when cursor was parsedThis post explains the reason why:
    11g Security Error: wwv_flow_collection.create_collection_from_query_b
    As it is an old post which doesn't mention the Apex version, I was wondering if there have been any new workarounds for this issue?
    If not, does it mean that functionality is useless in 11g? What about people that for one reason or another has been using it (not my case fortunately)?
    Thanks
    Luis

    Luis,
    for your example in the other post it isn't necessary to use a cursor, but you can use a SQL Statement in a String like this
    APEX_COLLECTION.CREATE_COLLECTION_FROM_QUERY
      ( p_collection_name => 'MY_NEW_COLLECTION'
      , p_query      =>
    '    SELECT EXTRACTVALUE
                 ( VALUE(USERXML)
                 , ''/User/Mail''
                 , ''xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" ''
          FROM APEX_COLLECTIONS COLL
             , TABLE
                 ( XMLSEQUENCE
                     ( EXTRACT
                         ( XMLTYPE.createXML(CLOB001)
                         , ''/env:Envelope/env:Body/getUserInfo/User''
                         , ''xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" '
                 ) USERXML
         WHERE COLLECTION_NAME = 'MY_WS_COLL'
    ...brgds,
    Peter
    Blog: http://www.oracle-and-apex.com
    ApexLib: http://apexlib.oracleapex.info
    BuilderPlugin: http://builderplugin.oracleapex.info
    Work: http://www.click-click.at

  • Apex_collection.create_collection_from_query and ORA-00900 Invalid SQL

    I am very new to collections and I am having an issue creating my first collection.  When I execute the following code I get ORA-00900  invalid sql.
    apex_collection.create_collection_from_query ('TEST', 'select * from apex_collections', 'NO');
    Any guidance is greatly appreciated.  I am running Oracle 11g and APEX 4.1.0.00.32.

    Sorry bad example.  I have tried several tables.  One only had a few columns and just text and numbers.  This is the table I am trying to load into the collection.  It does not seem to matter what I put in as the sql, it always comes back invalid sql.
    My table looks like this.
    Name                 Null     Type         
    MATERIAL_ID                               NOT NULL NUMBER       
    MATERIAL_NAME                         NOT NULL VARCHAR2(75) 
    MATERIAL_DESCRIPTION                             VARCHAR2(500)
    CATEGORY_ID                             NOT NULL NUMBER       
    SUBCATEGORY_ID                                       NUMBER       
    QTY                                             NOT NULL NUMBER(2)    
    REQUESTED_QTY                                        NUMBER(2)    
    I have to be doing something really simple wrong.

  • APEX 2.2.1 upgrade - htmldb_collection.create_collection_from_query problem

    We have recently upgraded a production application from 1.6 to 2.2.1 and have found a problem creating a collection from a query in a before header process. The page no longer displays and we eventually get the standard http request failed message after over 60 seconds. I have traced this session and the process appears to hang after parsing then executing the cursor i.e. does not fetch the results.
    The SQL is based on a view that uses connect by prior and runs fine within SQL+ (under 1 second to return 63 rows). Other queries passed to the API appear to work fine whether they are based on tables and/or views. Have also tried changing the reference to apex_collection but still get the same issue.
    Have changed the shared_pool_size to 100M as recommended for the upgrade.
    Has anyone experienced a similar issue or can recommend a better/alternative method to achieve the following:
    if ( htmldb_collection.collection_exists( v_collection_name ) )
    then
    htmldb_collection.delete_collection( v_collection_name );
    else
    htmldb_collection.create_collection_from_query
    (p_collection_name => v_collection_name ,
    p_query => 'select distinct
    t.customer_id --1
    , t.fiscal_year --2
    , t.financial_header_id --3
    , t.financial_item_id --4
    , t.sequence --5
    , t.code --6
    , t.description --7
    , t.is_title --8
    , t.is_item --9
    , t.is_negative --10
    , t.is_hidden --11
    , t.connect_by_isleaf --12
    , null this_year_minus_0 --13
    , null this_year_minus_1 --14
    , null this_year_minus_2 --15
    from financial_statements t where ( t.is_hidden = 0 )');
    end if;
    Thanks, Ian

    Daniel,
    That API is meant to be used from within an application, from a page process, for example. So I would expect an error from where you are calling it. (Disregard browser language question.)
    When you said:
    Our production version are 2.0.0.00.49 because we have a 9.2 database.
    ...what do you mean? You can use any version of Application Express with 9.2.0.3 or higher database.
    Scott

  • Getting ORA-22922 with apex_collection.create_collection_from_query

    Hi,
    i'm getting ora-22922 nonexistent LOB value with
    apex_collection.create_collection_from_query('coll_name','select a,b,c from testtable','NO');
    what is going wrong?
    please help !!
    thx in advance !!!

    Hi Dila,
    unless you let us know what
    TESTTABLEexactly is, we probably can't help you.

  • Problem: apex_collection.create_collection_from_query

    Hi;
    I've the following procedure:declare
        p_collection_name varchar2(1000) := 'EDIT_CAT';
    begin
            IF (apex_collection.collection_exists(p_collection_name))
            THEN
                apex_collection.delete_collection(p_collection_name);
            END IF;
            apex_collection.create_collection_from_query(
                p_collection_name => p_collection_name,
                p_query => 'select * from hd_category');      
    end;I alsways get the fllowing error:
    ORA-20104: create_collection_from_query Error:ORA-20104: create_collection_from_query ParseErr:ORA-00942: table or view does not exist
    But the table 'HD_CATEGORY' exists and setting up a normal select statement is working fine.
    Dows anybody know what's wrong with this?
    Thanks for any help
    chrissy

    Hi Scott,
    Sorry for my error in the first thread ... it's no procedure it's a process ...
    My code is, like you suggested, an anonymus block and it is an application process on demand.
    What I'm trying to do is to build the collection every time a record will be in edit.
    What I don't understand is, why I have to grant the SELECT privileg for the table. I can make a select on it, but not for the collection. Also my application schema user has the dba role, isn't there SELECT privilege included? I'm not firm in such things.
    At the moment I got it running, with a cursor and the normal apex_collection.create_collection and apex_collection.add_member.
    Thanks
    chrissy

  • Regarding HTMLDB_COLLECTION.CREATE_COLLECTION_FROM_QUERY

    Hi,
    I try to create collection and I use this piece of code:
    HTMLDB_COLLECTION.CREATE_COLLECTION_FROM_QUERY(
    p_COLLECTION_NAME => 'COMMENTS_COLLECTION',
    p_QUERY => 'SELECT
    ed.severity "Severity",
    rownum "Number",
    ed.id
    from
    external_defect ed
    where ed.OBJ_ID=:P156_OBJ_ID
    and ed.pro_id = :P156_PRO_ID'
    But while running this query I am getting the following error.
    " create_collection_from_query Error:ORA-20104: create_collection_from_query ParseErr:ORA-00942: table or view does not exist) "
    But In SQLWORKSHOP I am able to run SELECT query for this table.
    Please help me regarding the same
    Thanks

    "user554934",
    This may not be completely obvious from the documentation, but I don't believe the bind variables in your query are being processed in create_collection_from_query. Can you try this via the v() function?
    As in:
    HTMLDB_COLLECTION.CREATE_COLLECTION_FROM_QUERY(
    p_COLLECTION_NAME => 'COMMENTS_COLLECTION',
    p_QUERY => 'SELECT
    ed.severity "Severity",
    rownum "Number",
    ed.id
    from
    external_defect ed
    where ed.OBJ_ID=v(''P156_OBJ_ID'')
    and ed.pro_id = v(''P156_PRO_ID'')'
    );Joel

  • Question about HTMLDB_COLLECTION.CREATE_COLLECTION_FROM_QUERY

    Actually 2 questions:
    1) I have a query which normally runs for about 10-20 seconds and returns over a million records. When I use this query with HTMLDB_COLLECTION.CREATE_COLLECTION_FROM_QUERY in a page in on load before header process, the page times out. If a put some restriction in the query and bring the number of records down to about 100 000 it goes through. Is this normal? Shouldn't I be using this technique with large queries?
    2) I have successfully used HTMLDB_COLLECTION.CREATE_COLLECTION_FROM_QUERY in a package which is called from Apex page, but when I try to run a script containing HTMLDB_COLLECTION.CREATE_COLLECTION_FROM_QUERY in TOAD in the same schema where my Apex applications are parsed I get the following error:
    ORA-20104: create_collection_from_query Error:ORA-20001: Invalid parsing schema for current workspace ID
    ORA-06512: at "FLOWS_030100.WWV_FLOW_COLLECTION",
    Can somebody shed some light on this please!
    George

    Hi George,
    I don't know exactly what the method actually does (a DBA may be able to view the package body code to determine this) but I would have thought that it would at least double the time taken to run the query directly in SQL - once to run the query and the second time to populate the collection. Once created, though, any computations done to get the results for the reports would be a lot slower than using normal SQL data as aggregation and filters could not use indexes that should exist on the tables.
    One possibly, which I haven't yet used myself, would be Materialized Views - see: [http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_6002.htm#sthref6657] - though this may depend on the frequency of updates on the underlying tables as this would, of course, mean additional overheads when inserting/updating/deleting data. You can have indexes on these views, so that would help with the reports.
    Another possibility would to be to have a scheduled job that analyses the tables on a regular basis and generates snapshots in secondary tables that you could then base your reports on. We actually use this method in our office to do daily snapshots of financial data - these are scheduled to run overnight so that they do not slow down normal operations.
    If you wanted to see how long it would take to generate the collection, search the forum for "Processing" and you should find examples of pages that use the Processing graphic (like you see if you install an application into Apex for example). You could apply that to your page and then time it until you get the results
    Andy

  • ORA-20104: create_collection_from_query - WORKAROUND FOUND!

    I have found a workaround for this problem.
    Idea is to silent all exceptions and tried twice same operations-delete and create collection!!
    --"ORA-20104: create_collection_from_query"
    BEGIN
      APEX_COLLECTION.DELETE_COLLECTION (p_collection_name=>'HIST_ONE_SEGMENT_COLL');
    EXCEPTION
      WHEN OTHERS THEN
        NULL;
    END;
    BEGIN
      APEX_COLLECTION.CREATE_COLLECTION_FROM_QUERY (
            p_collection_name => 'HIST_ONE_SEGMENT_COLL',
            p_query => 'SELECT * FROM ... '
    EXCEPTION
      WHEN OTHERS THEN
        BEGIN
          APEX_COLLECTION.CREATE_COLLECTION_FROM_QUERY (
                p_collection_name => 'HIST_ONE_SEGMENT_COLL',
                p_query => 'SELECT * FROM ... '
        EXCEPTION
          WHEN OTHERS THEN
            NULL;
        END;
    END;In mine case this works on 11g as well as 10g databases with Apex 4.02.

    <b>Apex process (before header):</b>
    BEGIN
      APEX_COLLECTION.DELETE_COLLECTION (p_collection_name=>'HIST_ONE_SEGMENT_COLL');
    EXCEPTION
      WHEN OTHERS THEN
        NULL;
    END;
    BEGIN
      APEX_COLLECTION.CREATE_COLLECTION_FROM_QUERY (
            p_collection_name => 'HIST_ONE_SEGMENT_COLL',
            p_query => 'SELECT * FROM TABLE( db_size_pkg.grow_hist_one_segment_pr ('''||:G_OWNER||''', '''||:G_SEGMENT_NAME||''',''' ||:G_SEGMENT_TYPE||'''))'
    EXCEPTION
      WHEN OTHERS THEN
        BEGIN
          APEX_COLLECTION.CREATE_COLLECTION_FROM_QUERY (
                p_collection_name => 'HIST_ONE_SEGMENT_COLL',
                p_query => 'SELECT * FROM TABLE( db_size_pkg.grow_hist_one_segment_pr ('''||:G_OWNER||''', '''||:G_SEGMENT_NAME||''',''' ||:G_SEGMENT_TYPE||'''))'
        EXCEPTION
          WHEN OTHERS THEN
            NULL;
       END;
    END;<b>Pipelined function defined in package db_size_pkg but here is extracted code</b>
    FUNCTION grow_hist_one_segment_pr (p_owner IN VARCHAR2,
                                       p_segment_name IN VARCHAR2,
                                       p_segment_type IN VARCHAR2 DEFAULT 'TABLE'
             ) RETURN DB_SIZE_HIST_SET_T PIPELINED IS
      CURSOR grow_hist_pr_c  (cp_OWNER IN VARCHAR,cp_SEGMENT_NAME IN VARCHAR2, cp_SEGMENT_TYPE IN VARCHAR2) IS
        with q as (
           SELECT
                 PERIOD,
                 SUM (NR_BYTES) db_share_x,
                 SUM (NR_RECORDS) db_rec_share_x
             FROM DB_SIZE
           GROUP BY PERIOD
        select
              OWNER,
              SEGMENT_NAME,
              SEGMENT_TYPE,
              q.period,
              SIZE_MB/(db_share_x/1048576)*100 DB_SHARE,
              RECORDS/db_rec_share_x*100 DB_REC_SHARE,
              SIZE_MB,
              DECODE (LAG(SIZE_MB,1,0) OVER (ORDER BY q.period),0,0,SIZE_MB-LAG(SIZE_MB,1,0) OVER (ORDER BY q.period)) mb_hist,
              DECODE (LAG(SIZE_MB,1,0) OVER (ORDER BY q.period),0,0,(SIZE_MB-LAG(SIZE_MB,1,0) OVER (ORDER BY q.period))/LAG(SIZE_MB,1,0) OVER (ORDER BY q.period)*100) mb_hist_perc,
              DECODE (LAG(SIZE_MB,1,0) OVER (ORDER BY q.period),0,0,(SIZE_MB-FIRST_VALUE (SIZE_MB) OVER (ORDER BY q.period))/FIRST_VALUE (SIZE_MB) OVER (ORDER BY q.period)*100) mb_cumul_perc,
              RECORDS REC,
              DECODE (LAG(RECORDS,1,0) OVER (ORDER BY q.period),0,0,RECORDS-LAG(RECORDS,1,0) OVER (ORDER BY q.period)) rec_hist,
              DECODE (LAG(RECORDS,1,0) OVER (ORDER BY q.period),0,0,(RECORDS-LAG(RECORDS,1,0) OVER (ORDER BY q.period))/LAG(RECORDS,1,0) OVER (ORDER BY q.period)*100) rec_hist_perc,
              DECODE (FIRST_VALUE (RECORDS) OVER (ORDER BY q.period),0,0,(RECORDS-FIRST_VALUE (RECORDS) OVER (ORDER BY q.period))/FIRST_VALUE (RECORDS) OVER (ORDER BY q.period)*100) rec_cumul_perc
        from (
               SELECT period,
                      OWNER,
                      SEGMENT_NAME,
                      SEGMENT_TYPE,
                      SUM (NR_BYTES)/1048576 SIZE_MB ,
                      SUM (NR_RECORDS) RECORDS
                 FROM db_size
                 WHERE OWNER=cp_OWNER AND SEGMENT_NAME=cp_SEGMENT_NAME AND SEGMENT_TYPE=cp_SEGMENT_TYPE
                GROUP BY PERIOD, OWNER, SEGMENT_NAME, SEGMENT_TYPE
              ) l, q
        WHERE q.period=l.period
    BEGIN
      FOR grow_hist_r IN grow_hist_pr_c (p_owner,p_segment_name,p_segment_type) LOOP
        PIPE ROW(DB_SIZE_HIST_T(p_owner,p_segment_name,p_segment_type,grow_hist_r.period,
                                grow_hist_r.DB_SHARE, grow_hist_r.DB_REC_SHARE,
                                grow_hist_r.size_mb ,grow_hist_r.mb_hist ,grow_hist_r.mb_hist_perc ,grow_hist_r.mb_cumul_perc,
                                grow_hist_r.rec,grow_hist_r.rec_hist,grow_hist_r.rec_hist_perc,grow_hist_r.rec_cumul_perc)
      END LOOP;
    END;<b>db_size table defined as:</b>
    DROP TABLE TOOLS.DB_SIZE CASCADE CONSTRAINTS;
    CREATE TABLE TOOLS.DB_SIZE
      PERIOD           VARCHAR2(8 CHAR)             NOT NULL,
      OWNER            VARCHAR2(30 CHAR)            NOT NULL,
      SEGMENT_NAME     VARCHAR2(81 CHAR)            NOT NULL,
      SEGMENT_TYPE     VARCHAR2(30 CHAR)            NOT NULL,
      TABLESPACE_NAME  VARCHAR2(32 CHAR)            NOT NULL,
      PART_NAME        VARCHAR2(81 CHAR)            NOT NULL,
      NR_BYTES         INTEGER                      NOT NULL,
      NR_BLOCKS        INTEGER                      NOT NULL,
      NR_EXTENTS       INTEGER                      NOT NULL,
      NR_RECORDS       INTEGER                      NOT NULL,
      PARENT_ID        INTEGER,
      ID               INTEGER,
      CONSTRAINT DB_SIZE_PK
      PRIMARY KEY
      (PERIOD, OWNER, SEGMENT_NAME, SEGMENT_TYPE, TABLESPACE_NAME, PART_NAME)
    ORGANIZATION INDEX
    LOGGING
    TABLESPACE TOOLS
    PCTFREE    0
    INITRANS   2
    MAXTRANS   255
    CREATE UNIQUE INDEX TOOLS.DB_SIZE_UQX ON TOOLS.DB_SIZE
    (ID)
    LOGGING
    TABLESPACE TOOLS
    PCTFREE    0
    INITRANS   2
    MAXTRANS   255
    CREATE OR REPLACE TRIGGER TOOLS."DB_SIZE_TGBI"
    BEFORE INSERT
    ON TOOLS.DB_SIZE REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    begin
      IF :NEW.ID IS NULL THEN
        FOR c1 IN (SELECT DB_SIZE_SEQ.NEXTVAL next_val FROM dual) LOOP
          :NEW.ID :=  c1.next_val;
        END LOOP;
      END IF;
    end;
    CREATE OR REPLACE PUBLIC SYNONYM DB_SIZE FOR TOOLS.DB_SIZE;<b>DB_SIZE_HIST_SET_T and DB_SIZE_HIST_T types defined as</b>
    CREATE OR REPLACE TYPE TOOLS."DB_SIZE_HIST_T"                                          as OBJECT (
    OWNER            VARCHAR2(30) ,
    SEGMENT_NAME     VARCHAR2(81)  ,
    SEGMENT_TYPE     VARCHAR2(30)   ,
    PERIOD           VARCHAR2(8),              
    DB_SHARE         NUMBER,
    DB_REC_SHARE     NUMBER,
    SIZE_MB          NUMBER,
    TREND_MB         NUMBER,
    TREND_SIZE_PERC  NUMBER,
    CUMUL_SIZE_PERC  NUMBER,
    RECORDS          NUMBER,
    TREND_REC        NUMBER,
    TREND_REC_PERC   NUMBER,
    CUMUL_REC_PERC   NUMBER
    CREATE OR REPLACE TYPE TOOLS."DB_SIZE_HIST_SET_T"                                          as TABLE OF DB_SIZE_HIST_T;
    /<b>In Apex, report is defined as:</b>
    select * from HIST_ONE_SEGMENT_VW<b>and view is defined as</b>
    CREATE OR REPLACE FORCE VIEW HIST_ONE_SEGMENT_VW (
       OWNER,
       SEGMENT_NAME,
       SEGMENT_TYPE,
       PERIOD,
       DB_SHARE,
       DB_REC_SHARE,
       SIZE_MB,
       TREND_MB,
       TREND_SIZE_PERC,
       CUMUL_SIZE_PERC,
       RECORDS,
       TREND_REC,
       TREND_REC_PERC,
       CUMUL_REC_PERC,
       REC_IN_MB
    AS
       SELECT C001 OWNER,
              C002 SEGMENT_NAME,
              C003 SEGMENT_TYPE,
              C004 PERIOD,
              TO_NUMBER (C005) DB_SHARE,
              TO_NUMBER (C006) DB_REC_SHARE,
              TO_NUMBER (C007) SIZE_MB,
              TO_NUMBER (C008) TREND_MB,
              TO_NUMBER (C009) TREND_SIZE_PERC,
              TO_NUMBER (C010) CUMUL_SIZE_PERC,
              TO_NUMBER (C011) RECORDS,
              TO_NUMBER (C012) TREND_REC,
              TO_NUMBER (C013) TREND_REC_PERC,
              TO_NUMBER (C014) CUMUL_REC_PERC,
              DECODE (TO_NUMBER (C007),
                      0, 0,
                      TO_NUMBER (C011) / TO_NUMBER (C007))
                 REC_IN_MB
         FROM apex_collections
        WHERE collection_name = 'HIST_ONE_SEGMENT_COLL';Hope this is all you asked ... if not please let me know.
    Rg,
    Damir

  • Problem with create_collection_from_query (bug?)

    Hi all,
    I seem to be having a wierd problem with CREATE_COLLECTION_FROM_QUERY.
    I'm using LDAP (AD) Authentication, and I stole the ldap_query() function out of John Scott's book.
    I have an after authentication process where I query the LDAP to extract extra information from AD to populate/update a local user repository table. With most users, this all works fine. Howevere, with account I have, it isnt' populating the collection and returning 'NO DATA FOUND'.
    Early in the process, I take the userid and password to create a string which I call v_string.
    Then, I call:
    APEX_COLLECTION.CREATE_COLLECTION_FROM_QUERY (
    p_collection_name => 'MAIN_MENU_COLLECTION',
    p_query => 'SELECT attribute_name, attribute_value
    FROM table (ldap_query ('''
    || v_string
    || '''))'
    As I said, this works fine for all users so far except one, which has a hyphen in it "-". Is there some kind of 'behind the scenes' magic happening with create_collection_from_query that allows the collection to be created but not populated? If I run the ldap_query from SQL (and supply the right credentials), it works as expected and returns around 8 rows. But, when I try to use it for a collection for this one user account, the collection is created but no members exist for it.
    Thanks,
    Bill Ferguson

    For some reason I am still having some wierd problems, and evidently it is not restricted to accounts with a hypen.
    Here is what I've discovered and done so far.
    I went into AD and created a new test user account without a hypen. I then tried to login as that new user and while I got into the application, nothing was inserted into foo (per John's suggestion above). NOTE: Just to make sure nothing is being carried over, I always stop and then restart a new browser instance.
    I then tried logging in as myself. Succes all the way around. (stop and restart browser)
    I tried again as myself with a bad password. No luck, got the 'Invalid Credentials' message. Tried with good password, it works. (stop and restart again)
    I tried with the new test account without a hyphen. Got into application, but nothing in foo. (stop and restart)
    I tried with my 'hypenated' account. Same thing, got into application, but nothing in foo. (stop and restart)
    I tried the same two as above, but with bad passwords. Got the 'Invalid Credentials' message, then with real password, was able to get in but nothing in foo.
    Added in some logging routines and other tests into the post-authentication process. When it fails, it's because :P101_PASSWORD is null. For my regular account that works, no message is returned.
    So, I'm really confused now. Obviously it is authenticating, since I don't get the 'Invalid Credentials' message, so why is :P101_PASSWORD somehow getting nulled out for some account logins (after authenticating), but not others?
    Here is the beginning of my post authentication process:
    DECLARE
       v_usercode   PLS_INTEGER;
       v_section    VARCHAR2 (1000) := NULL;
       v_test       VARCHAR2 (1000) := NULL;
       v_pwd        VARCHAR2 (20);
       v_string     VARCHAR2 (1000);
       bresult      BOOLEAN := FALSE;
    BEGIN
       BEGIN
          v_pwd := :P101_PASSWORD;
          IF LENGTH (v_pwd) IS NULL
          THEN
             log_error (' 1. authentication, null password',
                        SQLCODE || ' - ' || SUBSTR (SQLERRM, 1, 3900));
          END IF;
       EXCEPTION
          WHEN NO_DATA_FOUND
          THEN
             log_error (' .5. authentication, begin, NO_DATA_FOUND error',
                        SQLCODE || ' - ' || SUBSTR (SQLERRM, 1, 3900));
          WHEN OTHERS
          THEN
             log_error (' .5. authentication, begin,  others error',
                        SQLCODE || ' - ' || SUBSTR (SQLERRM, 1, 3900));
       END;
       BEGIN
          DELETE FROM   foo
                WHERE   username = v ('APP_USER');
       EXCEPTION
          WHEN NO_DATA_FOUND
          THEN
             log_error (' 2. authentication, delete, NO_DATA_FOUND error',
                        SQLCODE || ' - ' || SUBSTR (SQLERRM, 1, 3900));
          WHEN OTHERS
          THEN
             log_error (' 2. authentication, delete,  others error',
                        SQLCODE || ' - ' || SUBSTR (SQLERRM, 1, 3900));
       END;
       BEGIN
          INSERT INTO foo
             SELECT   attribute_name, attribute_value, v ('APP_USER')
               FROM   table (ldap_query (v ('APP_USER'), v_pwd)), DUAL;So, right away I'm checking for if :P101_PASSWORD is null and when it's not working, it says it is null, but somehow it is also authenticating correctly.
    I'm totally confused (once again). Any help or advice?
    Thanks,
    Bill Ferguson

  • Create_collection_from_query: ORA-01403: no data found

    Hi All,
    I am trying to create a collection from a query that queries another collection in an anonymous block/process that executes upon page load in APEX. Right now my query is set up as such:
    v_Query := 'Select * from apex_collections where collection_name = ''NAME'' and c002= ''' || v_Variable || '''';
    v_Variable is passed in the URL that links the page and will be used to create a dynamically generated tree. I have verified that data exists in the source collection that satisfies this query, and that the query that spits out is formatted so that it looks like:
    Select * from apex_collections where collection_name = 'NAME' and c002 = 'Criteria'
    Much to my chagrin, however, I always get a "ORA-01403: no data found" error. I have done all of my testing in the APEX SQLWorkshop with zero luck so far getting it to work. Any help is appreciated. The entire block of code that im running is below:
    Thanks!!
    Sean
    DECLARE
    v_detail TsaOrgEntity_type;
    v_entity TsaOrgEntity_type;
    v_i number;
    v_multi MultiString_type;
    v_name varchar2(4000);
    v_text varchar2(4000);
    v_type varchar2(4000);
    v_Parent varchar2(4000);
    v_Prefix varchar2(4000);
    v_First varchar2(4000);
    v_Second varchar2(4000);
    v_id varchar2(4000);
    v_pid varchar2(4000);
    v_org TsaOrgEntity_type;
    v_code varchar2(4000);
    BEGIN
    v_prefix := '<a href="f?p=1000:6:' || :app_session || ':::6:P6_OrgEntity,P6_OrgName:';
    apex_collection.create_or_truncate_collection('ORGCODES');
    apex_collection.add_member('ORGCODES','TSA','TA5000000000000000','','');
    v_org := tsaorgentity_type('organization');
    v_org.search(v_prefix);
    FOR i IN 1..apex_collection.collection_member_count('ORGENTITY_RESULTSET') LOOP
      SELECT c002 INTO v_Name FROM apex_collections where collection_name = 'ORGENTITY_RESULTSET' AND seq_id = i;
      SELECT c011 INTO v_Code FROM apex_collections where collection_name = 'ORGENTITY_RESULTSET' AND seq_id = i;
      SELECT c001 into v_Type FROM apex_collections where collection_name = 'ORGENTITY_RESULTSET' AND seq_id = i;
      v_parent := ParentOrgID(v_Code);
      apex_collection.add_member('ORGCODES',v_Name,v_Code,v_Type,v_Parent);
    END LOOP;
    v_org := tsaorgentity_type('department');
    v_org.search(v_prefix);
    FOR i IN 1..apex_collection.collection_member_count('ORGENTITY_RESULTSET') LOOP
      SELECT c003 INTO v_Name FROM apex_collections where collection_name = 'ORGENTITY_RESULTSET' AND seq_id = i;
      SELECT c011 INTO v_Code FROM apex_collections where collection_name = 'ORGENTITY_RESULTSET' AND seq_id = i;
      SELECT c001 into v_Type FROM apex_collections where collection_name = 'ORGENTITY_RESULTSET' AND seq_id = i;
      v_parent := ParentOrgID(v_Code);
      apex_collection.add_member('ORGCODES',v_Name,v_Code,v_Type,v_Parent);
    END LOOP;
    v_org := tsaorgentity_type('subdpt');
    v_org.search(v_prefix);
    FOR i IN 1..apex_collection.collection_member_count('ORGENTITY_RESULTSET') LOOP
      SELECT c003 INTO v_Name FROM apex_collections where collection_name = 'ORGENTITY_RESULTSET' AND seq_id = i;
      SELECT c011 INTO v_Code FROM apex_collections where collection_name = 'ORGENTITY_RESULTSET' AND seq_id = i;
      SELECT c001 into v_Type FROM apex_collections where collection_name = 'ORGENTITY_RESULTSET' AND seq_id = i;
      v_parent := ParentOrgID(v_Code);
      apex_collection.add_member('ORGCODES',v_Name,v_Code,v_Type,v_Parent);
    END LOOP;
    v_org := tsaorgentity_type('port');
    v_org.search(v_prefix);
    FOR i IN 1..apex_collection.collection_member_count('ORGENTITY_RESULTSET') LOOP
      SELECT c002 INTO v_Name FROM apex_collections where collection_name = 'ORGENTITY_RESULTSET' AND seq_id = i;
      SELECT c008 INTO v_Code FROM apex_collections where collection_name = 'ORGENTITY_RESULTSET' AND seq_id = i;
      SELECT c001 into v_Type FROM apex_collections where collection_name = 'ORGENTITY_RESULTSET' AND seq_id = i;
      v_parent := ParentOrgID(v_Code);
      apex_collection.add_member('ORGCODES',v_Name,v_Code,v_Type,v_Parent);
    END LOOP;
    END;
    DECLARE
      v_detail  TsaOrgEntity_type;
      v_entity  TsaOrgEntity_type;
      v_i       number;
      v_multi   MultiString_type;
      v_name    varchar2(4000);
      v_text    varchar2(4000);
      v_type    varchar2(4000);
      v_Parent  varchar2(4000);
      v_Prefix  varchar2(4000);
      v_First   varchar2(4000);
      v_Second  varchar2(4000);
      v_id      varchar2(4000);
      v_pid     varchar2(4000);
      v_org     TsaOrgEntity_type;
      v_code    varchar2(4000);
    BEGIN
    v_entity := TsaOrgEntity_type('department', 'Security Technology');
    v_entity.detail(v_detail);
    v_Pid := ParentOrgID(v_detail.multistring2varchar(v_detail.get_organizationcode));
    v_ID := v_detail.multistring2varchar(v_detail.get_organizationcode);
    v_First := 'Select * from apex_collections where collection_name = ''ORGCODES'' and c002 = ''TA6200000000000000'' ';
    v_Second := 'Select * from apex_collections where collection_name = ''ORGCODES'' and c004 = ''TA6202000000000000'' ';
    IF apex_collection.collection_exists('FIRST') = TRUE THEN
      apex_collection.delete_collection('FIRST');
    END IF;
    IF apex_collection.collection_exists('SECOND') = TRUE THEN
      apex_collection.delete_collection('SECOND');
    END IF;
    apex_collection.create_collection_from_query_b('FIRST',v_First);
    apex_collection.create_collection_from_query_b('SECOND',v_Second);
    apex_collection.create_or_truncate_collection('BLUETREE');
    IF apex_collection.collection_member_count('FIRST') > 0 THEN
      FOR i in 1..apex_collection.collection_member_count('FIRST') LOOP
        SELECT c001 INTO v_Name from apex_collections where collection_name = 'FIRST' and seq_id = i;
        SELECT c003 INTO v_Type from apex_collections where collection_name = 'FIRST' and seq_id = i;
        SELECT c002 INTO v_ID from apex_collections where collection_name = 'FIRST' and seq_id = i;
        SELECT c004 INTO v_ID from apex_collections where collection_name = 'FIRST' and seq_id = i;
        v_Name := '<a href=f?p=1000:6:'||':::6:P6_OrgEntity,P6_OrgName:'
    || v_Type
    ||','
    || v_Name
    || '">'
    || v_Name
    || '</a>';
    apex_collection.add_member('BLUETREE',v_Name,v_ID,v_PID);
    END LOOP;
    END IF;
    IF apex_collection.collection_member_count('SECOND') > 0 THEN
    FOR i in 1..apex_collection.collection_member_count('SECOND') LOOP
    SELECT c001 INTO v_Name from apex_collections where collection_name = 'FIRST' and seq_id = i;
    SELECT c003 INTO v_Type from apex_collections where collection_name = 'FIRST' and seq_id = i;
    SELECT c002 INTO v_ID from apex_collections where collection_name = 'FIRST' and seq_id = i;
    SELECT c004 INTO v_ID from apex_collections where collection_name = 'FIRST' and seq_id = i;
    v_Name := '<a href="f?p=1000:6:'
    ||':::6:P6_OrgEntity,P6_OrgName:'
    || v_Type
    ||','
    || v_Name
    || '">'
    || v_Name
    || '</a>';
    apex_collection.add_member('BLUETREE',v_Name,v_ID,v_PID);
    END LOOP;
    END IF;
    apex_collection.add_member('BLUETREE',v_detail.get_cn(),v_detail.multistring2varchar(v_detail.get_organizationcode),ParentOrgID(v_detail.multistring2varchar(v_detail.get_Organizationcode)));
    apex_collection.add_member('BLUETREE','TSA','TA5000000000000000','','');
    dbms_output.put_line(v_First);
    dbms_output.put_line(V_Second);
    END;

    Hi Ricardo,
    You appear to be missing a comma after the column
    nome_objeto in your query string.
    Regards
    AndreHi Andre
    Thank you for your help.
    I copied the source wrong. The error is the same. I read an example in book EASY HTMLDB where i can create a region using a select on apex_collections table. I want to do this.
    Regards
    Ricardo

  • SQL Query report region that only queries on first load

    Hello all,
    Is there any way in which you can prevent a SQL Query report region from quering data after every refresh?
    I would like to make a report that queries on the first load, but then I would like to change the individual values, and reload to show the change, but every time I reload the page the columns are queried and the original values are displayed once again...
    any ideas?
    -Mux

    Chet,
    I created a header process to create the HTMLDB_COLLECTION. It is something like:
    HTMLDB_COLLECTION.CREATE_COLLECTION_FROM_QUERY(
    p_collection_name => 'Course_Data',
    p_query => 'SELECT DISTINCT COURSE_ID, HTMLDB_ITEM.CHECKBOX(14,COURSE_ID) as "checker", TITLE, SUBJECT, COURSE_NUMB, SECTION, ENROLLED, null as "temp_term", null as "temp_title", null as "temp_crse_id", null as "temp_subj", null as "temp_crse_numb", null as "temp_sect", FROM DB_TBL_A, DB_TBL_B, DB_TBL_C, DB_TBL_D, DB_TBL_E, DB_TBL_F WHERE ...');
    The names were changed, for obvious reasons.
    I then created an SQL Report Region to see if it would work. The SQL is:
    SELECT c001, c002, c003
    FROM htmldb_collections
    WHERE collection_name = 'COURSE_DATA'
    When I run the page it says:
    ORA-20104: create_collection_from_query Error:ORA-20104: create_collection_from_query ExecErr:ORA-01008: not all variables bound
    Any idea why this is happening?
    I'm new to HTMLDB_COLLECTIONS, so I may be doing something wrong
    -Mux

  • No data found on Report based on a collection

    Hi all,
    I got a page with this 'after-header' process :
    begin
      if(apex_collection.collection_exists(p_collection_name => 'users')) then
        apex_collection.delete_collection(p_collection_name => 'users');
      end if;
      apex_collection.create_collection_from_query(
        p_collection_name => 'users',
        p_query => 'select user_name from demo_users');
    end;And then, I try to display the collection data in a report, like with this SQL statement.
    select *
    from apex_collections
    where collection_name='users'I got a 'No data found' for this report... I try this very basic example to understand collections, and I don't know what I'm missing...
    Thanks a lot
    Dovik

    Hi,
    No problem
    Check collection naming
    http://download.oracle.com/docs/cd/E14373_01/appdev.32/e11838/advnc.htm#CIHHCGGD
    Have nice day
    Br,Jari

  • Adding Every Row From a Filtered Interactive Report to a Collection

    I'm creating an email list maintenance application in Apex 3.1. I have an Interactive Report on an email address table. I want the users to be able to run this IR and then click a button to add all of the resulting email addresses into a selected mailing list table. The interface needs to be as quick and simple for the user as possible, so I don't want to force them to click a checkbox beside hundreds of rows.
    Is there a way to add every resulting row from a custom IR to an apex_collection?
    I know that collections can be created based on a query with the CREATE_COLLECTION_FROM_QUERY call. But I don't think it's possible to reference the SQL statement which is dynamically generated through an Interactive Report. I'm referring to the SQL created after the user has applied filters. If there were, then I would just create the collection that way. Please correct me if I'm wrong.
    Thanks,
    Martin

    Hi Martin
    I couldn't find a place where the filters are stored either - it would be nice to know.
    It is possible to get to the filters via javascript as they are actually stored in a table with an id of "apexir_CONTROL_PANEL_COMPLETE". Within there, there are rows for each filter and each row has four cells. The second cell contains an A tag that has the filter itself as the text displayed as a hyperlink on screen. The third cell contains the checkbox that enables/disables the filter. Strings and numbers seem to be formatted ok, so you could pick up these values and create your own WHERE clause, populate a hidden field somewhere and then pick that up to generate a full select statement to get to the id's that you need.
    I haven't yet tried this, so this is theory only - but I can't see that it wouldn't work
    Andy

Maybe you are looking for

  • How do I fix a 1439 error on iPod Classic

    iPod Classic not working at all.  Tried resetting with no luck.  Tried to restore - comes up with [The iPod "iPod" could not be restored. An unknown error occurred (1439).]  How do I fix a 1439 error?

  • VGA bios MSI gtx 970 tiger edition oc

    can I get latest bios? and I can use it? my s/n 602-v316-060B1501002167 Thx

  • Reducing the Content Area in Panel Widget

    I know that the size of the content area is constrained by the size of the content within - text frame or images - but I only have a text frame and its is much smaller than the content area and I still cannot reduce the size of the content area. Plea

  • Multiple Selection with JList

    Hello! I have a Frame with a JList that needs to be able to do multiple slection. The JList ist filled with special names which are found when the user opens a certain file. (so a file-chooser is here too) When the User selects a name every paragraph

  • Mail 2.0 crashing when sending message and opening mailbox

    I've had a weird problem for a few weeks now that I've finally replicated. I have about 7 accounts that are all active. Mail stops responding when I compose a message and click "send" and then go to another mailbox. It starts to open the mailbox, and