'Function SQL Query return' using with Flash graphics

I created a pl/sql function that returns a SQL query in a varchar2 of this form:

Select the null link
-value > < x value
< value y of Series1 > series 1 label
< value Series2 y > 2 series label
< value of y Series3 > series 3 Label
...
...
from tablea a
Join tableb b
On a.col = b.col
order of < x value >

If I call the function of a graphic Flash box series SQL with the Type of Source query "SQL query" value that returns the function like this:

return functionname (to_date ('30-sep-2010, ' mon-dd-yyyy ""))

It parses correctly and the page is saved; However, when I run the page I get no output - error messages or another indication of a problem.

Now, if I call the function in a SQL client, capture the result of the query SQL using the dbms_output and paste that into the box graphic Flash series SQL - change the Source Type of SQL query query - and save the page it works fine when I run it and returns a chart series flash.

Can anyone suggest either;

1. what I might have missed or done wrong?
2. a way to effectively diagnose the problem...

I tried to use the debugger Apex - what is very nice, indeed - but it provides no information on what might be my problem. I tried to write my own my function debug messages using the apex_debug_message package - nothing...

Thank you
Eric

Hi Eric,.

Try to pull the source like this:

begin
   return functionname(to_date('30-sep-2010', 'dd-mon-yyyy'));
end;

This works very well for me, and if I take the begin-end and the final semicolon from the return statement I get the same behavior as you.

He doesn't mention in aid of the source (only during the wizard if) this source type must be expressed in this way, but I agree, it would be useful that the tool would validate to this format meets it "Query SQL that returns the function" or give some sort of indication of the sentence. In any case, this should help you will again.

Hope this helps,
John

If you find this information useful, please do not forget to mark the 'useful' or 'correct' post so that others benefit as well.

Tags: Database

