Need advice on SQL report base to APEX or jasper

Hi all

I need some advice on how to approach the question under the requirement of report. It was me mad for almost 2 weeks now, and my time is running out.
Here is a simplified version of the database

Four paintings: event, Service, commitment, defendant.
A defendant may have more than 1 commitment, but they only open at a time commitment.
For each commitment, they will have services and events.
These events may be just general events or related to the service.
Here's the script for tables and sample data
CREATE TABLE "DEFENDANT" 
   ("DEF_ID" NUMBER, 
     "FIRST_NAME" VARCHAR2(50 BYTE), 
     "LAST_NAME" VARCHAR2(50 BYTE), 
     "ACTIVE" NUMBER DEFAULT 1
   ) ;
Insert into DEFENDANT (DEF_ID,FIRST_NAME,LAST_NAME,ACTIVE) values (1,'Joe','Bloggs',1);
Insert into DEFENDANT (DEF_ID,FIRST_NAME,LAST_NAME,ACTIVE) values (2,'John','Doe',1);
--------------------
 CREATE TABLE "ENGAGEMENT" 
   ("ENG_ID" NUMBER, 
     "DEF_ID" NUMBER, 
     "COURT_NAME" VARCHAR2(20 BYTE), 
     "DATE_JOINED" DATE, 
     "DATE_TERMINATED" DATE, 
     "ETHNICITY" VARCHAR2(50 BYTE), 
     "ACTIVE" VARCHAR2(20 BYTE)
   ) ;
/

Insert into ENGAGEMENT (ENG_ID,DEF_ID,COURT_NAME,DATE_JOINED,DATE_TERMINATED,ETHNICITY,ACTIVE) values (1,1,'AAA',to_date('01/09/12','DD/MM/RR'),to_date('20/09/12','DD/MM/RR'),'European','1');
Insert into ENGAGEMENT (ENG_ID,DEF_ID,COURT_NAME,DATE_JOINED,DATE_TERMINATED,ETHNICITY,ACTIVE) values (2,2,'BBB',to_date('01/10/12','DD/MM/RR'),null,'Asian','1');
Insert into ENGAGEMENT (ENG_ID,DEF_ID,COURT_NAME,DATE_JOINED,DATE_TERMINATED,ETHNICITY,ACTIVE) values (3,1,'AAA',to_date('22/09/12','DD/MM/RR'),null,'European','1');
-------------------------------------------------------- 
 CREATE TABLE "EVENT" 
   ("EVENT_ID" NUMBER, 
     "ENG_ID" NUMBER, 
     "NOTES" VARCHAR2(20 BYTE), 
     "RELATED_SERVICE_ID" NUMBER, 
     "START_DATE" DATE, 
     "END_DATE" DATE, 
     "ACTIVE" NUMBER DEFAULT 1
   ) ;
/
--------------------------------------------------------
Insert into EVENT (EVENT_ID,ENG_ID,NOTES,RELATED_SERVICE_ID,START_DATE,END_DATE,ACTIVE) values (1,1,null,1,to_date('01/09/12','DD/MM/RR'),to_date('02/09/12','DD/MM/RR'),1);
Insert into EVENT (EVENT_ID,ENG_ID,NOTES,RELATED_SERVICE_ID,START_DATE,END_DATE,ACTIVE) values (2,1,null,1,to_date('23/09/12','DD/MM/RR'),null,1);
Insert into EVENT (EVENT_ID,ENG_ID,NOTES,RELATED_SERVICE_ID,START_DATE,END_DATE,ACTIVE) values (3,1,null,2,to_date('15/10/12','DD/MM/RR'),to_date('16/10/12','DD/MM/RR'),1);
Insert into EVENT (EVENT_ID,ENG_ID,NOTES,RELATED_SERVICE_ID,START_DATE,END_DATE,ACTIVE) values (4,2,null,null,to_date('02/10/12','DD/MM/RR'),null,1);
Insert into EVENT (EVENT_ID,ENG_ID,NOTES,RELATED_SERVICE_ID,START_DATE,END_DATE,ACTIVE) values (5,2,null,2,to_date('03/10/12','DD/MM/RR'),null,1);
Insert into EVENT (EVENT_ID,ENG_ID,NOTES,RELATED_SERVICE_ID,START_DATE,END_DATE,ACTIVE) values (6,3,null,null,to_date('22/09/12','DD/MM/RR'),to_date('23/09/12','DD/MM/RR'),1);
Insert into EVENT (EVENT_ID,ENG_ID,NOTES,RELATED_SERVICE_ID,START_DATE,END_DATE,ACTIVE) values (7,3,null,4,to_date('23/09/12','DD/MM/RR'),null,1);
Insert into EVENT (EVENT_ID,ENG_ID,NOTES,RELATED_SERVICE_ID,START_DATE,END_DATE,ACTIVE) values (8,2,null,null,to_date('12/10/12','DD/MM/RR'),null,1);
--------------------------------------------------------
 CREATE TABLE "SERVICE" 
   (     "SERVICE_ID" NUMBER, 
     "ENG_ID" NUMBER, 
     "DESCRIPTION" VARCHAR2(200 BYTE), 
     "DATE_STARTED" DATE, 
     "DATE_TERMINATED" DATE, 
     "ACTIVE" NUMBER DEFAULT 1
   );
