question simple idoc - a loop in a result set.

Just got back from holidays and watching a code, but my brain has decided to give up something that should be so simple...

Can anyone help unlock my head? :)

Whats is the best way of...
Browse meta-data and write pair name & value, by using the DOC_INFO service without having to manually write all metafields?

Here is a small example of what I'm doing but cannot figure out how to get the names of current fields; Maybe use rsFieldByIndex, but it seems silly and I can not find any function to return...

EXEC DOC_INFO
LOOPWHILE GETVAL (SEARCHRESULTS)
WRITE TO SEARCHRESULTS.NAME
WRITE SEARCH RESULTS. VALUE
RSNEXT
ENDLOOP

what Miss me?
Thank you
J /.

Hi John,.

It's funny he is actually a very good example of what you're trying to do in the doc IDOC Schema section.

Here it is:

<$getViewValuesResultSet("Country_View", "",="" "")$="">
<$loop schemadata$="">
<$count =="" 0,="" num="rsNumFields(" schemadata")$"="">
<$loopwhile count="">< num$="">
<$fieldName=rsFieldByIndex("SchemaData", count)$="">
<$fieldName$>=<$getValue("SchemaData", fieldname)$="">
<$count =="" count="" +="" 1$="">
<$endloop$>
<$endloop$>

With a doc info it would look more like fine.

<$dID="12345"$>
<$executeService("DOC_INFO")$>
<$loop doc_info$="">
<$count =="" 0,="" num="rsNumFields(" doc_info")$"="">
<$loopwhile count="">< num$="">
<$fieldName=rsFieldByIndex("DOC_INFO", count)$="">
<$fieldValue$>=<$getValue("DOC_INFO", fieldname)$="">
<$count =="" count="" +="" 1$="">
Field name:<$fieldName$>
Field value:<$fieldValue$>
<$endloop$>
<$endloop$>

Thanks... hope the holiday was good!
David

Tags: Fusion Middleware