Similar Questions

  • Dynamic SQL query returning (problem with list of value)

    Hi, I have problems with my request. I want to do where statement based on my selectlist, but the problem is that I could not write the correct string in my where condition.

    : P61_STATUS has this following display, return value

    Bewerber Bewerber
    PRA_Kandidat PRA_Kandidat
    abgelehnt abgelehnt
    angenommen angenommen
    Thema-Thema
    join online
    Staaten Staaten
    Sky sky
    our our
    DECLARE
      q varchar2(4000);
      list_betreuer htmldb_application_global.vc_arr2;
      list_semester htmldb_application_global.vc_arr2;
      list_status htmldb_application_global.vc_arr2;
    
    BEGIN
    
     -- variable to store the list
     list_betreuer := HTMLDB_UTIL.STRING_TO_TABLE(:P61_BETREUER);
     list_semester := HTMLDB_UTIL.STRING_TO_TABLE(:P61_SEMESTER);
     list_status := HTMLDB_UTIL.STRING_TO_TABLE(:P61_STATUS);
    
     -- Query begins
     q:= 'select p1.name, p1.vorname , a1.tel, a2.tel, '; 
     q:= q||'ab.thema, ab.status, ab.typ, s.bezeichnung, p2.name ';
     
     q:= q||'from person p1, person p2, adresse a1, adresse a2, ';
     q:= q||'zuordnungp_a zpa1,zuordnungp_a zpa2, ';
     q:= q||'abschlussarbeit ab, semester s ';
    
     q:= q||'WHERE ab.SEMESTER = s.OBJECTID (+) ';
     q:= q||'AND ab.STUDENT = p1.OBJECTID (+) ';
     q:= q||'AND ab.BETREUER = p2.OBJECTID (+) ';
    
     q:= q||'and p1.objectid = zpa1.person (+) ';
     q:= q||'and zpa1.adresse  = a1.objectid (+) ';
     q:= q||'and zpa1.art (+)= ''Privat'' ';
    
     q:= q||'and p1.objectid = zpa2.person (+) ';
     q:= q||'and zpa2.adresse  = a2.objectid (+) ';
     q:= q||'and zpa2.art (+)= ''Geschäft'' ';
    
    
     -- Loop for betreuer list
     FOR i in 1..list_betreuer.count
     LOOP
        IF i = 1 THEN
        q:= q||'AND (ab.betreuer = '||list_betreuer(i);
        ELSE
        q:= q||' OR ab.betreuer  = '||list_betreuer(i);
        END IF;
     END LOOP; if (list_betreuer.count>0)THEN q:= q||')'; END IF;
    
      -- Loop for semester list
     FOR i in 1..list_semester.count
     LOOP
        IF i = 1 THEN
        q:= q||'AND (ab.semester = '||list_semester(i);
        ELSE
        q:= q||'OR ab.semester = '||list_semester(i);
        END IF;
     END LOOP; if (list_semester.count>0)THEN q:= q||')'; END IF;
     
     -- Loop for status list
     FOR i in 1..list_status.count
     LOOP
        IF i = 1 THEN
        q:= q||'AND (ab.status = '||list_status(i)||'';
        ELSE
        q:= q||'OR ab.status = '||list_status(i)||'';
        END IF;
     END LOOP; if (list_status.count>0)THEN q:= q||')'; END IF;
     
      htp.p(q);
     return q;
     
    END;
    result
    select p1.name, p1.vorname , a1.tel, a2.tel, ab.thema, ab.status, ab.typ, s.bezeichnung, p2.name from person p1, person p2, adresse a1, adresse a2, zuordnungp_a zpa1,zuordnungp_a zpa2, abschlussarbeit ab, semester s WHERE ab.SEMESTER = s.OBJECTID (+) AND ab.STUDENT = p1.OBJECTID (+) AND ab.BETREUER = p2.OBJECTID (+) and p1.objectid = zpa1.person (+) and zpa1.adresse = a1.objectid (+) and zpa1.art (+)= 'Privat' and p1.objectid = zpa2.person (+) and zpa2.adresse = a2.objectid (+) and zpa2.art (+)= 'Geschäft' AND (ab.status = abgegeben) 
    the problem is in this summary
    q:= q||'AND (ab.status = '||list_status(i)||'';
    This statement produce this following statement
    ab.status = abgegeben
    But what I need, is this statement
    ab.status = 'abgegeben';
    How can I get this statement?

    Thank you very much

    To use double quotes:

    q:= q||'AND (ab.status = '''||list_status(i)||'''';
    
  • PL/SQL Query return function, adding the column links

    Hi all

    I'm working on a SQL report with the area type = function from PL/SQL Query to return
    All columns are generated dynamically based on my mapping table and a column of ID.
    So whenever the page is loaded, according to the ID mapping table returns a set of columns in a particular order.
    So not only the columns are dynamic, but the order of the columns varies also.
    But the first 1 column is standard (it doesn't come from the mapping table) and is coded in my pl/sql block hard.

    I'm fighting with the addition of a link to this column. The link must be a Javascript function which takes the parameters in the form of 2 columns in the mapping table.
    My pl/sql block is something like that...
    v_select := 'SELECT <g href=javascript:f_report1(#map_id#,#comments#)><img src=""></a> as report1, ';  // g=a
    v_cols := 'contains all columns from the mapping table based on a ID(hidden item)';
    v_from := 'FROM table';
    v_where := 'where condition is put in here';
    v_query := v_select||v_from||v_where;
    return v_query;
    Now, I'm not able to transmit the values of this #map_id # and #comments # correctly. I tried so many different combinations of channels, but could not make it work.

    I'm not sure that the order of this map_id and commentscolumn and therefore cannot connect through the report attributes.
    How can I go to a column value to the function?



    Thank you
    Dippy

    This should work if all goes well:

    v_select := q'[ SELECT '' as chart, ]';
    

    Published by: Dimitri Gielis on May 20, 2010 20:10

  • Column headings on PL/SQL return SQL Query report using &lt; br &gt;

    Hello
    I want to create a report region based on a function that returns a SQL query. As a dem oI created the following:
    create or replace function xxjk_retsql return varchar2
    as
    begin
    return 'select i "column header" from wwv_flow_dual100';
    end;
    I want to be able to insert a line break in the column heading so that it wraps to two lines. I tried this:
    create or replace function xxjk_retsql return varchar2
    as
    begin
    return 'select i "column<br>header" from wwv_flow_dual100';
    end;
    However, when the region is rendered, it seems to strip on the HTML tag. I also tried another tag, < i > < / i >, as a test and it is deleted also.



    Is it possible to include a pause in a header of column in this way?


    Thank you

    Hello:

    On the attributes page choose "pl/sql" for the field type.
    For the pl/sql function, write something like

    return 'top1
    bottom:top2
    bottom2:.........';

    CITY

  • SQL query returns no row vs. multiple lines

    Hello

    I am trying to get the result of a simple sql query,
    If there is no row returned, he would have "No. ROWS" in the result set.
    Other wise all the rows containing data is necessary.

    Let me know how this could be achieved. Under query works for the latter and not first case as mentioned below

    OUTPUT

    + (box 1) when we use B_ID = 123456 +.

    IDS
    -----
    'NO LINE '.

    + (box 2) when we use B_ID = 12345 +.
    IDS
    -----
    1 11112345
    2 22212345
    create table TEMP_AAA
    (
      A_ID VARCHAR2(10),
      B_ID VARCHAR2(10)
    )
    
    INSERT INTO TEMP_AAA(A_ID,B_ID) VALUES('111','12345');
    INSERT INTO TEMP_AAA(A_ID,B_ID) VALUES('222','12345');
    INSERT INTO TEMP_AAA(A_ID,B_ID) VALUES('333','12000');
    INSERT INTO TEMP_AAA(A_ID,B_ID) VALUES('444','10000');
    WITH 
    MATCH_ROWS AS
    (
           SELECT A_ID||B_ID IDS FROM TEMP_AAA WHERE B_ID=12345
    ),
    
    MATCH_ROW_COUNT AS
    (
           SELECT COUNT(1) AS COUNTS FROM MATCH_ROWS
    ),
    
    PROCESSED_ROWS AS
    (
           SELECT
                 CASE WHEN COUNTS = 0
                      THEN 
                       (SELECT NVL((SELECT IDS FROM TEMP_AAA WHERE B_ID=12345),'NO ROWS') IDS FROM DUAL)
                      ELSE
                       MATCH_ROWS.IDS
                 END IDS     
            FROM MATCH_ROWS,MATCH_ROW_COUNT
    )
    
    SELECT * FROM PROCESSED_ROWS;

    Hello

    I think you want to put this on a report or something. I have what would be easier to do this logic there. But if you want that this is possible.
    Like this

    with
    temp_aaa as
    (select '111' a_id ,'12345' b_id from dual union all
    select '222'      ,'12345'  from dual union all
    select '333'      ,'12000'  from dual union all
    select '444'      ,'10000'  from dual
    )
    , wanted_rows as
    ( select  '123456' B_ID from dual)
    select
      temp_aaa.A_ID || temp_aaa.B_ID IDS 
    
    from
      temp_aaa
      ,wanted_rows
    where
      temp_aaa.b_id = wanted_rows.b_id
    union all
    select
      'NO ROWS'
    FROM
      DUAL
    WHERE
      (SELECT COUNT(*) FROM TEMP_AAA, wanted_rows WHERE TEMP_AAA.B_ID = wanted_rows.B_ID) = 0
    

    In addition, you mix var and number of always use the same type or convert explicitly (to_number or to_char)

    WITH
    MATCH_ROWS AS
    (
           SELECT A_ID||B_ID IDS FROM TEMP_AAA WHERE      B_ID           =12345
    --                                                    varchar2(10)   number
    ),
    ...
    

    And again in the

                      THEN
                       (SELECT NVL((SELECT IDS FROM TEMP_AAA WHERE B_ID           =12345),'NO ROWS') IDS FROM DUAL)
    --                                                             varchar2(10)   number
    

    Kind regards

    Peter

  • reload the page when SQL query returns a value

    Hello world

    the title of this discussion may seem strange, but I'll try to explain why I need this:

    A user has the ability to connect on my APEX application. There are several tabs in my application that are visible only if a certain SQL statement returns a value which is not the case by default. The user has also the ability to download a file that is transferred to an external system that analyzes the file and writes the data in the database. During this writing process - which may take several minutes - conditions for some of the tabs to show the will becomes real (-> the query will return a value). When the user refreshes the page manually, the tabs will be displayed. However, I want the tabs will appear automatically when the condition is met.

    Is it possible to refresh the page as soon as the query returns a value? It is perhaps possible to check it on the client side and trigger a refresh of the page when the condition is met. It would be even better if only the tabset has been updated, but refreshing the full page is fine as well.

    Thank you!

    Here is an overview of how it can be done

    This is possible thanks to a dynamic action being performed on a timer.

    View default tabs and dynamic action hide them on loading the page if they are not to be considered

    Create a dynamic action that will execute your query every 5 seconds or more

    If the query returns data, you can use the dynamic action to show your tabs using javascript

  • return used with recursive with type object tree

    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE     11.2.0.1.0     Production
    TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    There was just a post called employee return tree with the object type, and there were several responses.
    I tried to wrap my brain around the recursive with and I was wondering how to implement it for this problem

    Basically, the post was something like that.
    CREATE TABLE employees
    AS
       SELECT 1 mgr_id, 2 emp_id FROM DUAL
       UNION
       SELECT 2, 3 FROM DUAL
       UNION 
       SELECT 3, 4 FROM DUAL
       UNION
       SELECT 4, 5 FROM DUAL;
    and he wanted to
    MGR_ID     GET_EMPS(MGR_ID)
    1     2,3,4,5
    2     3,4,5
    3     4,5
    4     5
    as mentioned, it has several solutions were however I was and wrote a recursive function
    to get the answer. that seems to work
    CREATE OR REPLACE FUNCTION get_emps (p_mgr employees.mgr_id%TYPE)
       RETURN VARCHAR2
    IS
       v_mgr    employees.mgr_id%TYPE;
       v_emp    employees.emp_id%type;
       v_emps   VARCHAR2 (200);
    BEGIN
       v_mgr := p_mgr;
       LOOP
          SELECT emp_id
            INTO  v_emp
            FROM employees
           WHERE mgr_id = v_mgr;
    
          v_emps := v_emps||','||v_emp;
          v_mgr := v_emp;
       END LOOP;
      exception when no_data_found then
      return  substr(v_emps,2);
        END;
    now, I would like to convert a recursive with my function, but I can't quite understand.

    Here's what I have so far but I'm still not close.
    WITH emp1 
     (mgr_id, emp_id, emp_ids)
     AS  
     ( SELECT mgr_id  , to_char( emp_id), to_char(emp_id)  from employees  WHERE mgr_id = 1
     UNION /* my internet filter will not alllow me to post this statement */ALL
       SELECT emp2.mgr_id,  to_char(emp2.emp_id), to_char(emp1.emp_id)||','||to_char(emp2.emp_id)
       FROM employees emp2 JOIN emp1 ON (emp2.mgr_id = emp1.emp_id)
     )
     select * from emp1
    Sorry for the comment here we have a weird filter on our internet that does not allow me to view the word a union |

    Hello

    You're so close! You just need a character more:

    WITH emp1
     (mgr_id, emp_id, emp_ids)
     AS
     (
         SELECT  mgr_id
         ,     TO_CHAR (emp_id)
         ,     TO_CHAR (emp_id)
         FROM     employees
         WHERE     mgr_id        = 1
        UNION ALL
             SELECT  emp2.mgr_id
         ,     TO_CHAR (emp2.emp_id)
         ,     TO_CHAR (emp1.emp_ids) || ',' || TO_CHAR (emp2.emp_id)
    --                        ^
    --                        s added above
         FROM     employees emp2
         JOIN             emp1 ON (emp2.mgr_id = emp1.emp_id)
     )
    SELECT  *
    FROM      emp1
    ;
    

    Output:

        MGR_ID EMP_ID     EMP_IDS
    ---------- ---------- --------------------
             1 2          2
             2 3          2,3
             3 4          2,3,4
             4 5          2,3,4,5
    
  • SQL query return different result 11 GR 1 material and GR 11, 2

    Problem: SQL returns different results in 11 GR 1 material and GR 11, 2 games.

    Example script:

    create the table tab_main
    (
    SOS number (2) not null,
    contract number (2) null
    )
    /

    create the table tab_sub
    (
    number (2) of contract non-null,.
    SOS number (2) null
    )
    /

    insert into tab_main values (1, 10);
    insert into tab_main values (2, 20);
    insert into tab_main values (3, null);
    insert into tab_main values (4, null);

    insert into tab_sub values (1, 10);
    insert into tab_sub (20, 2) values;
    commit;

    The SQL code:

    SELECT *.
    OF tab_main.
    tab_sub
    WHERE tab_main.sos = tab_sub.sos (+) AND
    tab_main. Contract = tab_sub.contract (+) and
    tab_main. Contract not in (select 1 of the double);

    The above query gives more results
    -by 11.2.0.4
    1 10 10 1
    2 20 20 2

    -in 11.1.0.7
    1 10 10 1
    2 20 20 2
    4
    3


    Please tell us what could be the reason for the behaviour of offset lines thie.


    Thank you

    Piesset

    I think it is probably a bug in 11.1.0.7 (and possibly other versions), I get the same results as your 11.2.0.4 9.2.0.7, 10.2.0.3 and 11.2.0.3, and this is the result, I expect.

    Your not in the paragraph is equivalent to:

    SELECT *.

    OF tab_main, tab_sub

    WHERE tab_main.sos = tab_sub.sos (+) AND

    tab_main. Contract = tab_sub.contract (+) and

    tab_main. Contract <> 1;

    Since you have null values in tab_main.contract they are lost by the predicate since null = value is never true (or false).

    John

  • pl/sql - sql query return

    Hi all... I hope someone can help.
    Worked a lot to solve this problem, but I can't find a solution.
     
    DECLARE
         lv_sql VARCHAR(32767);
         lv_pivot_cols VARCHAR2(1000);
    BEGIN
         FOR i IN (SELECT DISTINCT comp_name, pro_name FROM  cat_attributes order by comp_name)
         LOOP
              lv_pivot_cols := lv_pivot_cols ||'('||''''||i.comp_name||''''||','|| '''' || i.pro_name ||''''||')'||',';
         END LOOP;
         lv_pivot_cols := RTRIM(lv_pivot_cols,',');
    
         lv_sql := 'SELECT * FROM
         (SELECT position,cat_id, att_name as ATTRIBUTE, pro_name, value,comp_name
         FROM   cat_attributes )
    PIVOT (
                        max (value)
                        FOR (comp_name,pro_name) IN (' ||lv_pivot_cols||')) where cat_id=:P1100_CHOOSE_CATEGORY order by position';
            
         RETURN lv_sql;                    
         --DBMS_OUTPUT.PUT_LINE(lv_sql);
    END;
    the code above works well, but I want to add a where condition in the separate statement, which depends on an element of the apex.
    as:
    SELECT DISTINCT comp_name, pro_name FROM  cat_attributes where  cat_id=:P1100_CHOOSE_CATEGORY order by comp_name 
    But if an add this condition got
    error report: ORA-01403: no data found
    any suggestions?


    I would also like to change the size of characters max column header. now, it may be only * 30 * characters for the column header. is there a possibility to raise it?

    Thanks for all your suggestions

    Hello

    Hmm. Is the value of ': P1100_CHOOSE_CATEGORY ' in Session State?

    In this case, would be the usual suspect: ": P1100_CHOOSE_CATEGORY" has no value in Session State. You said if she had a value in Session State?

    Now, someone might say, "well, the other query work it must have a value in Session State! Well, maybe. But might work work with null query ': P1100_CHOOSE_CATEGORY '?? If it is null, then get the value stored in the Session State.

    Howard

  • SQL query returning no rows, please help!

    I have a table that contains the user checks for a specific procedures alongwith the date stamp. Now, I want the list of all procedures that are not accessible by users in the last 6 months. Or, all of the procedures that have not been used/accessible during the last 6 months.

    That's what I'm trying, but is does not return all rows:

    SELECT DISTINCT proc_name,
    TRUNC (entry_date)
    OF log_web
    WHERE NOT IN (SELECT proc_name proc_name
    OF log_web
    WHERE TRUNC (entry_date) > TRUNC (SYSDATE - 180))
    ORDER BY DESC 2

    Please notify.
    Thank you in advance.

    Hello

    NOT IN never returns TRUE if the subquery returns NULL values. If proc_name doesn't have a NOT NULL constraint, change the subquery to

    WHERE        proc_name     NOT IN ( SELECT  proc_name
                                FROM      log_web
                         WHERE      entry_date     > TRUNC (SYSDATE - 180)
                         AND      proc_name     IS NOT NULL
                          )
    

    I don't see any other suspect.
    Post a small example of data (CREATE TABLE and INSERT statements) where the query produces results worng.

  • SQL query for emp with decoding

    How to get the desired output with a simple query to achieve if SAL > 2500 jobs = 'manager' then display job as "seniormanager".
    CREATE TABLE EMP(EMPNO NUMBER(4) NOT NULL,ENAME VARCHAR2(10),JOB VARCHAR2(9),MGR NUMBER(4),HIREDATE DATE,SAL NUMBER(7, 2),COMM NUMBER(7, 2),DEPTNO NUMBER(2));
    INSERT INTO EMP VALUES(7521, 'WARD', 'SALESMAN', 7698,TO_DATE('22-FEB-1981', 'DD-MON-YYYY'), 1250, 500, 30);
    INSERT INTO EMP VALUES(7566, 'JONES', 'MANAGER', 7839,TO_DATE('2-APR-1981', 'DD-MON-YYYY'), 2975, NULL, 20);
    INSERT INTO EMP VALUES(7698, 'BLAKE', 'MANAGER', 7839,TO_DATE('1-MAY-1981', 'DD-MON-YYYY'), 2850, NULL, 30);
    INSERT INTO EMP VALUES(7782, 'CLARK', 'MANAGER', 7839,TO_DATE('9-JUN-1981', 'DD-MON-YYYY'), 2450, NULL, 10);
    INSERT INTO EMP VALUES(7788, 'SCOTT', 'ANALYST', 7566,TO_DATE('09-DEC-1982', 'DD-MON-YYYY'), 3000, NULL, 20);
    
    
    
    
    
    
    
    IF SAL>2500 and job='manager' then display job as 'seniormanager'
    SELECT * FROM EMP
    
    expected output
    
    7521     WARD     SALESMAN         7698     22-FEB-81     1250     500     30
    7566     JONES     SENIORMANAGER     7839     02-APR-81     2975          20
    7698     BLAKE     SENIORMANAGER     7839     01-MAY-81     2850          30
    7782     CLARK     MANAGER          7839     09-JUN-81     2450          10
    7788     SCOTT     ANALYST           7566     09-DEC-82     3000          20

    Maybe

    select ... ,
           case when sal > 2500 and upper(job) = 'MANAGER'
                then 'seniormanager'
                else job
           end job,
           ...
      from emp
    

    Concerning

    Etbin

  • Refine a query that uses WITH clause.

    Hello

    I would like to bind ALL_DAYS. DAYS_OF_MONTH with field of view < < DAY TO_CHAR (FINISHED, 'dd') > >

    The way that:
    DAYS_OF_MONTH = SERV1. DAY
    DAYS_OF_MONTH = SERV2. DAY
    DAYS_OF_MONTH = SERV3. DAY.

    How can I Edifier who?

    What it does is that the days where there is no data, it will put a 0 value.
    WITH all_days AS
    (
    SELECT
    TO_CHAR(TO_DATE(LEVEL||'-'||TO_CHAR(ADD_MONTHS(SYSDATE,-1),'MON-YY'),'DD-MON-YY'),'DD') DAYS_OF_MONTH
    FROM DUAL
    CONNECT BY LEVEL <= TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(SYSDATE,-1)),'DD'))
    )
    SELECT nvl(SERV1.DAY,'TOTAL MONTH:') DAY,
             nvl(SUM(SERV1.GOOD),0) GOOD1,
             nvl(SUM(SERV1.WRONG),0) WRONG1,
             nvl(SUM(SERV2.GOOD),0) GOOD2,
             nvl(SUM(SERV2.WRONG),0) WRONG2,
             nvl(SUM(SERV3.GOOD),0) GOOD3,
             nvl(SUM(SERV3.WRONG),0) WRONG3,
             (nvl(SUM(SERV1.GOOD),0)+nvl(SUM(SERV2.GOOD),0)+nvl(SUM(SERV3.GOOD),0)) TOTAL_GOOD,
             (nvl(SUM(SERV1.WRONG),0)+nvl(SUM(SERV2.WRONG),0)+nvl(SUM(SERV3.WRONG),0)) TOTAL_WRONG
        FROM  (SELECT   TO_CHAR(FINISHED, 'dd') DAY,
                       SUM(CASE
                               WHEN STATUS_CODE IN (4, 12) THEN 1
                               ELSE 0
                            END) GOOD,
                       SUM(CASE
                               WHEN STATUS_CODE NOT IN (4, 12) THEN 1
                               ELSE 0
                            END) WRONG
                  FROM my_table
                 WHERE SERVER_NAME = 'somename1'
                 GROUP BY TO_CHAR (FINISHED, 'dd')) Serv1,  
              (SELECT   TO_CHAR (FINISHED, 'dd') DAY,
                       SUM(CASE
                               WHEN STATUS_CODE IN (4, 12) THEN 1
                               ELSE 0
                            END) GOOD,
                      SUM(CASE
                               WHEN STATUS_CODE NOT IN (4, 12) THEN 1
                               ELSE 0
                            END) WRONG
                  FROM MY_TABLE
                 WHERE SERVER_NAME = 'somename2'
                               GROUP BY TO_CHAR (FINISHED, 'dd')) Serv2, 
              (SELECT   TO_CHAR (FINISHED, 'dd') DAY,
                       SUM(CASE
                               WHEN STATUS_CODE IN (4, 12) THEN 1
                               ELSE 0
                            END) GOOD,
                       SUM(CASE
                               WHEN STATUS_CODE NOT IN (4, 12) THEN 1
                               ELSE 0
                            END) WRONG
                  FROM my_table
                 WHERE NOM_SERVEUR_RAPP <> 'somename1'
                   AND NOM_SERVEUR_RAPP  'somename2'
                 GROUP BY TO_CHAR (FINISHED, 'dd')) SERV3
    WHERE Serv1.JOUR = Serv2.DAY(+)
    AND Serv2.JOUR = Serv3.DAY(+)
    GROUP BY ROLLUP (SERV1.DAY)
    ORDER BY 1;
    Kind regards.

    I think I understand the problem. 2 queries aren't adding up the values obtained. I replaced the serv_days with examples of data query. What is the desired; output

    with all_days as
     (select lpad(rownum, 2, '0') day_str,
             0 good1,
             0 wrong1,
             0 good2,
             0 wrong2,
             0 good3,
             0 wrong3,
             0 total_good,
             0 total_wrong
      from dual
      connect by level <=
                 to_number(to_char(last_day(add_months(sysdate, -1)), 'DD'))),
    serv_days as
     (select '01' day_str,
             1 good1,
             1 wrong1,
             1 good2,
             1 wrong2,
             1 good3,
             1 wrong3
      from dual
      union all
      select '02' day_str,
             2 good1,
             2 wrong1,
             2 good2,
             2 wrong2,
             2 good3,
             2 wrong3
      from dual)
    -- Main Query
    select day_str,
           sum(good1) good1,
           sum(wrong1) wrong1,
           sum(good2) good2,
           sum(wrong2) wrong2,
           sum(good3) good3,
           sum(wrong3) wrong3,
           sum(total_good) total_good,
           sum(total_wrong) total_wrong
    from (select day_str,
                 good1,
                 wrong1,
                 good2,
                 wrong2,
                 good3,
                 wrong3,
                 total_good,
                 total_wrong
          from all_days
          union all
          select day_str,
                 good1,
                 wrong1,
                 good2,
                 wrong2,
                 good3,
                 wrong3,
                 good1 + good2 + good3 total_good,
                 wrong1 + wrong2 + wrong3 total_wrong
          from serv_days)
    group by rollup(day_str)
    order by 1;
    01               1          1          1          1          1          1          3           3
    02               2          2          2          2          2          2          6           6
    03               0          0          0          0          0          0          0           0
    04               0          0          0          0          0          0          0           0
    05               0          0          0          0          0          0          0           0
    06               0          0          0          0          0          0          0           0
    07               0          0          0          0          0          0          0           0
    08               0          0          0          0          0          0          0           0
    09               0          0          0          0          0          0          0           0
    10               0          0          0          0          0          0          0           0
    11               0          0          0          0          0          0          0           0
    12               0          0          0          0          0          0          0           0
    13               0          0          0          0          0          0          0           0
    14               0          0          0          0          0          0          0           0
    15               0          0          0          0          0          0          0           0
    16               0          0          0          0          0          0          0           0
    17               0          0          0          0          0          0          0           0
    18               0          0          0          0          0          0          0           0
    19               0          0          0          0          0          0          0           0
    20               0          0          0          0          0          0          0           0
    21               0          0          0          0          0          0          0           0
    22               0          0          0          0          0          0          0           0
    23               0          0          0          0          0          0          0           0
    24               0          0          0          0          0          0          0           0
    25               0          0          0          0          0          0          0           0
    26               0          0          0          0          0          0          0           0
    27               0          0          0          0          0          0          0           0
    28               0          0          0          0          0          0          0           0
    29               0          0          0          0          0          0          0           0
    30               0          0          0          0          0          0          0           0
                     3          3          3          3          3          3          9           9
    
    31 rows selected
    
  • How to find the sql query by using the hash value

    Hello

    DBVERSION: 9.2.0.8

    I generated the statspack report and I want to see total request and I hash_value here.

    in v$ sql can't see all querys... .pls suggest me other ways...

    Thank you
    Srini...

    Have you seen Peter's response? There is no installation other than that would be to store the history of the IMO. Another reason that you must pass to 10g or 11g better, now.

    Aman...

  • pl/sql block returning the sql query.

    Hello

    I'm using the apex version 3.2 oracle 10g.
    I use the following return statement inside my report, which is a pl/sql block sql query return.

    declare
    The NEST varchar2 (100);
    Start
    ......
    return "select patient_id_code from t_files_data_exp, including patient_id_code not in the NEST';"

    end;

    How am I suppose to mention the pid within the return stmt I mean with quotes or anything? because the above return stmt gives error
    "1 error has occurred."
    Query cannot be parsed in the generator. If you believe that your query is syntactically correct, check the generic "columns" box below the source of the region without analysis. The query cannot be parsed, the cursor is not yet open or a function returning a SQL query returned no value. »


    Thank you

    If is varchar2

    declare
    pid varchar2(100) := '(''61092'',''61093'')';
    ...
    
  • Help with APP_USER in SQL query

    Hello

    I would like to extract a detail of the user in a form of language element DML based on the logged in user and the standard authentication scheme.

    I make this request in the element:
     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 value of the EMAIL. In fact, the value in the session is a capital letter, and the other in the database is tiny. I think that's irrelevant anyway.

    The query do not of any value. Could you please let me know what I did wrong?

    APEX: 4.2
    Item Source type: query SQL (single return 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 user name is entered in lowercase.

    But if you think that your request is correct, test it by using a literal rather than 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]');
    

    Published by: Sven w. October 23, 2012 13:30

    APEX: 4.2
    Item Source type: SQL Query ( return a single value )

    I just noticed that you use an element that has this as the SQL source. This only works if the sql returns a row and a column only. That's why I removed the second column in your query.

    Published by: Sven w. October 23, 2012 13:33

Maybe you are looking for

  • Toshiba Bluetooth stack miniPCIe Perripheriques

    I would like to install a Bluetooth (or combo) miniPCIe card in a laptop with a bluetooth chipset supported by the toshiba bluetooth stack software.And on the net, it is impossible to find a list of the supported devices. Anyone can help with this, t

  • How to connect an lvdt and cell to usb 6008

    Please help me iam do not know how to choose a daq card. looking for a lost lt but iam. I want to measure the force and displacement at the same time a bench test of suspension and I wanted to use or usb6008 because of my budget for the project. can

  • Deactivation of the system code 52741028

    In the bios menu it says to enter the administrative password, I've so after three unsuccessful attempts, he says "system disabled 52741028. How can I get around this?

  • WAG320n - can he endure RFC1483 bridged?

    Hi all! I have a bit of difficulty to the top of my new WAG320n brilliant as a replacement for my planned ISP modem/router. I'm with Bethere, providing ADSL2 + by using encapsulation, type "RFC 1483 Bridged", but I can't seem to select this mode in t

  • Tried to download Kodak ESP C310 All in one Printer

    I am trying to install my Kodak ESP C310 printer. I have an Acer 5552 portable 64-bit. I can't use this wireless - no problem. But when I try to configure the printer it does not recognize. I tried to download the all-in-one firmware of the printer,