Help with APP_USER in SQL query

Hi,
I would like to extract a user details in one Item of DML form based on the Logged user and standard authentication schema.
I have this query in the Item:
select ANALYST_FIRST_NAME ||' '|| ANALYST_LAST_NAME d, ANALYST_ID r from QTMT_ANALYST where EMAIL = :APP_USER The User in the session is equal to the EMAIL value. In fact, the value in the session is upper case and the other in the database is lower case. I believe that that is not relevant anyway.
The query do not bring any value. Could you please let me know what I have got wrong?
APEX: 4.2
Item Source Type: SQL Query (return single value)
Thank you and best regards,
Vladimir

To be on the safe side you should uppercase both sides of the equation. It could be that the username is entered in lower case.
But if you think that your query is correct, test it by using a literal instead of the user name.
select ANALYST_FIRST_NAME ||' '|| ANALYST_LAST_NAME d
from QTMT_ANALYST
where upper(EMAIL) = upper(:APP_USER);for testing purposes use something like this:
select ANALYST_FIRST_NAME ||' '|| ANALYST_LAST_NAME d
from QTMT_ANALYST
where upper(EMAIL) = upper('[email protected]');Edited by: Sven W. on Oct 23, 2012 1:30 PM
APEX: 4.2
Item Source Type: SQL Query ( return single value )I just noticed that you use an item which has this as the SQL source. This works only if the sql returns one row and one column only. Therefore I removed the second column from your query.
Edited by: Sven W. on Oct 23, 2012 1:33 PM