/

Insert into SERVICE (SERVICE_ID,ENG_ID,DESCRIPTION,DATE_STARTED,DATE_TERMINATED,ACTIVE) values (1,1,'Counselling',to_date('15/09/12','DD/MM/RR'),to_date('18/09/12','DD/MM/RR'),1);
Insert into SERVICE (SERVICE_ID,ENG_ID,DESCRIPTION,DATE_STARTED,DATE_TERMINATED,ACTIVE) values (2,1,'Housing',to_date('20/09/12','DD/MM/RR'),null,1);
Insert into SERVICE (SERVICE_ID,ENG_ID,DESCRIPTION,DATE_STARTED,DATE_TERMINATED,ACTIVE) values (3,2,'Treatment',to_date('01/10/12','DD/MM/RR'),to_date('15/10/12','DD/MM/RR'),1);
Insert into SERVICE (SERVICE_ID,ENG_ID,DESCRIPTION,DATE_STARTED,DATE_TERMINATED,ACTIVE) values (4,3,'Housing',null,null,1);
Insert into SERVICE (SERVICE_ID,ENG_ID,DESCRIPTION,DATE_STARTED,DATE_TERMINATED,ACTIVE) values (5,1,'Other',to_date('05/10/12','DD/MM/RR'),null,0);
Insert into SERVICE (SERVICE_ID,ENG_ID,DESCRIPTION,DATE_STARTED,DATE_TERMINATED,ACTIVE) values (6,2,'Treatment',to_date('16/10/12','DD/MM/RR'),null,1);
****
And that's the perspective I think to use as a basis for the report
CREATE OR REPLACE FORCE VIEW "BASE_VW" 
 
AS
  SELECT Def.Def_Id,
    Def.First_Name,
    Def.Last_Name,
    Eng.Eng_Id,
    Eng.Court_Name,
    Eng.Date_Joined,
    Eng.Date_Terminated,
    Eng.Ethnicity,
    Ser.Service_Id,
    Ser.Description,
    Ser.Date_Started    AS Service_Start_Date,
    Ser.Date_Terminated AS Service_Date_Terminated,
    Ser.Active          AS Service_Active,
    Ev.Event_Id,
    Ev.Related_Service_Id,
    Ev.Start_Date,
    Ev.End_Date,
    Ev.Notes,
    ev.active AS event_active
  FROM Defendant Def
  LEFT OUTER JOIN Engagement Eng
  ON Def.Def_Id = Eng.Def_Id
  LEFT OUTER JOIN Service Ser
  ON Eng.Eng_Id = Ser.Eng_Id
  LEFT OUTER JOIN Event Ev
  ON Ev.Eng_Id = Eng.Eng_Id;