Similar Questions

  • Unable to loop result set of a query in Site Studio component

    Hi all

    I write a custom component to display the records in the custom table.

    I created a (docservice) service called 'GET_DATA_VIEW' and selected scriptable. In action, I've assigned a "Quser" query and the query "select type query cache. I gave the name of result as GET_USER set.

    Now, the "Quser" query is a simple select statement as follows:

    Select * from temp_user where dName =?.

    Added dName as a parameter.

    The studio site page when I run the service and the result set, the loop it does not work. The code is as below:

    <!-$dName = 'test'->
    <!-$ executeService ("GET_DATA_VIEW")->
    <! - $loop GET_USER - >
    <!-$dName->: <!-$dDepartment->
    <!-$endloop->

    It does not, so that if I create a page template in the component that works.

    Help, please.

    Leo30 wrote: my query is "select country countryname".

    Where COUNTRYNAME is a column in the country table.

    When trying to loop through the result set, it does not print the result as below:




    >

    Leo30 wrote: but when I print it gives me the correct number of rows in the table.

    Hoping that the "USER_LIST" is a typo. The result set name is 'COUNTRY_LIST '.

    In any case, assuming that the fault of typo, it is likely that you have the incorrect column name or the name of the column is in the wrong case. The names are case-sensitive, and you can not return the column name, you expect from the result set.

    Try to use this code to print the actual column names and values of the result set.






    =


  • question simple css

    Hello

    I'm stuck with a question simple css-

    I need to display some text below the other strings:

    Text1
    Text2
    Text3

    I use jspx:

    < af:panelGroupLayout layout = "vertical" >

    < af:panelGroupLayout >
    < af:outputText value = "text1" / >
    < / af:panelGroupLayout >

    < af:panelGroupLayout >
    < af:outputText value = "text2" / >
    < / af:panelGroupLayout >

    < af:panelGroupLayout >
    < af:outputText value = "Text3" / >
    < / af:panelGroupLayout >

    < / af:panelGroupLayout >


    well, I receive the channels displayed vertically.


    but I need them to the right of the screen-

    so I use the style class:

    {.textClass}
    float: right;
    }

    and adding in all three group layout in the hope that the three strings to shift right-

    < af:panelGroupLayout layout = "vertical" >

    < af:panelGroupLayout >
    < af:outputText value = "text1" styleClass = "textClass" / >
    < / af:panelGroupLayout >

    < af:panelGroupLayout >
    < af:outputText value = "text2" styleClass = "textClass" / >
    < / af:panelGroupLayout >

    < af:panelGroupLayout >
    < af:outputText value = "Text3" styleClass = "textClass" / >
    < / af:panelGroupLayout >

    < / af:panelGroupLayout >


    they go right, but they are now displayed on one line:

    text3text2text1


    what I wanted was-

    -------------------------text1
    -------------------------text2
    -------------------------text3


    Please suggest.

    Thank you.

    Why so complicated?

                
                    
                    
                    
                
    

    the round is played.

    Timo

  • Problem with the query result set * STILL a QUESTION *.

    Summary

    What I am tring to do is to return output to the data points that currently have no values.

    * Here it is sample data for reasons explaining my question (my data set is MUCH bigger)

    xTable
    YEAR    PEOPLE    ITEMS    TYPE_NUMBER TYPE_DESC    CLASS
    2010       1                 1              REG              1 
    2010        2        3         2             MISC             1
    2010        5        4         3             WEEK           1
    2010                             1             REG              2
    2010                             2             MISC             2
    2010                             3             WEEK           2
    2009       1                 1              REG              1 
    2009        2        3         2             MISC             1
    2009        5        4         3             WEEK           1
    2009                             1             REG              2
    2009                             2             MISC             2
    2009                             3             WEEK           2
    
    ... (there's over 100 other unique CLASS values)
    Desired output
    YR     PEOPLE   ITEMS   TOTAL PEOPLE  TOTAL_ITEMS
    2010         -            -            -                        -                         --  (Class 2 result set)
    
    /* FYI, If i wanted the class 1 result set it would look like this:
    YR     PEOPLE   ITEMS   TOTAL PEOPLE  TOTAL_ITEMS
    2010        8       7             16                    14                       -- (Class 1 result set)*/
    Oracle: 10.2 G
            select 2010 as yr,
                         nvl(f.people,'-') as people
                         nvl(f.items,'-') as items  
                         nvl(to_char(sum(f.people)),'-') as total_people,
                         nvl(to_char(sum(f.items)),'-') as total_items,
                         from Xtable,
                              (2010 as yr,
                              sum(items)as items
                              sum(people) as people
                              from xTable
                              where person_id = 99999
                              and   type_number in (1,2,3)
                              and year = 2010
                              and class = 2 
                              or class = 1
                              ) f
                         where person_id = 99999
                         and type_number in (1,2,3)
                         and yr = f.yr
                         and (year <= 2010 or year = 2010)
                         and (class = 2 or class = 1)
                         group by 
                         f.people,
                         f.items
    Currently, the query above will return no rows.

    Published by: user652714 on February 2, 2010 13:04

    How about this?

    SQL> WITH    xTable AS
      2  (
      3          SELECT 2010 AS YEAR, 1 AS PEOPLE, 0 AS ITEMS, 1 AS TYPE_NUMBER, 'REG' AS TYPE_DESC, 1 AS CLASS FROM DUAL UNION ALL
      4          SELECT 2010 AS YEAR, 2 AS PEOPLE, 3 AS ITEMS, 2 AS TYPE_NUMBER, 'MISC' AS TYPE_DESC, 1 AS CLASS FROM DUAL UNION ALL
      5          SELECT 2010 AS YEAR, 5 AS PEOPLE, 4 AS ITEMS, 3 AS TYPE_NUMBER, 'WEEK' AS TYPE_DESC, 1 AS CLASS FROM DUAL UNION ALL
      6          SELECT 2010 AS YEAR, NULL AS PEOPLE, NULL AS ITEMS, 1 AS TYPE_NUMBER, 'REG' AS TYPE_DESC, 2 AS CLASS FROM DUAL UNION ALL
      7          SELECT 2010 AS YEAR, NULL AS PEOPLE, NULL AS ITEMS, 2 AS TYPE_NUMBER, 'MISC' AS TYPE_DESC, 2 AS CLASS FROM DUAL UNION ALL
      8          SELECT 2010 AS YEAR, NULL AS PEOPLE, NULL AS ITEMS, 3 AS TYPE_NUMBER, 'WEEK' AS TYPE_DESC, 2 AS CLASS FROM DUAL
      9  )
     10  -- END SAMPLE DATA
     11  SELECT  YEAR
     12  ,       NVL(TO_CHAR(SUM(PEOPLE)),'-')    AS PEOPLE
     13  ,       NVL(TO_CHAR(SUM(ITEMS)),'-')     AS ITEMS
     14  ,       CLASS
     15  FROM    xTable
     16  WHERE   CLASS IN (1,2)
     17  AND     YEAR = 2010
     18  GROUP BY YEAR
     19  ,       CLASS
     20  ORDER BY CLASS DESC;
    
                    YEAR PEOPLE ITEMS CLASS
    -------------------- ------ ----- -----
                    2010 -      -         2
                    2010 8      7         1
    
  • Help with the query to select only one record from the result set in double

    Hello

    Please help with the query. Version of Oracle database we use is 10g R2.

    I have a vision that is duplicated IDS, but they are used across the different functions. See below examples of data. Please help me with a query to select only one record (based on ID regardless of the area) from the bottom of the result set of duplicate records. For what is the point of view is there unique records, given the combination of the fields ID, Org, DF, dry, Sub-Sec

    ID
    Org
    DF
    Sec Sub-Sec

    (163)CQCPDMCPDMHD(163)PCENGENGENG(163)CQASICASICIS8888TSTACTACTAC(163)TSHEHESW6789CQINFOINFOFOS6789PCSECSYSSECSYSINFO16789TSSECSYSSECSYSINFO29009PCBMSBMSBMS1

    My result set must eliminate the duplicate identifiers regardless of whoever we choose of the result set. (I mean without distinction Org, DF, s, Sub-s). My expected result set should be.

    ID
    DSB

    DF
    SEC
    Sub-Sec
    (163)CQCPDMCPDMHD8888TSTACTACTAC6789CQINFOINFOFOS9009PCBMSBMSBMS1


    Thank you

    Orton

    Hello

    This sounds like a job for ROW_NUMBER:

    WITH got_r_num AS

    (

    SELECT id, DSB, df, s, sub_sec org

    ROW_NUMBER () OVER (PARTITION BY ID.

    ORDER BY org

    ) AS r_num

    OF view_x

    )

    SELECT id, DSB, df, sub_sec s,

    OF got_r_num

    WHERE r_num = 1

    ;

    He is a Top - N query example, where you choose the elements of N (N = 1 in this case) from the top of an ordered list.

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and INSERT, only relevant columns instructions) to your sample data and the results desired from these data.  (I know that you said that you were a view selection.  Just for this thread, pretending it is a picture and post simple CREATE TABLE and INSERT statements to simulate your point of view).
    Point where the above query is to produce erroneous results, and explain, using specific examples, how you get the right results from data provided in these places.  (I didn't quite understand the explanation above.  I don't know why you want to

    ID ORG DF DRY SUB_SEC

    --      ---     --      ---     -------

    1234 CQ DPRK DPRK HD

    and is not

    1234 IS CQ ASIC, ASIC

    or

    TS 1234 IT IT SW

    or

    1234 CQ ASIC ASIC HD

    )
    If you change the query at all, post your modified version.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002

  • Group by result set divergence

    Hi all

    Please help me on below.

    When I group by result set is as below.

    SQL > select count (*), the Group of the stg_famis_equip, by attribut2, attribut2 having count (*) > 1;

    COUNT (*) ATTRIBUT2

    ---------- --------------------

    2 FM023566                                                            

    2 FM021481                                                            

    2 FM025833                                                            

    2 FM058806                                                            

    Where, if I query with WHERE clause for certain values as below.

    Please suggest me on, why it is show as count = 2 and when questioning with only WHERE clause (some time no record).  I do one any error... Please suggest me.

    SQL > select attribut2, attribut3 from stg_famis_Equip where attribut2 = 'FM023566';

    ATTRIBUT2 ATTRIBUT3

    --------------------           --------------------

    FM023566 12

    SQL > select attribut2, attribut3 from stg_famis_Equip where attribut2 = 'FM021481';

    ATTRIBUT2 ATTRIBUT3

    --------------------           --------------------

    FM021481 11

    FM021481 12

    SQL > select attribut2, attribut3 from stg_famis_Equip where attribut2 = 'FM025833';

    ATTRIBUT2 ATTRIBUT3

    --------------------           --------------------

    FM025833 07

    FM025833 12

    SQL > select attribut2, attribut3 from stg_famis_Equip where attribut2 = 'FM058806';

    no selected line

    I'm on the Oracle 11 g Enterprise Edition Release Database 11.2.0.2.0 - 64 bit Production

    Thank you

    This means that:

    FM023566 has the new line and return at the end of the string (13/10)

    FM021481 is clean

    FM025833 is also clean

    FM058806 has the new line and carriage return to then end of the string

    Trim will replace spaces when not specified what should be trimmed. If you could do a RTRIM (attribute2, CHR (13): 10 to clean the data.)

    HTH

  • Combine multiple lines into one line (from two tables / result sets)

    Hello experts,

    I would like to know how to combine multiple lines/records in a single record. Here are the DDL and DML to tables:

    create table test_table)

    client_name varchar2 (50 char),

    login_time timestamp (6).

    logout_time timestamp (6).

    auto_type varchar2 (10 char)

    )

    create table root_table)

    navigation_time timestamp (6).

    client_name varchar2 (50 char),

    VARCHAR2 (50 char) nom_du_groupe

    )

    Insert into test_table

    values ("John", TO_TIMESTAMP ('2013-12-05 17:04:01.512 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), TO_TIMESTAMP ('2013-12-05 17:27:31.308 ',' YYYY-MM-DD HH24:MI:SS.) FF'), 'SIMPLE');

    Insert into test_table

    values ('David', TO_TIMESTAMP ('2013-12-05 06:33:01.308 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), TO_TIMESTAMP ('2013-12-05 06:45:01.112 ',' YYYY-MM-DD HH24:MI:SS.) FF'), 'SIMPLE');

    insert into root_table

    values (TO_TIMESTAMP ('2013-12-05 17:04:01.512 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), 'John', "invalid");

    insert into root_table

    values (TO_TIMESTAMP ('2013-12-05 17:14:22.333 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), 'John', "GROUP_1");

    insert into root_table

    values (TO_TIMESTAMP ('2013-12-05 17:27:31.308 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), 'John', "GROUP_1");

    insert into root_table

    values (TO_TIMESTAMP ('2013-12-05 06:33:01.308 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), "David", "invalid");

    insert into root_table

    values (TO_TIMESTAMP ('2013-12-05 06:45:01.112 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), 'David', 'GROUP_5');

    game results test_table

    client_name

    login_time logout_time auto_typeJohn05/12/2013 5:04:01.512000 PM05/12/2013 5:27:31.308000 PMSIMPLEDavid05/12/2013 6:33:01.308000 AM05/12/2013 6:45:01.112000 AMSIMPLE

    root_table result set

    navigation_time client_name GroupName
    05/12/2013 5:04:01.512000 PMJohnNot valid
    05/12/2013 5:14:22.333000 PMJohnGROUP_1
    05/12/2013 5:27:31.308000 PMJohnGROUP_1
    05/12/2013 6:33:01.308000 AMDavidNot valid
    05/12/2013 6:45:01.112000 AMDavidGROUP_5

    And here is the SQL code I'm writing:

    Select a.customer_name, a.login_time, a.logout_time, a.auto_type, Max (b.group_name)

    from test_table a, b root_table

    where a.customer_name = b.customer_name

    Group of a.customer_name, a.login_time, a.logout_time, a.auto_type

    As the 'invalid' value is greater than the value "GROUP_1" (based on the number of letter in English), the GroupName is returned as 'invalid '. I want to bring the GroupName based on the navigation_time column in the root_table so that it always returns a valid GroupName. Please help me.

    Output current:

    Client_name.      Login_Time.     Logout_Time |     Auto_Type |     GroupName

    --------------------------------------------------------------------------------------------------------------------------------------------

    John |     05/12/2013 5:04:01.512000 PM |     05/12/2013 5:27:31.308000 PM |     SIMPLE |     Not valid

    David |     05/12/2013 6:33:01.308000 AM |     05/12/2013 6:45:01.112000 AM |     SIMPLE |     Not valid

    Expected results:

    Client_name.      Login_Time.     Logout_Time |     Auto_Type |     GroupName

    --------------------------------------------------------------------------------------------------------------------------------------------

    John |     05/12/2013 5:04:01.512000 PM |     05/12/2013 5:27:31.308000 PM |     SIMPLE |     GROUP_1

    David |     05/12/2013 6:33:01.308000 AM |     05/12/2013 6:45:01.112000 AM |     SIMPLE |     GROUP_5

    Thank you!

    Adding INSERT statements, current and planned outputs.

    This...

    SELECT client_name

    login_time,

    logout_time,

    auto_type,

    GroupName

    Of

    (select a.customer_name,

    a.login_time,

    a.logout_time,

    a.auto_type,

    b.group_name,

    ROW_NUMBER() over (PARTITION BY a.customer_name, a.login_time, a.logout_time, a.auto_type ORDER BY b.group_name) rn

    from test_table a, b root_table

    where a.customer_name = b.customer_name)

    WHERE rn = 1;

    OUTPUT:-

    =========

    David DECEMBER 5, 13 06.33.01.308000000 AM DECEMBER 5, 13 06.45.01.112000000 AM SIMPLE GROUP_5
    John DECEMBER 5, 13 05.04.01.512000000 PM DECEMBER 5, 13 05.27.31.308000000 PM SIMPLE GROUP_1

    Thank you

    Ann

  • UNION and UNION ALL giving multiple result sets even if INTERSECT does not lines.

    Hello

    I have a set of two queries. I used the UNION to join the result set. When I used UNION ALL, I get a different result set.

    BT when I use INTERSECT, I m not getting all the lines.

    SO, which I guess is, as operation INTERSECT isn't Govind all the lines, then the UNION and UNION ALL of the result sets must be simliar.

    But I m getting different result sets.

    Please guide me.

    Thank you.

    Hello

    UNION returns separate lines; UNION ALL returns all rows that produce queries.

    INTERSECT has nothing to do with it.  You can have the lines in a single query.  For example

    Job SELECTION

    FROM scott.emp

    UNION - ALL THE

    SELECT 'FUBAR '.

    DOUBLE;

    In this example, there is no overlap between the 2 queries (INTERSECT would have 0 rows).

    UNION produces 6 lines, because the query at the top of the page produces 5 distinct lines (of 14 total ranks) and the background query 1.

    UNION ALL product lines 15: 14 of the request from top and 1 of the request from the lower part.

    I hope that answers your question.

    If not, post a test script (if necessary) and complete, including some UNION, UNION ALL queries INTERSECT.  Post of the CREATE TABLE and INSERT statements for all tables using those queries (with the exception of the commonly available rtables, such as those of the scott schema) and a specific question, such as "the UNION query all product...» I expect the UNION query to produce... because... but instead, it produces... Why is this?  It seems contractict... manual which says that... ».

  • AF:inputListOfValues sets the value of the first item in the result set when using enter key or tab and component value autosubmit = true

    I use JDev 11.1.1.6 and when I type in a value in an af:inputListOfValues element and press enter or the tab key, it will replace the value I entered with the first element in the set of results LOV. If enter a value, simply click on the component af:inputListOfValues it works correctly. If I use the popup and find a value it works properly as well. I have a programmatic view object that contains a single transitional attribute (this is the view object that is used to create the list of the components of the value of) and then I have another object from view based on entities which defines one of its attributes in a list of the attribute value. I tried to use a base object view of entity to create the LOV to and everything works as expected, so I don't know if this is a bug when using programmatic view objects or if I need more code in the VOImpl. In addition, it seems after that first of the value being replaced by the first value in the result set that it will work correctly as well. Here are some excerpts of important code.

    Also, it seems that this does not work only if the text entered in the component af:inputListOfValues would have only a single game, returned in the result set. For example, given the result defined in code: Brad, Adam, Aaron, Fred, Charles, Charlie, Jimmy

    If we get into Cha, the component works as expected

    If we register A, the component works as expected

    If we get Jimmy, the component does not work as expected, and returns the first value of results IE. Brad

    If we get Fred, the component does not work as expected, and returns the first value of results IE. Brad

    I also checked that I get the same behavior in JDev 11.1.1.7

    UsersVOImpl (programmatic view with 1 transitional attribute object)

    import java.sql.ResultSet;
    
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.List;
    
    import oracle.adf.share.logging.ADFLogger;
    
    import oracle.jbo.JboException;
    import oracle.jbo.server.ViewObjectImpl;
    import oracle.jbo.server.ViewRowImpl;
    import oracle.jbo.server.ViewRowSetImpl;
    
    // ---------------------------------------------------------------------
    // ---    File generated by Oracle ADF Business Components Design Time.
    // ---    Wed Sep 18 15:59:44 CDT 2013
    // ---    Custom code may be added to this class.
    // ---    Warning: Do not modify method signatures of generated methods.
    // ---------------------------------------------------------------------
    
    public class UsersVOImpl extends ViewObjectImpl {
    
        private static ADFLogger LOGGER = ADFLogger.createADFLogger(UsersVOImpl.class);
        private long hitCount = 0;
    
        /**
         * This is the default constructor (do not remove).
         */
        public UsersVOImpl () {
        }
    
        /**
         * executeQueryForCollection - overridden for custom java data source support.
         */
        protected void executeQueryForCollection (Object qc, Object[] params, int noUserParams) {
    
             List<String> usersList = new ArrayList<String>();
             usersList.add("Brad");
             usersList.add("Adam");
             usersList.add("Aaron");
             usersList.add("Fred");
             usersList.add("Charles");
             usersList.add("Charlie");
             usersList.add("Jimmy");
    
             Iterator usersIterator = usersList.iterator();
             setUserDataForCollection(qc, usersIterator);
             hitCount = usersList.size();
             super.executeQueryForCollection(qc, params, noUserParams);
    
        } // end executeQueryForCollection
    
        /**
         * hasNextForCollection - overridden for custom java data source support.
         */
        protected boolean hasNextForCollection (Object qc) {
    
             Iterator usersListIterator = (Iterator)getUserDataForCollection(qc);
             if (usersListIterator.hasNext()) {
         
                 return true;
    
             } else {
    
                 setFetchCompleteForCollection(qc, true);
                 return false;
    
             } // end if
    
        } // end hasNextForCollection
    
        /**
         * createRowFromResultSet - overridden for custom java data source support.
         */
        protected ViewRowImpl createRowFromResultSet (Object qc, ResultSet resultSet) {
    
             Iterator usersListIterator = (Iterator)getUserDataForCollection(qc);
             String user = (String)usersListIterator.next();
             ViewRowImpl viewRowImpl = createNewRowForCollection(qc);
    
             try {
    
                 populateAttributeForRow(viewRowImpl, 0, user.toString());
    
             } catch (Exception e) {
    
                 LOGGER.severe("Error Initializing Data", e);
                 throw new JboException(e);
    
             } // end try/catch
    
             return viewRowImpl;
    
        } // end createRowFromResultSet
    
        /**
         * getQueryHitCount - overridden for custom java data source support.
         */
        public long getQueryHitCount (ViewRowSetImpl viewRowSet) {
             return hitCount;
        } // end getQueryHitCount
    
        @Override
        protected void create () {
    
             getViewDef().setQuery(null);
             getViewDef().setSelectClause(null);
             setQuery(null);
    
        } // end create
    
        @Override
        protected void releaseUserDataForCollection (Object qc, Object rs) {
    
             Iterator usersListIterator = (Iterator)getUserDataForCollection(qc);
             usersListIterator = null;
             super.releaseUserDataForCollection(qc, rs);
    
        } // end releaseUserDataForCollection
    
    } // end class
    
    

    <af:inputListOfValues id="userName" popupTitle="Search and Select: #{bindings.UserName.hints.label}" value="#{bindings.UserName.inputValue}"
                                                  label="#{bindings.UserName.hints.label}" model="#{bindings.UserName.listOfValuesModel}" required="#{bindings.UserName.hints.mandatory}"
                                                  columns="#{bindings.UserName.hints.displayWidth}" shortDesc="#{bindings.UserName.hints.tooltip}" autoSubmit="true"
                                                  searchDesc="#{bindings.UserName.hints.tooltip}"                                           
                                                  simple="true">
                              <f:validator binding="#{bindings.UserName.validator}"/>                       
    </af:inputListOfValues>
    
    
    
    

    I found a solution to this problem. It seems that, when using a view object programmatic that has a transient as its primary key attribute, you need to override the methods in the ViewObjectImpl so that he knows how to locate the line related to the primary key when the view object records are not in the cache. That's why it would work properly sometimes, but not always. Here are the additional methods that you must override. The logic you use in the retrieveByKey would be on a view view object database object and would be different if you had a primary key consisting of multiple attributes.

    @Override
    protected Row[] retrieveByKey (ViewRowSetImpl viewRowSetImpl, Key key, int i) {
        return retrieveByKey(viewRowSetImpl, null, key, i, false);
    }
    
    @Override
    protected Row[] retrieveByKey (ViewRowSetImpl viewRowSetImpl, String string, Key key, int i, boolean b) {
    
        RowSetIterator usersRowSetIterator = this.createRowSet(null);
        Row[] userRows = usersRowSetIterator.getFilteredRows("UserId", key.getAttribute(this.getAttributeIndexOf("UserId")));
        usersRowSetIterator.closeRowSetIterator();
        return userRows;
    
    }
    
    @Override
    protected Row[] retrieveByKey (ViewRowSetImpl viewRowSetImpl, Key key, int i, boolean b) {
        return retrieveByKey(viewRowSetImpl, null, key, i, b);
    }
    
  • Query result set...

    I can't determine a good word in my question. So, I think that my pseudocode below will be sufficient for this purpose.

    Oracle version: 11.2 g

    Data set
    WITH temp AS
    (
     SELECT 1 col1, 1 day FROM dual UNION ALL
     SELECT 2 col1, 1 day FROM dual UNION ALL
     SELECT 3 col1, 1 day FROM dual UNION ALL
     SELECT 4 col1, 1 day FROM dual UNION ALL
     SELECT 5 col1, 1 day FROM dual UNION ALL
     SELECT 6 col1, 1 day FROM dual UNION ALL
     SELECT 7 col1, 2 day FROM dual UNION ALL
     SELECT 8 col1, 2 day FROM dual UNION ALL
     SELECT 9 col1, 2 day FROM dual UNION ALL
     SELECT 10 col1,2 day FROM dual 
    )
    SELECT *
      FROM temp
    The result of the above query:
    COL1     DAY
    1     1
    2     1
    3     1
    4     1
    5     1
    6     1
    7     2
    8     2
    9     2
    10     2
    You the WISH result set:
    DAY COL_TOTAL
    1   21  
    2   55   -- 21 + 33 (the sum of day 1 + the sum of day 2)
    I realize that I can get the desired result, set above the code below. However, for my I have several other data points and 100 separate days I need to do for their actual issue. In doing so, a statement of the UNION 100 isn't exactly going to work.
    WITH temp AS
    (
     SELECT 1 col1, 1 day FROM dual UNION ALL
     SELECT 2 col1, 1 day FROM dual UNION ALL
     SELECT 3 col1, 1 day FROM dual UNION ALL
     SELECT 4 col1, 1 day FROM dual UNION ALL
     SELECT 5 col1, 1 day FROM dual UNION ALL
     SELECT 6 col1, 1 day FROM dual UNION ALL
     SELECT 7 col1, 2 day FROM dual UNION ALL
     SELECT 8 col1, 2 day FROM dual UNION ALL
     SELECT 9 col1, 2 day FROM dual UNION ALL
     SELECT 10 col1,2 day FROM dual 
    )
    SELECT SUM(col1) AS col_total
      FROM temp
     WHERE day <= 1
    UNION ALL
    SELECT SUM(col1) AS col_total
      FROM temp
     WHERE day <= 2
    Published by: user652714 on August 13, 2012 21:55

    Hello

    I now see what you want. You can use this:

    select *
    from tt
    order by col_1;
    
         COL_1        DAY
    ---------- ----------
             1          1
             2          1
             3          1
             4          1
             5          1
             6          1
             7          2
             8          2
             9          2
            10          2
    
    10 rows selected.
    
    select day, sum(total) over  (order by  day) COL_TOTAL
    from
    (select day, sum(col_1) TOTAL
    from tt
    group by day
    );
    
        DAY  COL_TOTAL
    ---------- ----------
             1         21
             2         55
    
    2 rows selected.
    
  • How to merge several pull random requests in a result set?

    See tables: http://dl.dropbox.com/u/10356431/Shared/screen.png

    Can someone help me build a query that will randomly get questions based on the category and the level of difficulty and the total number of questions in the Question Set Config. table.

    I built a.

    SELECT c.question_id
    s.question_set_id
    OF qm_question_category c
    s qm_question_set_cfg
    WHERE (c.category_id = s.category_id
    AND c.difficulty_level = s.difficulty_level
    )
    AND ROWNUM < = (SELECT SUM (total_questions)
    OF qm_question_set_cfg
    WHERE question_set_id = 101138) / * Set ID * /.
    ORDER BY dbms_random.value

    It retrieves the total number of questions randomly from the existing questions based on the categories and the level of difficulty.

    But what I want is to * first go get the questions in each category + difficulty at random, then merge these lines * in a single result set. (For eg. 10 questions random category 1, Category2 10 to 10 of CategoryN as stated in the Question Set Config)

    Hello.

    Here's one way:

    --'sample data'
    WITH questions AS
    (
         SELECT
              LEVEL question_id,
              'Q'||LPAD(LEVEL,3,'0')||'?' question_text FROM DUAL
         CONNECT BY LEVEL <=500
    ),
    question_category AS
    (
         SELECT
              10-MOD(LEVEL,10) category_id,
              LEVEL question_id,
              MOD(LEVEL,3)+1 difficulty_level
         FROM dual
         CONNECT BY LEVEL <=1000
    ),
    question_set AS
    (
         SELECT 1 set_id, 'set_1' set_name FROM DUAL UNION
         SELECT 2 set_id, 'set_2' set_name FROM DUAL
    ),
    question_set_config AS
    (
         SELECT 1 set_config_id, 1 set_id, 1 category_id, 3 difficulty_level, 3 no_of_questions FROM dual UNION
         SELECT 2 set_config_id, 1 set_id, 2 category_id, 2 difficulty_level, 5 no_of_questions FROM dual UNION
         SELECT 3 set_config_id, 2 set_id, 3 category_id, 2 difficulty_level, 4 no_of_questions FROM dual UNION
         SELECT 4 set_config_id, 2 set_id, 4 category_id, 1 difficulty_level, 6 no_of_questions FROM dual
    ),
    ------------------------ 'end of sample data' ----------------------------------
    questions_categories AS
    (
         SELECT
              qc.category_id,
              q.question_id,
              q.question_text,
              qc.difficulty_level,
              ROW_NUMBER() OVER (PARTITION BY qc.category_id,qc.difficulty_level ORDER BY dbms_random.value) rn
         FROM
              questions q,
              question_category qc
         WHERE
              q.question_id = qc.question_id
    )
    SELECT
         qs.set_id,
         qc.question_id,
         qc.question_text,
         qc.category_id,
         qc.difficulty_level
    FROM
         question_set_config qsc,
         question_set qs,
         questions_categories qc
    WHERE
         qsc.set_id = qs.set_id AND
         qsc.difficulty_level = qc.difficulty_level AND
         qsc.category_id = qc.category_id AND
         qc.rn <= qsc.no_of_questions
    ORDER BY 1,4;
    
    SET_ID     QUESTION_ID     QUESTION_TEXT     CATEGORY_ID     DIFFICULTY_LEVEL
    ------     -----------     -------------     -----------     ----------------
    1     29          Q029?          1          3
    1     359          Q359?          1          3
    1     449          Q449?          1          3
    1     298          Q298?          2          2
    1     328          Q328?          2          2
    1     88          Q088?          2          2
    1     238          Q238?          2          2
    1     208          Q208?          2          2
    2     187          Q187?          3          2
    2     7          Q007?          3          2
    2     247          Q247?          3          2
    2     367          Q367?          3          2
    2     486          Q486?          4          1
    2     276          Q276?          4          1
    2     186          Q186?          4          1
    2     456          Q456?          4          1
    2     156          Q156?          4          1
    2     66          Q066?          4          1
    

    I hope this helps.

    Kind regards.

  • Remove duplicates from the result set

    Here's a challenge question that I was playing with a my free time during the work.

    I assume you have the basic HR example somewhere around (I hope is not in production).

    Let's say you want to get employees from the employees table whose name is similar to another employee last name.
    The easiest way is to join the two tables with a join condition that checks for the name and employee id. Here's what I came with.

    *************

    Select e1.last_name, e1.first_name b, e2.last_name c, e2.first_name d
    employees employees join e1 e2
    on (e1.last_name = e2.employee_id <>e2.last_name and e1.employee_id)
    order by one;

    ************

    The above query returns 10 rows. The first and the second are essentially the same. It is similarly, 3 & 4, 5 & 6, 7 and 8 and 9 and 10. The question is: is there a way that allows me to get rid of using only sql duplicate rows from the result set of this query. I sat on it for 15 minutes and I couldn't know. I'll try to watch my completed work once again.

    Example:

    SQL> column a format a10
    SQL> column b format a10
    SQL> column c format a10
    SQL> column d format a10
    SQL>
    SQL>
    SQL> select e1.last_name a , e1.first_name b, e2.last_name c, e2.first_name d
      2  from employees e1 join employees e2
      3  on ( e1.last_name = e2.last_name and e1.employee_id != e2.employee_id)
      4  where e1.employee_id < e2.employee_id
      5  order by a;
    
    A          B          C          D
    ---------- ---------- ---------- ----------
    Cambrault  Gerald     Cambrault  Nanette
    Grant      Kimberely  Grant      Douglas
    King       Steven     King       Janette
    Smith      Lindsey    Smith      William
    Taylor     Jonathon   Taylor     Winston
    
    SQL>
    
  • Retrieve and display a result set using the dynamic sql?

    Hi all

    How would display a result set in Oracle using the dynamic SQL? Reason being, the table where I'd retrieve and display the result set is a GLOBAL TEMP TABLE created in a stored procedure. If I try to use the loop as usual, the compiler complains that the table does not exist. This makes sense because the compiler does not recognize the table because it is created dynamically. Here is an example:

    create or replace PROCEDURE maketemptab IS
    sql_stmt VARCHAR2 (500);
    OutputString VARCHAR2 (50);

    BEGIN
    -create temporary table
    sql_stmt: = ' CREATE of TABLE TEMPORARY GLOBAL globtemptab (id NUMBER, col1 VARCHAR2 (50))';
    EXECUTE IMMEDIATE sql_stmt;
    dbms_output.put_line ('... created table ');

    -Insert a row into the temporary table
    sql_stmt: = "INSERT INTO globtemptab values (1, 'some data of a test')';"
    EXECUTE IMMEDIATE sql_stmt;
    dbms_output.put_line ('... inserted row ');

    -Insert a row into the temporary table
    sql_stmt: = ' INSERT INTO globtemptab values (2, "some more test data");
    EXECUTE IMMEDIATE sql_stmt;
    dbms_output.put_line ('... inserted row ');

    -Select the row on temporary table
    sql_stmt: = 'SELECT col1 FROM globtemptab WHERE id = 1';
    EXECUTE IMMEDIATE sql_stmt INTO outputstring;
    dbms_output.put_line ('... selected line: ' | outputstring);

    -drop temporary table
    sql_stmt: = 'DROP TABLE globtemptab;
    EXECUTE IMMEDIATE sql_stmt;
    dbms_output.put_line ('... moved table ');

    -display the result set
    for tabdata loop (select col1 from globtemptab)
    dbms_output.put_line ('... test of recovered data are' | tabdata.col1)
    end loop;
    end;


    In short, how to rewrite the SQL below the comment "to display the result set" using the dynamic sql?

    Thank you
    Amedeo.

    Hello

    Try this:

    CREATE OR REPLACE PROCEDURE maketemptab IS
       sql_stmt     VARCHAR2(500);
       outputstring VARCHAR2(50);
       v_cursor     SYS_REFCURSOR;
       v_col1       VARCHAR2(30);
    BEGIN
       -- create temp table
       sql_stmt := 'CREATE GLOBAL TEMPORARY TABLE globtemptab(id NUMBER, col1 VARCHAR2(50))';
       EXECUTE IMMEDIATE sql_stmt;
       dbms_output.put_line('...table created');
    
       -- insert row into temp table
       sql_stmt := 'INSERT INTO globtemptab values (1, ''some test data'')';
       EXECUTE IMMEDIATE sql_stmt;
       dbms_output.put_line('...row inserted');
    
       -- insert row into temp table
       sql_stmt := 'INSERT INTO globtemptab values (2, ''some more test data'')';
       EXECUTE IMMEDIATE sql_stmt;
       dbms_output.put_line('...row inserted');
    
       -- select row from temp table
       sql_stmt := 'SELECT col1 FROM globtemptab WHERE id=1';
       EXECUTE IMMEDIATE sql_stmt
          INTO outputstring;
       dbms_output.put_line('...row selected: ' || outputstring);
    
       OPEN v_cursor FOR 'SELECT col1 FROM globtemptab';
    
       LOOP
          FETCH v_cursor
             INTO v_col1;
          EXIT WHEN v_cursor%NOTFOUND;
          dbms_output.put_line('...test data retrieved is' || v_col1);
       END LOOP;
       CLOSE v_cursor;
    
       -- drop temp table
       sql_stmt := 'DROP TABLE globtemptab';
       EXECUTE IMMEDIATE sql_stmt;
       dbms_output.put_line('...table dropped');
    END;
    /
    

    Kind regards

  • How to test a procedure returns the result set

    Hello

    I have a following code:

    {color: #0000ff} create or replace the TYPES of PACKAGING
    AS
    type cursorType is ref cursor;
    end;

    create or replace PROCEDURE GetAllCategories (p_cursor in the Types.cursorType)
    AS
    Start
    Open p_cursor for SELECT * CATEGORY;
    end; {color}

    I would like to test the procedure of * {color: #000000} visualization output resultset {color} *. How can I do with SQL Developer?
    In fact, when select RUN in SQL Developer, I got the following code:

    DECLARE
    P_CURSOR types.cursorType;
    BEGIN

    GetAllCategories (P_CURSOR = & gt; P_CURSOR);
    END;

    When I run it, it is successful but there is no result set displayed. However if I execute SELECT * FROM category only in the SQL Editor, I see the result set in the grid. Then where the result set did when he went through the procedure?

    Thanks in advance for any help.

    Published by: CarbonFiber Sep 22, 2008 20:52

    Is a simple way with sqlplus

    SQL> create or replace package types
      2  as
      3     type cursortype is ref cursor;
      4  end;
      5  /
    
    Package created.
    
    SQL> create or replace procedure getallemp(p_cursor in out types.cursortype )
      2  as
      3  begin
      4     open p_cursor for select * from emp;
      5  end;
      6  /
    
    Procedure created.
    
    SQL> var lcursor refcursor
    SQL>
    SQL> exec getallemp(:lcursor)
    
    PL/SQL procedure successfully completed.
    
    SQL> print lcursor
    
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO        DIV
    ---------- ---------- --------- ---------- --------- ---------- ---------- ---------- ----------
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20         10
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30         10
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20         10
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30         10
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30         10
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10         10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20         10
          7839 KING       PRESIDENT            17-NOV-81       5000                    10         10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30         10
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20         10
    
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO        DIV
    ---------- ---------- --------- ---------- --------- ---------- ---------- ---------- ----------
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30         10
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20         10
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10         10
    
    14 rows selected.
    

    Thank you
    Knani.

  • How to dynamically access the SQLite result set?

    I want to dynamically access the SQLite result set. Since webworks does not support the "PRAGMA table_info (table_name); I save all newly created information tables in a single two-column table called schema. schema has two columns, table_name, and column_name.

    So I created a function to dynamically access the data in the table. I use the item = results.rows.item (i) and that the data access with item.column line.

    column is a variable that will receive the value of a schema representative of column_name. When I alert (column) I get the column_name is correct, but when I used item.column my results are "not defined".

    any advice on how to solve this issue.

    I managed to solve this issue. The solution is the following: the normal way to access the data of the variable item = results.rows.item (i) is item.column (where the column is the name of the column in the database table. To access the data dynamically, I Specifies a var col1 to assign different values in col1. I then access the data in the database using point [col1] hope that makes sense. If you need a further explanation contact me at [email protected]

Maybe you are looking for