Similar Messages

  • Need Help with Creating the SQl query

    Hi,
    SQL query gurus...
    INFORMATION:
    I have two table, CURRENT and PREVIOUS.(Table Defs below).
    CURRENT:
    Column1 - CURR_PARENT
    Column2 - CURR_CHILD
    Column3 - CURR_CHILD_ATTRIBUTE 1
    Column4 - CURR_CHILD_ATTRIBUTE 2
    Column5 - CURR_CHILD_ATTRIBUTE 3
    PREVIOUS:
    Column1 - PREV_PARENT
    Column2 - PREV_CHILD
    Column3 - PREV_CHILD_ATTRIBUTE 1
    Column4 - PREV_CHILD_ATTRIBUTE 2
    Column5 - PREV_CHILD_ATTRIBUTE 3
    PROBLEM STATEMENT
    Here the columns 3 to 5 are the attributes of the Child. Lets assume that I have two loads, One Today which goes to the CURRENT table and one yesterday which goes to the PREVIOUS table. Between these two loads there is a CHANGE in the value for Columns either 3/4/5 or all of them(doesnt matter if one or all).
    I want to determine what properties for the child have changed with the help of a MOST efficient SQL query.(PARENT+CHILD is unique key). The Database is ofcourse ORACLE.
    Please help.
    Regards,
    Parag

    Hi,
    The last message was not posted by the same user_name that started the thread.
    Please don't do that: it's confusing.
    Earlier replies give you the information you want, with one row of output (maximum) per row in current_tbl. There may be 1, 2 or 3 changes on a row.
    You just have to unpivot that data to get one row for every change, like this:
    WITH     single_row  AS
         SELECT     c.curr_parent
         ,     c.curr_child
         ,     c.curr_child_attribute1
         ,     c.curr_child_attribute2
         ,     c.curr_child_attribute3
         ,     DECODE (c.curr_child_attribute1, p.prev_child_attribute1, 0, 1) AS diff1
         ,     DECODE (c.curr_child_attribute2, p.prev_child_attribute2, 0, 2) AS diff2
         ,     DECODE (c.curr_child_attribute3, p.prev_child_attribute3, 0, 3) AS diff3
         FROM     current_tbl    c
         JOIN     previous_tbl   p     ON  c.curr_parent     = p.prev_parent
                                AND c.curr_child     = p.prev_child
         WHERE     c.curr_child_attribute1     != p.prev_child_attribute1
         OR     c.curr_child_attribute2     != p.prev_child_attribute2
         OR     c.curr_child_attribute3     != p.prev_child_attribute3
    ,     cntr     AS
         SELECT     LEVEL     AS n
         FROM     dual
         CONNECT BY     LEVEL <= 3
    SELECT     s.curr_parent     AS parent
    ,     s.curr_child     AS child
    ,     CASE     c.n
              WHEN  1  THEN  s.curr_child_attribute1
              WHEN  2  THEN  s.curr_child_attribute2
              WHEN  3  THEN  s.curr_child_attribute3
         END          AS attribute
    ,     c.n          AS attribute_value
    FROM     single_row     s
    JOIN     cntr          c     ON     c.n IN ( s.diff1
                                    , s.diff2
                                    , s.diff3
    ORDER BY  attribute_value
    ,            parent
    ,            child
    ;

  • Continuation-Please help with a complex sql query

    Hi all,
    Thanks a lot for your suggestions and inputs in the last thread of this post.
    With the help of your suggested approach,i went ahead and was able to get some more data in the format as needed..I worked on gradually adding one table after another exactly as the data is required stepwise.But,still I am facing issues with displaying them.
    there are many issues I am not able to do and would appreciate if you please have a look at my latest modified SELECT given below and help me writing it to get the display as needed.
    Below,is the attempted query i tried out using your inputs.But,am stuck and need your help in writing it.
    **Here,there is 1 ->MANY lines for the t_objective_id--->This has many learning_record_ids which i want to group by the unique objective_id.
    Also,prior to that,there is a tplan_id---->which has MANY t_objective_id's
    SELECT DECODE (LAG (firstname, 1, 0) OVER (ORDER BY firstname),
                   firstname, ' ',
                   firstname
                  ) firstname,
           DECODE (LAG (emplid, 1, 0) OVER (ORDER BY emplid),
                   emplid, ' ',
                   emplid
                  ) emplid,
           DECODE (LAG (tplan_name, 1, 0) OVER (ORDER BY tplan_name),
                   tplan_name, ' ',
                   tplan_name
                  ) tplan_name,
                  tplan_id,
                  DECODE (LAG (activities, 1, 0) OVER (ORDER BY activities),
                   activities, ' ',
                   activities
                  ) activities,
                  activities,
                  --activities,
           DECODE (LAG (t_objective_id, 1, 0) OVER (ORDER BY t_objective_id),
                   t_objective_id, ' ',
                   t_objective_id
                  ) t_objective_id,           
                   completed_activities,required_credits,
          DECODE (LAG (learning_record_id, 1, 0) OVER (ORDER BY learning_record_id),
                   learning_record_id, ' ',
                   learning_record_id
                  ) learning_record_id,           
                   catalog_item_name,catalog_item_type           
      FROM (SELECT test_cp.firstname, test_op.emplid, tp.tplan_name,tp.tplan_id,FN_TP_GET_CMPLTD_ACT_CNT(tp.tplan_id,test_lp.lp_person_id,'1862') activities,
                   test_tpo.t_objective_id,
                   (  fn_tp_obj_comp_req_act_cdt (test_lp.lp_person_id,
                                                  tp.tplan_id,
                                                  test_tpo.t_objective_id,
                                                  tp.is_credit_based
                    + fn_tp_obj_comp_opt_act_cdt (test_lp.lp_person_id,
                                                  tp.tplan_id,
                                                  test_tpo.t_objective_id,
                                                  tp.is_credit_based
                   ) completed_activities,test_tpo.required_credits,lr.learning_record_id,lr.catalog_item_name,lr.catalog_item_type
              FROM test_learning_plan test_lp,
                   test_training_plan tp,
                   test_person test_cp,
                   test_org_person test_op,test_tp_learning_activity test_tplplr,
                   test_tp_objective test_tpo,test_learning_record lr,test_train_obj_activity tpobjact
             WHERE test_lp.lp_person_id = '1862188559'
               AND test_cp.person_id = test_lp.lp_person_id
               AND tp.tplan_id = 'tplan200811200632352287621599'
               AND test_tpo.t_objective_id = tpobjact.t_objective_id
               AND test_lp.LP_CATALOG_HIST_ID = tp.tplan_id
               AND test_tplplr.tp_lp_lr_id =test_lp.learning_plan_id
               AND test_tplplr.activity_lp_lr_id = lr.learning_record_id
               AND lr.LR_CATALOG_HISTORY_ID = tpobjact.activity_id
               AND test_op.o_person_id = test_cp.person_id
               AND test_tpo.tplan_id = tp.tplan_id)
    If we see the outer SELECT ---then one of the main issues is for EACH t_objective_id----->There are n learning_record_ids.
    But,this select only shows 1 learning_record_id for each objective_id which is wrong.
    Similarly,the data displayed isnot proper.
    Below is the way I am getting the data now from the above SELECT.
    Note:- FIRSTNAME is not correctly displayed.
    FIRSTNAME     EMPLID     TPLAN_NAME     TPLAN_ID     ACTIVITIES     ACTIVITIES_1  
                      001                TP1          tplan1          5          5
    TESTNAME                                              tplan1           5          
    Continuation of the other columns of the same rows--**couldnt paste it properly so.
    T_OBJECTIVE_ID     COMPLETED_ACTIVITIES     REQUIRED_CREDITS     LEARNING_RECORD_ID        CATALOG_ITEM_NAME     CATALOG_ITEM_TYPE
              obj1               1                         5                         lr1                            C1                          Course
                    obj2               4                        4          

    Something like this might solve your problem ->
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    Elapsed: 00:00:00.00
    satyaki>
    satyaki>
    satyaki>select * from emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7521 WARD       SALESMAN        7698 22-FEB-81     226.88        500         30
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1815       1400         30
          7788 SCOTT      ANALYST         7566 19-APR-87     598.95                    20
          7839 KING       PRESIDENT            17-NOV-81       7260                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       2178          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87     159.72                    20
          7900 JAMES      CLERK           7698 03-DEC-81     1379.4                    30
          7902 FORD       ANALYST         7566 03-DEC-81    5270.76                    20
          7934 MILLER     CLERK           7782 23-JAN-82     1887.6                    10
          7566 Smith      Manager         7839 23-JAN-82       1848          0         10
          7698 Glen       Manager         7839 23-JAN-82       1848          0         10
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7599 BILLY      ANALYST         7566 10-JUN-09       4500                    30
    12 rows selected.
    Elapsed: 00:00:00.00
    satyaki>
    satyaki>
    satyaki>
    satyaki>
    satyaki>select decode(lag(job,1,null) over(order by job),'CLERK','CK',
      2                                                   'SALESMAN', 'SM',
      3                                                   'ANALYST','AL',
      4                                                   'BO') res
      5  from emp;
    RE
    BO
    AL
    AL
    AL
    CK
    CK
    CK
    BO
    BO
    BO
    SM
    RE
    SM
    12 rows selected.
    Elapsed: 00:00:00.01
    satyaki>
    satyaki>
    satyaki>select MAX(decode(lag(job,1,null) over(order by job),'CLERK','CK',
      2                                                   'SALESMAN', 'SM',
      3                                                   'ANALYST','AL',
      4                                                   'BO')) res
      5  from emp;
    select MAX(decode(lag(job,1,null) over(order by job),'CLERK','CK',
    ERROR at line 1:
    ORA-30483: window  functions are not allowed here
    Elapsed: 00:00:00.01
    satyaki>
    satyaki>select MAX(res)
      2  from (
      3          select decode(lag(job,1,null) over(order by job),'CLERK','CK',
      4                                                           'SALESMAN', 'SM',
      5                                                           'ANALYST','AL',
      6                                                           'BO') res
      7          from emp
      8     );
    MA
    SM
    Elapsed: 00:00:00.00
    satyaki>
    satyaki>Regards.
    Satyaki De.

  • Help with a advanced SQL query

    I have a table with the help of standard lengths of material. (tblStdLength)
    In another table are the lengths that are in stock at the material. (tblOnStock)
    I would want to match these two tables to find out how much of the stock of standard lengths you have in stock the table.
    If the length is longer than the nearest standard length, the drag of the excess down to the nearest standradlängd if there is an X "CUT field.
    However, I have encountered a problem and can not solve this ...
    Ex:
    Material Cable23 have 4 standard lengths in Table tblStdLength:
    {code}
    Material          StdLength
    Cable23          |     2000
    Cable23          |     4000
    Cable23          |     6000
    Cable23          |     8000
    Materials Cable23 have the following lengths in stock in Table tblOnStock:
    Material          Factor          Length          TotalQty          Cut
    Cable23          |     1     |     383     |     383          |          
    Cable23          |     1     |     424     |     424          |
    Cable23          |     1     |     998     |     998          |
    Cable23          |     1     |     1000     |     1000          |
    Cable23          |     3     |     4000     |     12000          |     X
    Cable23          |     1     |     4234     |     4234          |     X
    {code}
    In this mode, shall the lengths of 12000 + 4000 include in the calculation of the total stock of standard lengths.
    The answer should be 16000.
    4000, it gets of 4234. It has X on the 'Cut' field and then it round down to the nearest standard length.
    How do I do this best? Hope I explained so you understand ...

    Hi again,
    SQL works great when there are several lengths (rows) in the table tblStdlength. But sometimes there is only one standard length per matrial in the table (1 row), then it does not work. Why? Assumes lead function that there should be several rows?
    with tblStd as
           select Material
                    , stdlength
                    , lead(stdlength) over (partition by material order by stdlength) hstdlength
                    from tblStdlength
    select t.Material
             , sum(floor(s.total_qty/t.stdlength)*t.stdlength) tot_quantity
         from tblStd t, tblonstock s
                where t.material=s.material
                          and s.length >= t.stdlength
                          and s.length< t.hstdlength
                group by t.material

  • Help with SYSDATE in SQL query

    Hi all,
    I'm trying to select some data from table base on SYSDATE. The below query does not return any data.
    My query is:
    select count(TICKET_ID) "ECEMEA" from QTMT_TICKETS where STATUS_ID=1 and TEAM_ID=3 and RECEIVED_DATE=sysdate
    Could you please let me know, why this does not work? Date format in my application is: DD-MMM-YY (16-AUG-12). In the database the dates are stored in this format: MM/DD/YYYY (08/25/2012). Does it mean, that I have to play with the format?
    Please let me know.
    Thank you and best regards,
    Vladimir

    user13277783 wrote:
    Hi all,Please update your forum profile with a real handle instead of "user13277783".
    I'm trying to select some data from table base on SYSDATE. The below query does not return any data.
    My query is:
    select count(TICKET_ID) "ECEMEA" from QTMT_TICKETS where STATUS_ID=1 and TEAM_ID=3 and RECEIVED_DATE=sysdate
    Always post code wrapped in <tt>\...\</tt> tags, as described in the FAQ.
    Could you please let me know, why this does not work? Date format in my application is: DD-MMM-YY (16-AUG-12). In the database the dates are stored in this format: MM/DD/YYYY (08/25/2012). Assuming RECEIVED_DATE is actually of type DATE (and it should be), then no format is applied to dates until they are converted for display, however there may be a time component stored that is not visible in the default date display format. Try
    select count(TICKET_ID) "ECEMEA"
    from QTMT_TICKETS
    where STATUS_ID=1
    and TEAM_ID=3
    and RECEIVED_DATE >= trunc(sysdate)
    and RECEIVED_DATE < trunc(sysdate) + 1

  • Help needed in framing SQL query.

    Hi,
    I have table having following schema:
    PRODUCT_ID         INT
    DATE                   DATETIME
    ITEMS_SOLD         INT
    This table contains data for a week (sunday to saturday). I want to write an SQL query to get (filter out) PRODUCT_ID of products which has same no. of ITEMS_SOLD for all 7 days. Also for given PRODUCT_ID I need to find the longest period of successive days where the no. of ITEMS_SOLD is same for all days in this period. Eg.(PRODUCT_ID 23 was sold as following along the week in no. of units sold: 4,6,6,6,6,7,4 .So the longest period is *4 days* from Monday to Thursday.) The first condition is special case of second condition where no. of days is 7.
    Any help to get the SQL query will be appreciated.
    Thanks,
    Akshay.

    PRODUCT_ID      DATE           ITEMS_SOLD
    1          10/10/2011     3
    1          11/10/2011     3
    1          12/10/2011     3
    1          13/10/2011     3
    1           16/10/2011     5
    2          10/10/2011     4
    2           11/10/2011     4
    2          12/10/2011     4
    2          13/10/2011     4
    2           14/10/2011     4
    2          15/10/2011     4
    2          16/10/2011     4
    Output:
    PRODUCT_ID ITEMS_SOLD NO_OF_DAYS
    1          3                4     
    2          4               7
    Explanation of results:
    The table to be queried contains data for 1 week: from 10/10/2011(Sunday) to 16/10/2011(Saturday). Now, product with PRODUCT_ID '1' was sold on dates 10,11,12,13,16. Out of these 5 days 3 units were sold on 4 successive days (from 10-13). So output should be like :
    PRODUCT_ID ITEMS_SOLD NO_OF_DAYS
    1          3               4     
    as longest period of successive days is 4 where same no. of units were sold i.e 3 units (other period is of 1 day on 16th ).
    For PRODUCT_ID 2 we have only one period of 7 days where 4 units were sold each day. So we output :
    PRODUCT_ID ITEMS_SOLD NO_OF_DAYS
    2           4               7
    Other case where same PRODUCT_ID have different units sold on each day should be ignored.
    I hope that clarifies the problem more. Let me know in case I have missed out anything which should have been mentioned.
    -Akshay.

  • Help me write a SQL query; urgent

    Hi, can somebody please help me write a SQL query.
    I have 3 tables each with the same column names (Col1, Col2, Col3). Col1 is PK with Unique Constraint.
    I wanted to add values of Col2 and Col3 (from all 3 tables) and put it in a separate table (i.e aggregated) of all values found in Col1.
    Does anybody help me please ?
    thanks alot.

    Please don't mark your question as urgent. You've been around here long enough that you should know that it will not get your question anwered any faster, and may just irritate people into not answering at all.
    I'm not sure exactly what you want.
    Are you saying you want t1.c2 + t1.c3 + t2.c2 + t2.c3+ t3.c2 + t3.c3 for the rows that have the same c1 in all three tables?
    If so, it would be like this, I think: insert into t4
    select t1.c1
    , t1.c2 + t1.c3 + t2.c2 + t2.c3+ t3.c2 + t3.c3
    from t1, t2, t3
    where t2.c1 = t1.c1
    and t3.c1 = t1.c1If that's not what you want, please clarify.
    And next time maybe you should post your SQL question in a SQL forum.

  • With clause in SQL query data model

    Hello!
    isn't it possible to use the with clause in sql query data models?
    for example following query:
    WITH
    a_test as (
    select dummy from dual
    select *
    from a_test
    brings up a "XML Parsing Error: no element found"-error...
    BR Paul

    I tried a slightly different query (see below) and the query worked fine and retrieved data.. I did not get any errors.
    WITH
    a_test as (
    select 'dummy' from dual
    select *
    from a_test
    This works as well.. retrieving the value of the parameter
    WITH
    a_test as (
    select :Test_ID from dual
    select *
    from a_test
    thanks,
    BIPuser

  • Need help in Report From SQL Query

    Hi All,
    I am facing a problem with a report. I need your help.
    I am creating a Report From SQL Query (Portal) with some arguments passed at runtime. I am able to view the output, if the query returns few rows ( arount 1000 rows). But for some inputs it needs to generate >15000 records, at this point the page is getting time out (i think!) and showing error page. I am able to execute query from the SQL Plus console ot using TOAD editor. Here the query is not taking more that 2 mins time to show the result.
    If i am executing from Portal i observed that, once i give the appropriate input and hit submit button a new oracle process is getting created for the query on UNIX (I am usign "TOP" command to check processes). The browser page will be shown error page after 5 minutes (i am assuming session time out!) , but on the backend the process will be executed for more than 30 mins.
    I tried also increase the page time out in httpd.conf, but no use.
    The data returned as a result of the query is sized more than 10 MB. Is caching this much data is possible by the browser page? is the returned data is creating any problem here.
    Please help me to find appropriate reasone for the failure?

    user602513 wrote:
    Hi All,
    I am facing a problem with a report. I need your help.
    I am creating a Report From SQL Query (Portal) with some arguments passed at runtime. I am able to view the output, if the query returns few rows ( arount 1000 rows). But for some inputs it needs to generate >15000 records, at this point the page is getting time out (i think!) and showing error page. I am able to execute query from the SQL Plus console ot using TOAD editor. Here the query is not taking more that 2 mins time to show the result.
    If i am executing from Portal i observed that, once i give the appropriate input and hit submit button a new oracle process is getting created for the query on UNIX (I am usign "TOP" command to check processes). The browser page will be shown error page after 5 minutes (i am assuming session time out!) , but on the backend the process will be executed for more than 30 mins.
    I tried also increase the page time out in httpd.conf, but no use.
    The data returned as a result of the query is sized more than 10 MB. Is caching this much data is possible by the browser page? is the returned data is creating any problem here.
    Please help me to find appropriate reasone for the failure?Do you get any errors or warnings or it is just the slow speed which is the issue?
    There could be a variety of reasons for the delayed processing of this report. That includes parameter settings for that page, cache settings, network configurations, etc.
    - explore best optimization for your query;
    - evaluate portal for best performance configuration; you may follow this note (Doc ID: *438794.1* ) for ideas;
    - third: for that particular page carrying that report, you can use caching wisely. browser cache is neither decent for large files, nor practical. instead, explore the page cache settings that portal provides.
    - also look for various log files (application.log and apache logs) if you are getting any warnings reflecting on some kind of processing halt.
    - and last but not the least: if you happen to bring up a portal report with more than 10000 rows for display then think about the usage of the report. Evaluate whether that report is good/useful for anything?
    HTH
    AMN

  • Handling property name with spaces in SQL query

    Hello,
    I have some JSON that looks like this:
        "SystemId": "112234",
        "Parameter": {
            "Total Hours": [
                    "timestamp": "2015-03-15T15:20:00Z",
                    "itemValue": "0"
                    "timestamp": "2015-03-15T15:15:00Z",
                    "itemValue": "296"
    ..and am having trouble with the space in the "Total Hours" property name.  When executing a SQL query, I have tried to reference it as ["Total Hours"], [Total Hours], and "Total Hours", but none of these works.  I
    have also reviewed the "Querying DocumentDB" and "DocumentDB SQL Query Language" documents, but am unclear on how to escape this space.  As this is valid JSON, I would expect to be able to handle it via DocumentDB SQL query, but am
    not certain what I am missing.  
    Thanks for your help.
    Please remember to mark replies as answers if they help you.

    Given that the property with the name with the space contains an array, I attempted to query using:
     SELECT * FROM c WHERE c.Parameter.c["Total Hours"][0].timestamp = "2015-03-15T15:15:00Z" and a few other permutations, but no luck.  Did I misunderstand?
    Please remember to mark replies as answers if they help you.

  • Adding h:dataTable with parameters in SQL query

    Hi,
    I've added a h:datatable to my web app in netbeans. I need this table to display records based on a sql query that contains a WHERE clause that has the currently logged-in user's id.
    Further I need a column with buttons that each perform an operation based on the primary key of the selected row.
    I have no Idea how to do any of this.
    Could anyone please help where to start or point me to a good tutorial.
    Thanks

    Hi BalusC.
    Thanks for the reply.
    Coincidentally I discovered your blog shortly after posting this question, and it has been a great help, thanks!
    I have another related problem now however. I am trying to display messages from the database, and then to allow a user to reply to these messages.
    Everything displays correctly and when I click on the reply link the right text area becomes visible, but for some reason, the action event of the last command button does not fire.
    Could you please help me figure out why it doesn't work.
    I also don't know how to retrieve the message from the right text area input.
    Thanks
    Here's the code in my Home.jsp
    <h:dataTable binding="#{Home.messageTable}" id="messageTable" value="#{Home.messages}" var="dataItem">
                                                                <h:column>
                                                                    <f:facet name="header">
                                                                        <h:outputText value=""/>
                                                                    </f:facet>
                                                                    <h:panelGroup layout="block" styleClass="message_main">
                                                                        <h:outputText styleClass="message_label" value="FROM :"/>
                                                                        <h:outputText styleClass="message_data" value="#{dataItem.sender}"/>
                                                                        <h:outputText styleClass="message_label" value="DATE :"/>
                                                                        <h:outputText styleClass="message_data" value="#{dataItem.dateString}"/>
                                                                        <h:outputText styleClass="message_label" value="SUBJECT :"/>
                                                                        <h:outputText styleClass="message_data" value="#{dataItem.subject}"/>
                                                                        <h:outputText styleClass="message_label" value="MESSAGE :"/>
                                                                        <h:outputText styleClass="message_body" value="#{dataItem.message}"/>
                                                                        <h:commandLink styleClass="message_label" action="#{Home.selectMessage}" value="Reply" />
                                                                        <h:panelGroup rendered="#{dataItem.selected}" layout="block" styleClass="reply_panel">
                                                                            <h:outputText styleClass="message_label" value="Enter reply:"/>
                                                                            <h:inputTextarea styleClass="message_body" />
                                                                            <h:commandButton action="#{Home.sendReply}" styleClass="message_label" value="Send Reply" />
                                                                        </h:panelGroup>
                                                                    </h:panelGroup>
                                                                </h:column>
                                                            </h:dataTable>And the related methods
    public String sendReply()
            Message msg = (Message)messageTable.getRowData();       
            msg.sendReply(?);// Needs the string value of the correct text area
            msg.setSelected(!msg.isSelected());       
            return null;
        public String selectMessage()
            Message msg = (Message)messageTable.getRowData();
            msg.setSelected(!msg.isSelected());
            return null;
        }

  • Help with anonymus pl/sql layout using javascript

    Hi people.
    i want to display some records on a region (using apex 4.2) , this anonymous pl/sql script below shows 3 records from database, but the layout only shows me the first record with it's data, the others 2 records, only show me labels.
    i have verified this same query creating a report and it shows the 3 records correctly.
    i guess i am doing something wrong with this javascript routine or i am surely missing something,
    in this link you can see the layout i am getting. (http://sdrv.ms/Xrv0J8).
    the other little help i need is to display in one row for each record. actually i am getting one row for each label and one row for each data record. i have read and found is something about /div, but i don't no how to change it to get desired results, any suggestion is welcome.
    thanks in advance for any help.
    i am completely new in apex and java script, but i have several years experience in pl/sql.
    The Script :
    Begin
    Declare
    Cursor Deliv Is
    Select item,
    To_char (Delivery, 'month dd, yyyy hh24:mi:ss') Delivery,
    Current_date
    From pending_items;
    Begin
    For A In Deliv Loop
    Begin
    Sys.Htp.P ('<script type="text/javascript">');
    Sys.Htp.P ('function cdtd() {');
    Sys.Htp.P (' var xmas = new Date("' || a.delivery || '")');
    Sys.Htp.P (' var now = new Date();');
    Sys.Htp.P (' var timeDiff = xmas.getTime() - now.getTime();');
    Sys.Htp.P (' if (timeDiff <= 0) {');
    Sys.Htp.P (' clearTimeout(timer);');
    -- Sys.Htp.P (' document.write("Some Text Here!");');
    Sys.Htp.P (' // Run any code needed for countdown completion here');
    Sys.Htp.P (' }');
    Sys.Htp.P (' var seconds = Math.floor(timeDiff / 1000);');
    Sys.Htp.P (' var minutes = Math.floor(seconds / 60);');
    Sys.Htp.P (' var hours = Math.floor(minutes / 60);');
    Sys.Htp.P (' var days = Math.floor(hours / 24);');
    Sys.Htp.P (' hours %= 24;');
    Sys.Htp.P (' minutes %= 60;');
    Sys.Htp.P (' seconds %= 60;');
    Sys.Htp.P (' document.getElementById("daysBox").innerHTML = days;');
    Sys.Htp.P (' document.getElementById("hoursBox").innerHTML = hours;');
    Sys.Htp.P (' document.getElementById("minsBox").innerHTML = minutes;');
    Sys.Htp.P (' document.getElementById("secsBox").innerHTML = seconds;');
    Sys.Htp.P (' var timer = setTimeout("cdtd()",1000);');
    Sys.Htp.P ('}');
    Sys.Htp.P ('</script>');
    Sys.Htp.P ('Days ');
    Sys.Htp.P ('<div id="daysBox"></div>');
    Sys.Htp.P ('Hours');
    Sys.Htp.P ('<div id="hoursBox"></div>');
    Sys.Htp.P ('Minutes');
    Sys.Htp.P ('<div id="minsBox"></div>');
    Sys.Htp.P ('Seconds');
    Sys.Htp.P ('<div id="secsBox"></div>');
    Sys.Htp.P ('<script type="text/javascript">');
    Sys.Htp.P ('cdtd();</script>');
    End;
    End Loop;
    End;
    End;

    Let's focus on your delivery dates and javascript for now.
    Why you would put your javascript in htp.p calls in a plsql region is quite beyond me. When you edit the page there is a javascript region where you can put global variables and functions, an excellent spot for this then, and a lot more maintainable than this.
    Now it's also obvious that your query on pending items will return more than one record. So, using a report would serve you well in this case. However, using code like this:
    document.getElementById("daysBox").innerHTML = days;
    document.getElementById("hoursBox").innerHTML = hours;
    document.getElementById("minsBox").innerHTML = minutes;
    document.getElementById("secsBox").innerHTML = seconds;will not serve you. getElementById is meant to return one element uniquely identified by an ID. If you have a report with multiple rows, and elements on each row with the same ID, you are doing something wrong. You would need the delivery date per row, and I guess that you put out your code with htp.p because you do not know how to deal with that and passing it in to the javascript procedure.
    But wouldn't it be more oppurtune for you to simply create a report with a source sql where you calculate each part of the date, and then refresh this region with a certain interval. If you'd refresh every 5 minutes, wouldn't that be more than fast enough to keep track of things? Don't forget, refreshing a region will execute the sql again.
    It's not that you can't accomplish a multirecord report with a countdown per row, but are you comfortable enough with javascript and jquery to code and maintain that versus leveraging plsql and dynamic actions (there is even a dynamic action timer plugin provided by oracle)?

  • Combine multiple web services with the same SQL query into one

    Hello,
    I would like to ask a question regarding combine multiple similar web services into one. Can you please tell me if it is possible to combine 4-5 web services into one since they built on the same SQL query with 5 different criterias or condition so that the user can enter any of the 5 criterias to populate the data on the form instead of having 5 different web services?
    e.g Query: Select appName, permit#, address, phone, description, type, section, from table where appName = can be 'appName, permit#, address, phone, or description' to populate the rest of the data to the form.
    Does any one have ever done some thing like this in Workbench ES? If so please assist. I know it can be easier to build it in Visual Basic, C#, or dot.net but the requirement is to build it in workbench ES.
    Thanks in advance,
    Han Dao

    If you are querying for Name, PhoneNumber, and SSN, and you queried for all people with a phone number that started with 867, you would have a potentially long list of people.  So to keep track of all of the people, we store each record in XML complex elements.  The root node is just any name you want, and the repeating element is the complex element name. 
    So using the example from above, I'm going to specify the following:
         Root Node: Result
         Repeating Element: Person
    So now when I do a query, my resultXML will look like:
    <Result>
          <Person>
                 <Name>Alex</Name>
                 <PhoneNumber>867-5309</PhoneNumber>
                 <SSN>111-11-1111</SSN>
          </Person>
    </Result>
    If your query returned multiple results (like ours would probably), it would look like:
    <Result>
          <Person>
                 <Name>Alex</Name>
                 <PhoneNumber>867-5309</PhoneNumber>
                 <SSN>111-11-1111</SSN>
          </Person>
          <Person>
                 <Name>Han</Name>
                 <PhoneNumber>867-2169</PhoneNumber>
                 <SSN>222-22-2222</SSN>
          </Person>
    </Result>
    So Result and Person is just to give a little bit of structure to the xml result (containers really).  So you can name them whatever is helpful for you.
    The column name mappings map the query columns (Name, PhoneNumber, SSN) to some node in the XML (Name, PhoneNumber, SSN).  So you don't need to specify which field maps to what in the form.  Just copy the column names to the element name so you have a 1-to-1 naming.  If you want to manipulate the XML a bit though, you could do:
    Column Name               Element
    Name                            YourName
    PhoneNumber                Phone
    SSN                              Secret
    which would then make your xml look like:
    <Result>
          <Person>
                 <YourName>Alex</YourName>
                 <Phone>867-5309</Phone>
                 <Secret>111-11-1111</Secret>
          </Person>
    </Result>
    It lets you change the XML element names to whatever you want. Otherwise by default they take on their column names.
    In your form, you could bind to the WSDL through the Data Connections pane and point it to your web service.  This will then create form elements that you can just drag and drop allowing you to have the information available when the service gets ran.  Once the service is called, you can modify the field's data to get whatever information you need in order to populate other form fields. 
    If that is too confusing, feel free to send me your form (e-mail is on profile page) and I'll add comments to it to show you how to set up the form for the web service call (and also give me the link to your webservice)

  • Creating JTree with results from SQL Query

    I have the following source in SQLJ:
    String temp=null;
    iter1 it1;
    iter2 it2;
    #sql it1={select id,fdn,level from groups connect by prior fdn=parent_fdn start with fdn='/' };
    while(it1.next())
    System.out.println(it1.id()); // Display Parent
    temp=it1.fdn();
    #sql it2= {select clli from nes where parent_fdn=:temp order by clli };
    while(it2.next())
    System.out.println(it2.clli());//Display Child of above Parent if any
    My problem is to construct a Tree GUI using JTree from the above
    code with the same hierarchy of parent-child relationship.
    I have tried every possible solution using Vectors,Hashtables,String Arrays etc but have not come up with a successful solution so far
    IF ANYONE HAS A SOLUTION PLEASE HELP ME WITH AN EXAMPLE.
    Thank You
    Sharath

    sharathkv,
    Your issue seems to be in figuring out an algorithm to convert row-based SQL resultsets to a hierarchical data structure suitable for display in a tree.
    Run the jython (www.jython.org) app below: it simulates doing just that. jython is indentation-sensitive, so you'll need to exercise care when copying. If copy-paste to a text editor doesn't work, copy-paste to a HTML-aware editor (even Outlook Express, if on Windows), then copy from there and paste in a text editor.
    --A
    This is a jython (www.jython.org) app that illustrates
    converting row-based data (eg. a SQL resultset) to a custom
    hierarchical data structure, and displaying it in a JTree.
    from javax.swing import *
    from javax.swing.tree import *
    import java
    def getSQLRows():
        Simulates a SQL resultset.
        Columns fdn and parent-fdn indicate parent/child relationships.
        rows = [
            # id, fdn, parent-fdn, level
              [1, '/', None, 1]
            , [2, '/fruits', '/', 2]
            , [3, '/colors', '/', 2]
            , [4, '/sports', '/', 2]
            , [5, '/fruits/apples', '/fruits', 3]
            , [6, '/fruits/oranges', '/fruits', 3]
            , [7, '/colors/red', '/colors', 3]
            , [8, '/colors/blue', '/colors', 3]
            , [9, '/sports/petanc', '/sports', 3]
            , [10, '/sports/rugby', '/sports', 3]
        return rows
    def convertRowsToHierarchy(rows):
        Converts row-based results to hierarchical structure.
        Uses known parent/child relations present in rows.
        root = None
        for row in rows:
            fdn, parentfdn = row[1], row[2]
            node = SQLTreeNode(fdn, parentfdn)
            if root:
                root.addEx(node)
            else:
                root = node
        return root
    class SQLTreeNode(java.lang.Object):
        '''Custom tree node; displayed in JTree'''
        def __init__(self, fdn, parentfdn):
            self.fdn = fdn
            self.parentfdn = parentfdn
            self.nodes = []
        def add(self, node):
            '''Adds node as immediate child'''
            self.nodes.append(node)
        def addEx(self, node):
            '''Adds-with-search.  NOTE: naive implementation'''
            if self.fdn == node.parentfdn:
                self.add(node)
            else:
                for child in self.nodes:
                    child.addEx(node)
        def toString(self):
            return self.fdn
        def dump(self):
            '''Debug routine to dump hierarchy'''
            print 'fdn=%s, parentfdn=%s' % (self.fdn, self.parentfdn)
            for node in self.nodes:
                node.dump()
    class SQLTreeModelAdapter(TreeModel):
        '''Tree model adapter: adapts custom data structure to TreeModel'''
        def __init__(self, root):
            self.__root = root
        def getChild(self, parent, index):
            return parent.nodes[index]
        def getChildCount(self, parent) :
            return len(parent.nodes)
        def getIndexOfChild(self, parent, child):
            return parent.nodes.index(child)
        def getRoot(self) :
            return self.__root
        def isLeaf(self, node):
            return len(node.nodes) == 0
        def addTreeModelListener(self, l):
            pass
        def removeTreeModelListener(self, l):
            pass
        def valueForPathChanged(self, path, newValue):
            pass
    class SQLTreeDemo(JFrame):
        Tree demo UI
        Displays a tree displaying [hierarchical] results
        of a BOM-type SQL query
        def __init__(self):
            # Get matrix simulating SQL resultset
            rows = getSQLRows()
            # Convert to custom hierarchical data structure
            root = convertRowsToHierarchy(rows)
            model = SQLTreeModelAdapter(root)
            tree = JTree(model)
            sp = JScrollPane(tree)
            self.contentPane.add(sp)
            self.size = 200, 300
    if __name__ == '__main__':
        s = SQLTreeDemo()
        s.visible = 1

  • Help with Converting an Access query

    Hello:
    First time poster and would appreciate some help in converting this Access query into T-SQL so I can use in a Stored Procedure. I don't need help in resolving the syntax for the variables as parameter in the second query, but stuck in writing the first query
    in T-SQL . I assume I need some type of nested query with a left join to another query in T-SQL. 
    How do I convert this from Access into MS-SQL
    SELECT TBL_MONTH.L_Month, TBL_MONTH.L_MonthName
    FROM TBL_MONTH LEFT JOIN qry_MonthCheck ON TBL_MONTH.L_Month = qry_MonthCheck.L_Month
    WHERE (((qry_MonthCheck.L_Month) Is Null));
    qryMonthCheck in Access is defined as
    SELECT TBL_MONTH.L_Month, TBL_SIGNOFF.SO_YEAR, TBL_SIGNOFF.SO_USER, TBL_SIGNOFF.SO_LOCATION
    FROM TBL_MONTH RIGHT JOIN TBL_SIGNOFF ON TBL_MONTH.L_Month = TBL_SIGNOFF.SO_MONTH
    WHERE (((TBL_SIGNOFF.SO_YEAR)=[forms]![frm_signoff]![cboyear]) AND ((TBL_SIGNOFF.SO_LOCATION)=[Tempvars]![tmpVarUserLOC]));

    It is very much up to personal taste. For tables I use no prefix at all. Or suffix. I prefer plural: categories, products, etc. For junction tables, I drop the plural in the first entity, for instance productcategories. As for the case, many people prefer
    initial uppercase, while I go for lowercase only. But initial uppercase has its points, particularly in documentation. I am a staunch advocate of using case-sensitive collation for metadata. I don't see any point in mixing productcategories, Productcategories,
    ProductCategories etc. That can only cause confusion.
    As for either entities, I don't use views much, and I don't have any prefix for these either. In fact, several views I've been involved used to be tables once upon a time.
    If you want to add a marker to the object name, I recommend using a suffix. It is much easier to find objects in the version control system and other browser, when not everything is cluttered on the same letter. For instance, I typically add _sp at the end
    of stored procedure names.
    Erland Sommarskog, SQL Server MVP, [email protected]

Maybe you are looking for

  • Intrastat Query

    Hi, i am trying to build a query to assist us in compiling a report for Intrastat reporting. I understand that there is a wizard to help achieve this, however, i am wanting to update commodit codes for products on a monthly basis. i too understand th

  • I updated my iPhone 5 software and now it won't stay connected to wi-fi

    I updated my iPhone 5 software and now it won't stay connected to wi-fi

  • Dynamic Update Tabular form

    I have a tabular form on Table 1 (an empty table) I want to populate Table_1/tabular form with Table 2 values Table_1 & Table_2 are linked by pk/fk relationship (Main_Route) Basically, There will be a select list for Main_routes on the Table_1/tabula

  • Audio playback in Final Cut Express 4

    Captured some clips and started a sequence all was fine. rebooted the software to get around an issue where it wouldnt let me drop any transitions in which is now fine. Now however im not getting any audio playback even though i can see the audio on

  • Trouble with the trial version of PS CC

    I've already downloaded it once but in the wrong langauge. I deleted it from my PC and now I'm trying to dowload it in the write lang but it sais that it's already updated and there's sa green check mark over it. Besides, it's still in russian for so