****
Requirement:
Report parameter: Start Date, end Date, Court_name
Of selected Court_name, list of defendants who are currently participating in the Court.
For each display of the defendant
Section 1: Identification of the details: first name, surname, ethnicity, Date of arrival in the Court
Section 2: All currently active Services that the defendant attend
Section 3: All the events related to the service attending the defendant
Section 4: All other events (don't have IDS Service related)

The user must be able to download the full report in the spreadsheet or in PDF format.
I tried to create a set of Union chooses (but the format is not that good, when no data return show nothing, I would like to show rather some messages as "There is no associated event, rather than nothing")
and he produced a report for 1 defendant at the same time.

We use Oracle APEX, so only select statement or statement select return PL/SQL Code is valid for the report source.
At our place, we use Jasper adjacent report at the APEX, but I have very little experience with report of Jasper.
The developer who knows a lot about the report of jasper is too busy to help me.

Currently I use the union chooses as below:
With Current_Engagement As
( Select Eng_Id From Engagement
  Where Def_Id =2
  And Date_Joined Is Not Null
  And ( Date_Terminated Is Null Or Date_Terminated > Sysdate)
  And Rownum =1
)
Select '1.Defendant ID' as col1, 'First Name' as col2, 'Last Name' as col3, 'Court Name' as col4, 'Ethnicity' as col5, 'Date Joined' as col6, 'Date Terminated' as col7
From Dual

Union All

Select Distinct to_char(Def_Id), First_Name, Last_Name, Court_Name, Ethnicity, to_char(Date_Joined), to_char(Date_Terminated)
From Base_Vw Inner Join Current_Engagement Ce On Base_Vw.Eng_Id = Ce.Eng_Id

Union All 
select '2.Service ID', 'Service Description', 'Start Date', 'End Date', Null, Null, Null
from dual

Union All

Select distinct to_char(service_id), description, to_char(service_start_date), to_char(service_date_terminated), null, null, null
From Base_Vw Inner Join Current_Engagement Ce On Base_Vw.Eng_Id = Ce.Eng_Id
where service_active =1

Union All
Select '3.Event ID', 'Related Service ID', 'Start Date', 'End date', 'Notes', null, null
From Dual

Union All
Select distinct to_char(event_id), to_char(related_service_id), to_char(start_date), to_char(end_date), notes, null, null
from Base_Vw Inner Join Current_Engagement Ce On Base_Vw.Eng_Id = Ce.Eng_Id
Where Event_Active = 1
and related_service_id is not null

Union All

Select '4.Event ID', 'Start Date', 'End date', 'Notes', null, null, null
From Dual

Union All

Select distinct to_char(event_id), to_char(start_date), to_char(end_date), notes, null, null, null
From Base_Vw Inner Join Current_Engagement Ce On Base_Vw.Eng_Id = Ce.Eng_Id
Where Event_Active = 1
and related_service_id is null
and the result is a bit what I try to achieve (except that I need to work on the screen a message "No data found" rather than anything), but it seems that my code works for one respondent.
COL1                           COL2                           COL3                           COL4                 COL5                 COL6        COL7          
------------------------------ ------------------------------ ------------------------------ -------------------- -------------------- ----------- ---------------
1.Defendant ID                 First Name                     Last Name                      Court Name           Ethnicity            Date Joined Date Terminated 
2                              John                           Doe                            BBB                  Asian                01/10/12                    
2.Service ID                   Service Description            Start Date                     End Date                                                              
3                              Treatment                      01/10/12                       15/10/12                                                              
6                              Treatment                      16/10/12                                                                                             
3.Event ID                     Related Service ID             Start Date                     End date             Notes                                            
5                              2                              03/10/12                                                                                             
4.Event ID                     Start Date                     End date                       Notes                                                                 
4                              02/10/12                                                                                                                            
8                              12/10/12                                                                                                                            

 10 rows selected 
     
However, I struggle to find a way to apply this to more than 1 defendant and always keep the format.
Defendant 1
All details related to defendant 1 
Defendant 2
All details relayed to defendant 2
...
Defendant n
All details relayed to defendant n
Is it possible to view a report as above using only the SQL script?


Thank you very much in advance. I'm ready to financially compensate someone who can give me a solution.

Edited by: Ann586341. Base_vw SQL view script is fixed.

Hi, Ann.

The query I posted earlier can be simplified a bit. You need not partitioned outer joins, which means that you don't need d_num.

WITH     current_engagement     AS
(
     SELECT  Def.Def_Id
     ,     Def.First_Name
     ,         Def.Last_Name
     ,         Eng.Eng_Id
     ,         Eng.Court_Name
     ,         Eng.Date_Joined
     ,         Eng.Date_Terminated
     ,         Eng.Ethnicity
     ,     ROW_NUMBER () OVER ( PARTITION BY  def.def_id
                               ORDER BY          eng.date_joined
                         ,                eng.eng_id
                       )      AS e_num
     FROM      Defendant   Def
       JOIN       Engagement  Eng  ON   Def.Def_Id = Eng.Def_Id
     WHERE     (   Eng.Date_Terminated  IS NULL
          OR  Eng.Date_Terminated      >= TO_DATE (:p_start_date, 'DD/MM/YYYY')
          )
     AND     Eng.Date_Joined           <= TO_DATE (:p_end_date,   'DD/MM/YYYY')
     AND     Eng.court_name           = :p_court_name
)
,     event_types          AS
(
     SELECT  3.2 AS event_type     FROM dual     UNION ALL
     SELECT     4.2                   FROM dual
)
,     union_results          AS
(               -- Section 1 Header: 1 row per defendant
     SELECT  '1.Defendant ID'     AS col1
     ,     'First Name'           AS col2
     ,     'Last Name'          AS col3
     ,     'Court Name'           AS col4
--     ,      'Ethnicity'           AS col5 ...
     ,     def_id
     ,     1.1               AS section_num
     ,     0               AS r_num
     FROM     current_engagement
     WHERE     e_num     = 1
    UNION ALL          -- Section 1 Data: 1 row per defendant
         SELECT     TO_CHAR (def_id)        AS col1
     ,     first_name             AS col2
     ,     last_name             AS col3
     ,     court_name             AS col4
     ,     def_id
     ,     1.2               AS section_num
     ,     1               AS r_num
     FROM     current_engagement
     WHERE     e_num     = 1
    UNION ALL          -- Section 2 Header: 1 row per defendant
       SELECT  '2.Service ID'             AS col1
       ,       'Service Description'     AS col2
       ,       'Start Date'          AS col3
       ,       'End Date'          AS col4
       ,       def_id
       ,       2.1               AS section_num
       ,       0               AS r_num
       FROM    current_engagement
    UNION ALL          -- Section 2 Data: 1 row per service (at least 1 per defendant)
       SELECT DISTINCT
                   NVL ( TO_CHAR (s.service_id),  'No Data')      AS col1
       ,       NVL (s.description,            'No Data')      AS col2
       ,       NVL ( TO_CHAR (s.date_started, 'DD/MM/YYYY')
                           ,                           'No Data')        AS col3
       ,       NVL ( TO_CHAR (s.date_terminated, 'DD/MM/YYYY')
                           ,                           'No Data')      AS col4
       ,       ce2.def_id
       ,       2.2                               AS section_num
       ,       s.service_id                AS r_num
       FROM              current_engagement  ce2
       LEFT OUTER JOIN     service              s      ON   s.eng_id  = ce2.eng_id
                                   AND      s.active  = 1
    UNION ALL          -- Section 3 Header: 1 row per defendant
       SELECT  '3.Event ID'               AS col1
       ,       'Related Service ID'     AS col2
       ,       'Start Date'          AS col3
       ,       'End date'          AS col4
       ,       def_id
       ,       3.1               AS section_num
       ,       0               AS r_num
       FROM    current_engagement
    UNION ALL          -- Section 4 Header: 1 row per defendant
       SELECT  '4.Event ID'               AS col1
       ,       'Start Date'          AS col2
       ,       'End date'          AS col3
       ,       'Notes'               AS col4
       ,       def_id
       ,       4.1               AS section_num
       ,       0               AS r_num
       FROM    current_engagement
    UNION ALL          -- Section 3+4 Data: 1 row per event (at least 2 per defendant)
       SELECT DISTINCT
                   NVL ( TO_CHAR (e.event_id),    'No Data')      AS col1
       ,       NVL ( CASE  et.event_type
                                 WHEN  3.2
                THEN  TO_CHAR (e.related_service_id)
                ELSE  TO_CHAR (e.start_date, 'DD/MM/YYYY')
               END
                           ,                     'No Data')      AS col2
       ,       NVL ( CASE  et.event_type
                                 WHEN  3.2
                THEN  TO_CHAR (e.start_date, 'DD/MM/YYYY')
                ELSE  TO_CHAR (e.end_date,   'DD/MM/YYYY')
               END
                           ,                           'No Data')        AS col3
       ,       NVL ( CASE  et.event_type
                                 WHEN  3.2
                THEN  TO_CHAR (e.end_date  , 'DD/MM/YYYY')
                ELSE  e.notes
               END
                           ,                           'No Data')      AS col4
       ,       ce34.def_id
       ,       et.event_type                          AS section_num
       ,       e.event_id                           AS r_num
       FROM              current_engagement  ce34
       CROSS JOIN     event_types         et
       LEFT OUTER JOIN     event              e      ON   e.eng_id  = ce34.eng_id
                                   AND  e.active  = 1
                                   AND  NVL2 ( e.related_service_id
                                                , 3.2
                                            , 4.2
                                            )    = et.event_type
)
SELECT       col1, col2, col3, col4
FROM       union_results
ORDER BY  def_id
,            section_num
,       r_num
;

Tags: Database

Similar Questions

  • How do the query select outer join to a report of the APEX

    Hi all

    I'm Ann.

    I have a select statement that is used to calculate statistics for a month (October 2012 in this example)
    Select ph.phase_number
    sum ((case
    WHEN ph.date_finished IS NULL or ph.date_finished > last_day (TO_DATE (' ' Oct 2012 ', ' MY YYYY' "))
    THEN last_day (TO_DATE (' ' Oct 2012 ', ' MY YYYY' "))
    Of OTHER ph.date_finished
    END)
    (-ph.date_started + 1) / count (def.def_id) as avg_days
    Ph phase_membership
    inner join court_engagement this on ph.mpm_eng_id = ce.engagement_id
    join in-house defendant def on ce.defendant_id = def.def_id
    where def.active = 1
    and ph.date_started < = last_day (TO_DATE (' ' Oct 2012 ', ' MY YYYY' "))
    and ph.active = 1
    and UPPER (ce.court_name) LIKE '% '.
    Rollup Group (phase_number)
    ;

    The result is as below
    Phase_Number AVG_DAYS
    Phase One 8.6666666666666667
    Phase two 14.6
    Phase three 12
    11.4615365

    I have another list of selection mainly the list of months between two date value.
    Select to_char (which_month, 'LUN YYYY') as display_month
    de)
    Select add_months (to_date (' ' August 2012 ', ' MY YYYY' "), rownum-1) which_month
    of object
    where
    rownum < = months_between (to_date (' ' Oct 2012 ', ' MY YYYY' "), add_months (to_date (' ' August 2012", "MY YYYY"), - 1))
    order of which_month)

    The query result is as below

    DISPLAY_MONTH

    AUGUST 2012
    SEP 2012
    OCT 2012

    Is it possible I can join these two select statement above to generate a comparable result:

    Days of month Phase number Avg
    August 2012 Phase One 8.666
    Sep 2012 Phase One 7.66
    Oct 2012 Phase One 5,66
    August 2012 Phase two 8.666
    Sep 2012 Phase two 7.66
    Oct 2012 Phase two 5,66
    August 2012 Phase three 8.666
    Sep 2012 Phase three 7.66
    Oct 2012 Phase three 5,66

    Or
    Days of month Phase number Avg
    August 2012 Phase One 8.666
    August 2012 Phase two 7.66
    August 2012 Phase three 5,66
    Sep 2012 Phase One 8.666
    Sep 2012 Phase two 7.66
    Sep 2012 Phase three 5,66
    Oct 2012 Phase One 8.666
    Oct 2012 Phase two 7.66
    Oct 2012 Phase three 5,66

    And it can be controlled by Phase number or month.
    My other colleague suggested I should use a left outer join, but after having tried many ways, I'm still stuck.

    I tried select is
    Select a.display_month, b.* in)
    Select to_char (which_month, 'LUN YYYY') as display_month
    de)
    Select add_months (to_date (' ' August 2012 ', ' MY YYYY' "), rownum-1) which_month
    of object
    where
    rownum < = months_between (to_date (' ' Oct 2012 ', ' MY YYYY' "), add_months (to_date (' ' August 2012", "MY YYYY"), - 1))
    order which_month)) a left outer join

    (Select to_char (ph.date_finished, 'MY YYYY') as join_month, ph.phase_number)
    sum ((case
    WHEN ph.date_finished IS NULL or ph.date_finished > last_day (TO_DATE (a.display_month, 'MY YYYY'))
    THEN last_day (TO_DATE (a.display_month, 'MY YYYY'))
    Of OTHER ph.date_finished
    END)
    (-ph.date_started + 1) / count (def.def_id) as avg_days
    Ph phase_membership
    inner join court_engagement this on ph.mpm_eng_id = ce.engagement_id
    join in-house defendant def on ce.defendant_id = def.def_id
    where def.active = 1
    and ph.date_started < = last_day (TO_DATE (a.display_month, 'MY YYYY'))
    and ph.active = 1
    and UPPER (ce.court_name) LIKE '% '.
    To_char (ph.date_finished, 'MY YYYY'), group (phase_number) rollup) b
    On a.display_month = b.join_month

    but then I get an error
    SQL error: ORA-00904: "A." "" DISPLAY_MONTH ": invalid identifier

    I need to view a report on the APEX with option for people to download at least format CSV.
    Already 1 inteactive report in the page, so I don't think adds another interactive report without using the iframe trick.

    If any of you have any ideas, please help.

    Thank you very much.

    Ann

    Hello Ann,.

    Frank has done a very good job. I am also impressed.

    Is in regard to your correction to his question, the problem is on this replacement you did

    last_day(TO_DATE(am.which_month,'MON YYYY'))
    

    AM.which_month is already a date type, and you don't need to convert it to this day.
    Here is the correct way:

    last_day(am.which_month)
    

    There are also sometimes with the data you've posted have no line for this month. So I also added a function NVL to display 0 under avg_days for these cases.

    Here is my corrected query:

    DEFINE startmonth = "Aug 2012";
    DEFINE endmonth   = "Oct 2012";
    WITH  all_months  AS
    (
       SELECT ADD_MONTHS(to_date('&startmonth','MON YYYY'), ROWNUM-1) AS which_month
       ,      ADD_MONTHS(to_date('&startmonth','MON YYYY'), ROWNUM  ) AS next_month
       from all_objects
       where
       rownum <= months_between(to_date('&endmonth','MON YYYY'), add_months(to_date('&startmonth','MON YYYY'), -1))
    )
    SELECT TO_CHAR (am.which_month, 'Mon YYYY')  AS month
         , ph.phase_number
         , NVL(sum ( (CASE
                     WHEN ph.date_finished IS NULL OR ph.date_finished > last_day(am.which_month)
                     THEN last_day(am.which_month)
                     ELSE ph.date_finished
                  END
                 ) - ph.date_started + 1
               ) / count(def.def_id), 0) as avg_days
      FROM all_months am
           LEFT OUTER JOIN  a_phase_membership  ph  PARTITION BY (ph.phase_number)
              ON  am.which_month <= ph.date_started
              AND am.next_month  >  ph.date_started
              AND ph.date_started <= last_day(am.which_month)  -- May not be needed
              AND ph.active = 1
           LEFT OUTER JOIN  a_engagement  ce
              ON  ph.mpm_eng_id = ce.engagement_id
              AND ce.court_name IS NOT NULL  -- or something involving LIKE
           LEFT OUTER join  a_defendant     def
              ON  ce.defendant_id = def.def_id
              AND def.active = 1
     GROUP BY ROLLUP(phase_number, am.which_month)
     ORDER BY  am.which_month
            ,  ph.phase_number
    ;
    
    The output is:
    MONTH    PHASE_NUMBER           AVG_DAYS
    -------- -------------------- ----------
    Aug 2012 PHASE ONE                     0
    Aug 2012 PHASE THREE                   0
    Aug 2012 PHASE TWO                     0
    Sep 2012 PHASE ONE                    12
    Sep 2012 PHASE THREE                   1
    Sep 2012 PHASE TWO                     9
    Oct 2012 PHASE ONE                     8
    Oct 2012 PHASE THREE                   0
    Oct 2012 PHASE TWO                    14
             PHASE ONE                    11
             PHASE THREE                   1
             PHASE TWO                  11.5
                                  9.71428571
    

    I don't know if that's really what you want. In the case check it and let me know.

    Kind regards.
    Al

  • Need advice on how to create the report

    I don't know how to do this, so I ask for advice from the gods apex...

    Here is the question, I have two tables I need to combine the info from. not a problem in his car. I can do it. but here's the question. in table A, I have some data such as title, theids, disc_id, etc... Table B contains fullname, theid, emplid

    now in the table A column "theids" is filled with apex as a multi select list. the values in the column is therefore something like 48; 3; 88

    He got these identification numbers of the Table B (popup lov) query that returns theid of the one of the person.

    now, I need to create a report that will be used in an excel download and what they want is a line by disc_id and they want the most useful "cost" in the field where to run the "theids." It is instead of:

    disc_id title theids
    101 the 48 test; 3; 88

    they want:

    disc_id title Theids
    101 N33456, N3457, try N43562

    so I'm a bit stuck, I can understand how to write a sql using instr to get something like this:
    101 N33456 of test
    101 N3457 of test
    etc.

    but this isn't what they want. so I think I need to create a package to do this and some sort of return values. the problem is that I can't figure out how I can replace the 48; 3; 88 to N33456, N3457, N43562

    I'm still new to this kind of things pl/sql and apex sorry if this appears to be an obvious answer.

    If you have a look at this example:

    http://HTMLDB.Oracle.com/pls/OTN/f?p=31517:138

    You'll see there

    SELECT empno, ename, job, mgr, sal
      FROM emp
     WHERE INSTR(':'||:p138_select_empno||':', ':'||empno||':') > 0
    

    and

    p138_select_empno is a multiple selection list displaying the names of the employees and containing the string of nosm as 7888; 8900; 3499.

    This info is enough to get to a function like this:

    CREATE OR REPLACE FUNCTION get_string (p_string IN VARCHAR2)
       RETURN VARCHAR2
    IS
       v_string   VARCHAR2 (4000);
    BEGIN
       FOR c IN (SELECT ename
                   FROM emp
                  WHERE INSTR (':' || p_string || ':',
                               ':' || empno || ':'
                              ) > 0)
       LOOP
          v_string := v_string || ', ' || c.ename;
       END LOOP;
    
       v_string := LTRIM (v_string, ', ');
       RETURN v_string;
    END;
    

    and use this function in a report like this:

    SELECT get_string (:p138_select_empno)
      FROM DUAL
    

    Denes Kubicek
    ------------------------------------------------------------------------------
    http://deneskubicek.blogspot.com/
    http://www.Opal-consulting.de/training
    http://Apex.Oracle.com/pls/OTN/f?p=31517:1
    ------------------------------------------------------------------------------

  • How to adjust column widths individual classic SQL report

    Hello

    I use Oracle APEX v4.2 with IE8 browser and basically tries to adjust widths of individual columns in my classic SQL report. Basically, I have three columns I want to spacing, so that the width of the entire region for the report is used, but am not sure how to proceed.

    I drilled in individual columns and specified the column widths as the element, but in vain.

    Would appreciate help on how to do this for each column and hope that I do not need to change the model of report (if possible).

    Thank you.

    Tony.

    Tony F. says:

    I use Oracle APEX v4.2 with IE8 browser and basically tries to adjust widths of individual columns in my classic SQL report. Basically, I have three columns I want to spacing, so that the width of the entire region for the report is used, but am not sure how to proceed.

    There is an element of uncertainty in what we suggest as well, because you have not specified the theme and the report of model that is used. This information is required for any question of formatting or the visual layout.

    I drilled in individual columns and specified the column widths as the element, but in vain.

    Report in some themes templates may be missing in the #COLUMN_WIDTH substitution string # required for use of the declarative column widths, as shown here: Re: width of column in reports

    I don't know why it would be missing from a theme of so-called "modern" (perhaps the lack of documentation affects even the Oracle theme designers), but you can add it to the models listed in this thread.

    Width of the element applies only to controls on a form in a table.

    Would appreciate help on how to do this for each column and hope that I do not need to change the model of report (if possible).

    This can be done using selectors CSS attribute (for the themes of quirks mode non-traditional, because you are using a legacy version of IE). Add a style sheet in CSS Inline property page:

    #ALIAS,
    td[headers="ALIAS"] {
    width: 40%;
    }
    

    where the ALIAS value in the attribute selector matches the required column alias, and the width property specifies the column dimension required and the units.

    Note that the percentage widths will be compared to the width of the report table. Therefore, it may be necessary to also specify widths (100%) for the table of report and its components. Exactly how is based on the report, the region and the page templates and theme used, information that was not provided.

  • Change the line color of the standard SQL report

    Hello

    I'm trying to follow this post to change the color of a line in the APEX SQL report. Change the color of line - report SQL Oracle APEX

    It is a little outdated and trying to figure out how to get to this page: http://img7.imageshack.us/img7/4782/columntemplate.jpg 4.2 APEX where I can put under condition of background color.


    I use Theme 13 (inheritance) and make a copy of the report area. Published, but could not find an equivalent section of this screenshot of the apex 3.1.

    Any help appreciated.

    William Wallace says:

    I'm trying to follow this post to change the color of a line in the APEX SQL report. Change the color of line - report SQL Oracle APEX

    It is a little outdated and trying to figure out how to get to this page: http://img7.imageshack.us/img7/4782/columntemplate.jpg 4.2 APEX where I can put under condition of background color.

    I use the theme 13 (legacy)

    Ugh.

    and make a copy of the report area. Published, but could not find an equivalent section of this screenshot of the apex 3.1.

    This suggests that you look at the definition of region page, or even simply the definition of region model. What you need here is a copy of the report model.

    1. go in Home > Application Builder > Application > shared components > models.

    2. Select theme 13 theme filter, the Filter Type reports and click OK.

    3. create a copy of the Standard report model by using the icon copy in the list.

    4. Select the new report template and edit it as shown in the thread linked to above, paying special attention to the content of the second post. (It is of generic column template definition page that contains the section in the screenshot).

  • The number of characters in the CLOB column is supported by the report of the APEX

    Hello

    Actually, I have a report of the Apex based on CLOB column, which includes data whose length exceeds 10,000 characters.

    up to 10,000 characters, it works fine, but once it get records with characters more than 10 + lift

    ORA-06502: PL/SQL: digital or value error: character string buffer too small

    Thank you and best regards,

    Ashish

    2902196 wrote:

    Please update your forum profile with a recognizable username instead of "2902196": Video tutorial how to change username available

    Always include the information referred to in these guidelines when you post a question: How to get the answers from the forum

    Actually, I have a report of the Apex based on CLOB column, which includes data whose length exceeds 10,000 characters.

    up to 10,000 characters, it works fine, but once it get records with characters more than 10 + lift

    ORA-06502: PL/SQL: digital or value error: character string buffer too small

    The maximum size of a column report CLOB value is 32 KB. However, the maximum size for the content of the line of the full report is also 32 KB (including the HTML markup), so you can be hitting this limit because of the size of your 10 K CLOB data + the rest of the line.

    According to the database character set and the characters which that contains data, the character encoding may use more than one byte to represent a character.

  • SQL report

    How can I make the Apex SQL report that follows (two versions)?

    Thank you very much.

    Participation of students in the meetings.

    Students = Aris, Maria

    Meetings = 1, 2, 3 (2014-1-5, 15-1-2014 and 2014-1-25 respectively).

    Participation = 0/1 (absent/present).

    __________________________________________

    Report version 1

    Meeting 1 meeting 2 3

    1 1 ARIS 0

    Maria 1 0 0

    __________________________________________

    Report version 2

    Meeting 1 meeting 2 3

    2014 1-5 15-1-2014 2014-1-25

    1 1 ARIS 0

    Maria 1 0 0

    __________________________________________

    Here's the diagram:

    create table students

    (

    primary key not null ID number,

    name varchar2 (80)

    );

    create table meeting

    (

    primary key not null ID number,

    date of meeting_date

    );

    create the table student_meeting

    (

    primary key not null ID number,

    student_id number of non-null reference student (id),

    meeting_id number of non-null reference meeting (id),

    number of presences,

    check (presence in (0, 1))

    );

    insert into values student (11, "Aris");

    insert into values student (12, 'Maria');

    Insert in the encounter of the values (1, '' 2014-01-05);

    insert into values of meeting (date 2, '' 2014-01-15).

    Insert in meeting values (3, '' 2014-01-25).

    insert into student_meeting values (101, 11, 1, 1);

    insert into student_meeting values (102, 11, 2, 1);

    insert into student_meeting values (103, 11, 3, 0);

    insert into student_meeting values (104, 12, 1, 1);

    insert into student_meeting values (105, 12, 2, 0);

    insert into student_meeting values (106, 12, 3, 0);

    commit;

    What you want is called a matrix or pivot table dynamic PivotTable report... Take a look at this link RPF (as long as you eon ar 11g for a database...) for example: Vishal blog: methods of creating matrix in Oracle APEX report

    Thank you

    Tony Miller
    Software LuvMuffin
    Ruckersville, WILL

  • UTF8 National characters in the reports of the APEX

    Hello

    We have a table of type NVARCHAR2 column (200), which contains characters russion (utf8).

    It is stored and displayed correctly in our development tools.

    However, in the reports of the APEX (Classic and IR), the values are truncated. It's the same thing when you make a SELECTION in the SQL workshop.

    Once the setting (SELECT * FROM NLS_DATABASE_PARAMETERS):

    PARAMETER VALUE
    NLS_NCHAR_CHARACTERSETAL16UTF16
    NLS_LANGUAGEAMERICAN
    NLS_TERRITORYAMERICA
    NLS_CURRENCY$
    NLS_ISO_CURRENCYAMERICA
    NLS_NUMERIC_CHARACTERS.,
    NLS_CHARACTERSETWE8ISO8859P1
    NLS_CALENDARGREGORIAN
    NLS_DATE_FORMATDD-MON-RR
    NLS_DATE_LANGUAGE

    AMERICAN

    APEX Application is created by default, no globalization setting is changed.

    Any ideas?

    Best regards

    Martin

    APEX and UTF-8 FAQ autour?

  • SQL report should look to the updating of the continuous element

    Hello

    I have a question about how it is possible to do a SQL report that looks like the element continuous is changed in the browser.

    I now have this SQL query:

    Select x.first_name, x.Last_name, it. Nom_element, ui.user_item_ID, ui.item_ID, ui.employee_number

    of APEX_EBS_ACTIVE_LIST x,.

    USER_ITEMS ui,

    ELEMENT that she

    where x.employee_number = ui.employee_number

    and it.item_id = ui.item_id

    and ui.employee_number =: p7_employee_number

    ORDER BY x.last_name

    I have Apex page 7 a popup lov (P7_employee_number. When selection here the employee_number I want that the SQL query displays at the same time the report below on the page with the information on the employee.

    Does anyone know how this is possible? I use APEX 4.2

    Thank you!


    Concerning
    ELCO

    ELCO

    On point page p7_employee_number have a dynamic action with the event 'change '.

    Have an action "Refresh" with as affected the region of you're sql statement.

    Make sure that the p7_employee_number element is declared as "Elements of Page to submit" to the region.

    Which will refresh the report whenever the item is changed.

    It is with the section of the page and the report are not on the same page apex.

    Nicolette

  • How add us a button to check for each line in a report to oracle Apex?

    How we publish one every line ina report in oracle Apex? (with the help of select * from empdate)

    I need to add new row in the table (with the help of select * from empdate)

    I need to click on the box and I want to delete the row from the table!

    I need to click on the box and I want to change the whole table raow!

    See this blog entry for an example: adding a checkbox to your report & #8211; APEX_ITEM tutorial & #8211; APEX blog

    Thank you

    Tony Miller

    Software LuvMuffin

  • Change the width of the columns in Sql report

    Hello

    I use Apex 4.1

    Can someone tell me how we can change the width of the Sql report. For report IR we can do this by using the following code,

    < style >
    table.apexir_WORKSHEET_DATA td [headers = "Name of the pass"] {}
    _width: 500px;
    min-width: 400px; < / style >

    Please help me with Sql Report.

    Thank you
    Shoaib

    Published by: Shoaib581 on January 21, 2013 03:05

    Shoaib581 wrote:
    Hello

    I use Apex 4.1

    Can someone tell me how we can change the width of the Sql report. For report IR we can do this by using the following code,

    Always zip code using .

    ...\
    

    Tags:

    
    

    Please help me with Sql Report.

    Either use the same CSS approach by adding a static region ID in the report area and adding the style sheet in the header HTML page: