CONNECT BY PRIOR USING MULTIPLE TABLES RETURNS  AWKAWARD RESULTS.

CREATE TABLE "JAM"."FTVORGN2"
   (    "FTVORGN_COAS_CODE" VARCHAR2(1 CHAR) NOT NULL ENABLE,
    "FTVORGN_ORGN_CODE" VARCHAR2(6 CHAR) NOT NULL ENABLE,
    "FTVORGN_EFF_DATE" DATE NOT NULL ENABLE,
    "FTVORGN_ACTIVITY_DATE" DATE NOT NULL ENABLE,
    "FTVORGN_USER_ID" VARCHAR2(30 CHAR) NOT NULL ENABLE,
    "FTVORGN_NCHG_DATE" DATE NOT NULL ENABLE,
    "FTVORGN_TERM_DATE" DATE,
    "FTVORGN_TITLE" VARCHAR2(35 CHAR) NOT NULL ENABLE,
    "FTVORGN_STATUS_IND" VARCHAR2(1 CHAR),
    "FTVORGN_ORGN_CODE_PRED" VARCHAR2(6 CHAR),
    "FTVORGN_DATA_ENTRY_IND" VARCHAR2(1 CHAR) NOT NULL ENABLE,
    "FTVORGN_VPDI_CODE" VARCHAR2(6 CHAR)
I have a table like the above.
I also have a table like the below.
CREATE TABLE "JAM"."FORUSOR"
   (    "FORUSOR_USER_ID_ENTERED" VARCHAR2(30 CHAR) NOT NULL ENABLE,
    "FORUSOR_COAS_CODE" VARCHAR2(1 CHAR) NOT NULL ENABLE,
    "FORUSOR_ORGN_CODE" VARCHAR2(6 CHAR) NOT NULL ENABLE,
    "FORUSOR_ACCESS_IND" VARCHAR2(1 CHAR) NOT NULL ENABLE,
    "FORUSOR_ACTIVITY_DATE" DATE NOT NULL ENABLE,
    "FORUSOR_USER_ID" VARCHAR2(30 CHAR) NOT NULL ENABLE,
    "FORUSOR_WBUD_ACCESS_IND" VARCHAR2(1 CHAR) NOT NULL ENABLE,
    "FORUSOR_SURROGATE_ID" NUMBER(19,0),
    "FORUSOR_VERSION" NUMBER(19,0),
    "FORUSOR_DATA_ORIGIN" VARCHAR2(30 CHAR),
    "FORUSOR_VPDI_CODE" VARCHAR2(6 CHAR)
REM INSERTING into FTVORGN2
SET DEFINE OFF;
Insert into FTVORGN2 (FTVORGN_COAS_CODE,FTVORGN_ORGN_CODE,FTVORGN_EFF_DATE,FTVORGN_ACTIVITY_DATE,FTVORGN_USER_ID,FTVORGN_NCHG_DATE,FTVORGN_TERM_DATE,FTVORGN_TITLE,FTVORGN_STATUS_IND,FTVORGN_ORGN_CODE_PRED,FTVORGN_DATA_ENTRY_IND,FTVORGN_VPDI_CODE) values ('D','01',to_date('01-OCT-88','DD-MON-RR'),to_date('19-MAR-97','DD-MON-RR'),'TRAIN01',to_date('31-DEC-99','DD-MON-RR'),null,'TOTAL UNIVERSITY','A',null,'N',null);
Insert into FTVORGN2 (FTVORGN_COAS_CODE,FTVORGN_ORGN_CODE,FTVORGN_EFF_DATE,FTVORGN_ACTIVITY_DATE,FTVORGN_USER_ID,FTVORGN_NCHG_DATE,FTVORGN_TERM_DATE,FTVORGN_TITLE,FTVORGN_STATUS_IND,FTVORGN_ORGN_CODE_PRED,FTVORGN_DATA_ENTRY_IND,FTVORGN_VPDI_CODE) values ('D','1006',to_date('22-SEP-14','DD-MON-RR'),to_date('22-SEP-14','DD-MON-RR'),'MJ35',to_date('31-DEC-99','DD-MON-RR'),null,'Provost','A','01','N',null);
Insert into FTVORGN2 (FTVORGN_COAS_CODE,FTVORGN_ORGN_CODE,FTVORGN_EFF_DATE,FTVORGN_ACTIVITY_DATE,FTVORGN_USER_ID,FTVORGN_NCHG_DATE,FTVORGN_TERM_DATE,FTVORGN_TITLE,FTVORGN_STATUS_IND,FTVORGN_ORGN_CODE_PRED,FTVORGN_DATA_ENTRY_IND,FTVORGN_VPDI_CODE) values ('D','2027',to_date('01-OCT-97','DD-MON-RR'),to_date('01-OCT-97','DD-MON-RR'),'DARDARMT',to_date('31-DEC-99','DD-MON-RR'),null,'Sch of Biomed Engr, Sci Health Sys','A','1006','N',null);
Insert into FTVORGN2 (FTVORGN_COAS_CODE,FTVORGN_ORGN_CODE,FTVORGN_EFF_DATE,FTVORGN_ACTIVITY_DATE,FTVORGN_USER_ID,FTVORGN_NCHG_DATE,FTVORGN_TERM_DATE,FTVORGN_TITLE,FTVORGN_STATUS_IND,FTVORGN_ORGN_CODE_PRED,FTVORGN_DATA_ENTRY_IND,FTVORGN_VPDI_CODE) values ('D','2028',to_date('28-FEB-01','DD-MON-RR'),to_date('28-FEB-01','DD-MON-RR'),'JMOORE',to_date('31-DEC-99','DD-MON-RR'),null,'Sch of Envr Science, Engr Policy','A','1006','N',null);
Insert into FTVORGN2 (FTVORGN_COAS_CODE,FTVORGN_ORGN_CODE,FTVORGN_EFF_DATE,FTVORGN_ACTIVITY_DATE,FTVORGN_USER_ID,FTVORGN_NCHG_DATE,FTVORGN_TERM_DATE,FTVORGN_TITLE,FTVORGN_STATUS_IND,FTVORGN_ORGN_CODE_PRED,FTVORGN_DATA_ENTRY_IND,FTVORGN_VPDI_CODE) values ('D','5275',to_date('01-OCT-97','DD-MON-RR'),to_date('02-JUL-99','DD-MON-RR'),'JMOORE',to_date('31-DEC-99','DD-MON-RR'),null,'Administration','A','1006','N',null);
Insert into FTVORGN2 (FTVORGN_COAS_CODE,FTVORGN_ORGN_CODE,FTVORGN_EFF_DATE,FTVORGN_ACTIVITY_DATE,FTVORGN_USER_ID,FTVORGN_NCHG_DATE,FTVORGN_TERM_DATE,FTVORGN_TITLE,FTVORGN_STATUS_IND,FTVORGN_ORGN_CODE_PRED,FTVORGN_DATA_ENTRY_IND,FTVORGN_VPDI_CODE) values ('D','5325',to_date('01-OCT-97','DD-MON-RR'),to_date('13-JAN-00','DD-MON-RR'),'JMOORE',to_date('31-DEC-99','DD-MON-RR'),null,'Enrollment & Career Management','A','1006','N',null);
Insert into FTVORGN2 (FTVORGN_COAS_CODE,FTVORGN_ORGN_CODE,FTVORGN_EFF_DATE,FTVORGN_ACTIVITY_DATE,FTVORGN_USER_ID,FTVORGN_NCHG_DATE,FTVORGN_TERM_DATE,FTVORGN_TITLE,FTVORGN_STATUS_IND,FTVORGN_ORGN_CODE_PRED,FTVORGN_DATA_ENTRY_IND,FTVORGN_VPDI_CODE) values ('D','5350',to_date('01-OCT-97','DD-MON-RR'),to_date('02-JUL-99','DD-MON-RR'),'JMOORE',to_date('31-DEC-99','DD-MON-RR'),null,'Office of Education','A','1006','N',null);
Insert into FTVORGN2 (FTVORGN_COAS_CODE,FTVORGN_ORGN_CODE,FTVORGN_EFF_DATE,FTVORGN_ACTIVITY_DATE,FTVORGN_USER_ID,FTVORGN_NCHG_DATE,FTVORGN_TERM_DATE,FTVORGN_TITLE,FTVORGN_STATUS_IND,FTVORGN_ORGN_CODE_PRED,FTVORGN_DATA_ENTRY_IND,FTVORGN_VPDI_CODE) values ('D','5365',to_date('01-OCT-97','DD-MON-RR'),to_date('02-JUL-99','DD-MON-RR'),'JMOORE',to_date('31-DEC-99','DD-MON-RR'),null,'Library','A','1006','N',null);
REM INSERTING into FORUSOR
SET DEFINE OFF;
Insert into FORUSOR (FORUSOR_USER_ID_ENTERED,FORUSOR_COAS_CODE,FORUSOR_ORGN_CODE,FORUSOR_ACCESS_IND,FORUSOR_ACTIVITY_DATE,FORUSOR_USER_ID,FORUSOR_WBUD_ACCESS_IND,FORUSOR_SURROGATE_ID,FORUSOR_VERSION,FORUSOR_DATA_ORIGIN,FORUSOR_VPDI_CODE) values ('jam337','D','1006','B',to_date('01-AUG-12','DD-MON-RR'),'P','N',null,null,null,null);
Insert into FORUSOR (FORUSOR_USER_ID_ENTERED,FORUSOR_COAS_CODE,FORUSOR_ORGN_CODE,FORUSOR_ACCESS_IND,FORUSOR_ACTIVITY_DATE,FORUSOR_USER_ID,FORUSOR_WBUD_ACCESS_IND,FORUSOR_SURROGATE_ID,FORUSOR_VERSION,FORUSOR_DATA_ORIGIN,FORUSOR_VPDI_CODE) values ('jam337','D','1007','B',to_date('01-AUG-12','DD-MON-RR'),'P','N',null,null,null,null);
Insert into FORUSOR (FORUSOR_USER_ID_ENTERED,FORUSOR_COAS_CODE,FORUSOR_ORGN_CODE,FORUSOR_ACCESS_IND,FORUSOR_ACTIVITY_DATE,FORUSOR_USER_ID,FORUSOR_WBUD_ACCESS_IND,FORUSOR_SURROGATE_ID,FORUSOR_VERSION,FORUSOR_DATA_ORIGIN,FORUSOR_VPDI_CODE) values ('jam337','D','1011','B',to_date('01-AUG-12','DD-MON-RR'),'P','N',null,null,null,null);
Insert into FORUSOR (FORUSOR_USER_ID_ENTERED,FORUSOR_COAS_CODE,FORUSOR_ORGN_CODE,FORUSOR_ACCESS_IND,FORUSOR_ACTIVITY_DATE,FORUSOR_USER_ID,FORUSOR_WBUD_ACCESS_IND,FORUSOR_SURROGATE_ID,FORUSOR_VERSION,FORUSOR_DATA_ORIGIN,FORUSOR_VPDI_CODE) values ('jam337','D','1026','Q',to_date('30-JAN-08','DD-MON-RR'),'P','N',null,null,null,null);
Insert into FORUSOR (FORUSOR_USER_ID_ENTERED,FORUSOR_COAS_CODE,FORUSOR_ORGN_CODE,FORUSOR_ACCESS_IND,FORUSOR_ACTIVITY_DATE,FORUSOR_USER_ID,FORUSOR_WBUD_ACCESS_IND,FORUSOR_SURROGATE_ID,FORUSOR_VERSION,FORUSOR_DATA_ORIGIN,FORUSOR_VPDI_CODE) values ('jam337','D','1100','Q',to_date('30-JAN-08','DD-MON-RR'),'P','N',null,null,null,null);
the ftvorgn table is hierachical in nature, where the forusor table is not . The FORUSOR table holds the name and a hiearchy node from the FTVORGN TABLE within it.
I have spent several hours trying to get a query to work. I just don't see  what my error is? if you follow the trail thus far you will notice that the FORUSOR table contains a value of '1006' in  the FORUSOR_ORGN_CODE  column. However everytime I run this query i get duplicate rows in return.
SELECT FTVORGN_ORGN_CODE,
             FTVORGN_DATA_ENTRY_IND,
             FTVORGN_TITLE,
             FTVORGN_STATUS_IND,
             FTVORGN_ORGN_CODE_NSF,
             FTVORGN_HIERARCHY_TABLE_IND,
             LEVEL, FTVORGN_ORGN_CODE_PRED
     FROM    FTVORGN2, FORUSOR
     WHERE   FORUSOR.FORUSOR_USER_ID_ENTERED = 'jam337'
    CONNECT BY PRIOR FTVORGN_ORGN_CODE = FTVORGN_ORGN_CODE_PRED
             AND   PRIOR FTVORGN_COAS_CODE = FTVORGN_COAS_CODE
             AND   FTVORGN_EFF_DATE <= TO_DATE(sysdate)
             AND   FTVORGN_NCHG_DATE > TO_DATE(sysdate)
  START WITH       FTVORGN_ORGN_CODE = FORUSOR_ORGN_CODE
             AND   FTVORGN_COAS_CODE = 'D'
             AND   FTVORGN_EFF_DATE <= TO_DATE(sysdate)
             AND   FTVORGN_NCHG_DATE > TO_DATE(sysdate);
I't trying to basically get all the predecessor notes for everynote on FORUSOR but i keep ending up with  duplicate rows.
I should end up with something similar to this.
sorry for the format of the results I'm not very good at formatting.
"FTVORGN_ORGN_CODE"      
"FTVORGN_DATA_ENTRY_IND" 
"FTVORGN_STATUS_IND"     
"LEVEL"                  
"FTVORGN_ORGN_CODE_PRED"
"1006"                   
"N"                      
"A"                      
"1"                      
"01"                    
"2027"                   
"N"                      
"A"                      
"2"                      
"1006"                  
"2028"                   
"N"                      
"A"                      
"2"                      
"1006"                  
"5275"                   
"N"                      
"A"                      
"2"                      
"1006"                  
"5325"                   
"N"                      
"A"                      
"2"                      
"1006"                  
"5350"                   
"N"                      
"A"                      
"2"                      
"1006"                  
"5365"                   
"N"                      
"A"                      
"2"                      
"1006"                  
on column FORUSOR_ORGN_CODE in the FORUSOR table there is a node value that corresponds to a value on FTVORGN. However , that value could have a FTVORGN_ORGN_CODE_PRED which basically says I'm reporting to this value.
if I basically run this query for a node you can see the hierachy.
SELECT FTVORGN_ORGN_CODE,
             FTVORGN_DATA_ENTRY_IND,
             FTVORGN_STATUS_IND,
             LEVEL, FTVORGN_ORGN_CODE_PRED
     FROM    FTVORGN2
  CONNECT BY PRIOR FTVORGN_ORGN_CODE = FTVORGN_ORGN_CODE_PRED
             AND   PRIOR FTVORGN_COAS_CODE = FTVORGN_COAS_CODE
             AND   FTVORGN_EFF_DATE <= TO_DATE(sysdate)
             AND   FTVORGN_NCHG_DATE > TO_DATE(sysdate)
  START WITH       FTVORGN_ORGN_CODE = '1006'
             AND   FTVORGN_COAS_CODE = 'D'
             AND   FTVORGN_EFF_DATE <= TO_DATE(sysdate)
             AND   FTVORGN_NCHG_DATE > TO_DATE(sysdate);
I now need to pass the orgn code from forusor to this query to get all the ftvorgn_orgn_code that this user technically has reporting to him on FORUSOR.
so for example user jma337 has org
1006 in forusor
when i run the query i should get
jma337  2027
jma337  2028
jma337 5275 etc.
Reason in because these are all predecessors of 1006 which in this case would essentially be our level 1.
I need to do this all the FORUSOR_ORGN_CODE this user has recorded to him on FORUSOR.

Switching to four digit years (to make the query work)
with
ftvorgn2 as
(select 'D' ftvorgn_coas_code,
        '01' ftvorgn_orgn_code,
        to_date('01-OCT-1988','DD-MON-YYYY') ftvorgn_eff_date,
        to_date('19-MAR-1997','DD-MON-YYYY') ftvorgn_activity_date,
        'TRAIN01' ftvorgn_user_id,
        to_date('31-DEC-2099','DD-MON-YYYY') ftvorgn_nchg_date,
        null ftvorgn_term_date,
        'TOTAL UNIVERSITY' ftvorgn_title,
        'A' ftvorgn_status_ind,
        null ftvorgn_orgn_code_pred,
        'N' ftvorgn_data_entry_ind,
        null ftvorgn_vpdi_code
   from dual
union all
select 'D','1006',to_date('22-SEP-2014','DD-MON-YYYY'),to_date('22-SEP-2014','DD-MON-YYYY'),'MJ35',to_date('31-DEC-2099','DD-MON-YYYY'),null,'Provost','A','01','N',null from dual union all
select 'D','2027',to_date('01-OCT-1997','DD-MON-YYYY'),to_date('01-OCT-1997','DD-MON-YYYY'),'DARDARMT',to_date('31-DEC-2099','DD-MON-YYYY'),null,'Sch of Biomed Engr, Sci Health Sys','A','1006','N',null from dual union all
select 'D','2028',to_date('28-FEB-2001','DD-MON-YYYY'),to_date('28-FEB-2001','DD-MON-YYYY'),'JMOORE',to_date('31-DEC-2099','DD-MON-YYYY'),null,'Sch of Envr Science, Engr Policy','A','1006','N',null from dual union all
select 'D','5275',to_date('01-OCT-1997','DD-MON-YYYY'),to_date('02-JUL-1999','DD-MON-YYYY'),'JMOORE',to_date('31-DEC-2099','DD-MON-YYYY'),null,'Administration','A','1006','N',null from dual union all
select 'D','5325',to_date('01-OCT-1997','DD-MON-YYYY'),to_date('13-JAN-2000','DD-MON-YYYY'),'JMOORE',to_date('31-DEC-2099','DD-MON-YYYY'),null,'Enrollment & Career Management','A','1006','N',null from dual union all
select 'D','5350',to_date('01-OCT-1997','DD-MON-YYYY'),to_date('02-JUL-1999','DD-MON-YYYY'),'JMOORE',to_date('31-DEC-2099','DD-MON-YYYY'),null,'Office of Education','A','1006','N',null from dual union all
select 'D','5365',to_date('01-OCT-1997','DD-MON-YYYY'),to_date('02-JUL-1999','DD-MON-YYYY'),'JMOORE',to_date('31-DEC-2099','DD-MON-YYYY'),null,'Library','A','1006','N',null from dual
forusor as
(select 'jam337' forusor_user_id_entered,
        'D' forusor_coas_code,
        '1006' forusor_orgn_code,
        'B' forusor_access_ind,
        to_date('01-AUG-12','DD-MON-RR') forusor_activity_date,
        'P' forusor_user_id,
        'N' forusor_wbud_access_ind,
        null forusor_surrogate_id,
        null forusor_version,
        null forusor_data_origin,
        null forusor_vpdi_code
    from dual
union all
select 'jam337','D','1007','B',to_date('01-AUG-2012','DD-MON-YYYY'),'P','N',null,null,null,null from dual union all
select 'jam337','D','1011','B',to_date('01-AUG-2012','DD-MON-YYYY'),'P','N',null,null,null,null from dual union all
select 'jam337','D','1026','Q',to_date('30-JAN-2008','DD-MON-YYYY'),'P','N',null,null,null,null from dual union all
select 'jam337','D','1100','Q',to_date('30-JAN-2008','DD-MON-YYYY'),'P','N',null,null,null,null from dual
select ftvorgn_orgn_code, 
       ftvorgn_data_entry_ind, 
       ftvorgn_title, 
       ftvorgn_status_ind, 
    -- ftvorgn_orgn_code_nsf, 
    -- ftvorgn_hierarchy_table_ind, 
       level,
       ftvorgn_orgn_code_pred 
  from ftvorgn2
start with ftvorgn_orgn_code in (select forusor_orgn_code 
                                    from forusor
                                   where forusor_user_id_entered = 'jam337'
                                 --  and forusor_coas_code = 'D'
connect by prior ftvorgn_orgn_code = ftvorgn_orgn_code_pred
       and ftvorgn_eff_date <= sysdate
       and ftvorgn_nchg_date > sysdate
FTVORGN_ORGN_CODE
FTVORGN_DATA_ENTRY_IND
FTVORGN_TITLE
FTVORGN_STATUS_IND
LEVEL
FTVORGN_ORGN_CODE_PRED
1006
N
Provost
A
1
01
2027
N
Sch of Biomed Engr, Sci Health Sys
A
2
1006
2028
N
Sch of Envr Science, Engr Policy
A
2
1006
5275
N
Administration
A
2
1006
5325
N
Enrollment & Career Management
A
2
1006
5350
N
Office of Education
A
2
1006
5365
N
Library
A
2
1006
Regards
Etbin

Similar Messages

  • Get error when CONNECT BY PRIOR used by where

    Hi
    I get "No more data to read from socket" error when the result of CONNECT BY PRIOR used after where, is there anybody encounter this error?
    example SQL:
    select
    from table_A
    where exists
    (select 1 from table_b
    START WITH table_b.col1 = 'value'
    CONNECT BY PRIOR table_b.col1 = table_b.col2)
    The sql select 1 from table_b START WITH table_b.col1 = 'value' CONNECT BY PRIOR table_b.col1 = table_b.col2 can return 2 row correct, but the whole sql does not work.

    Hi! Rahul,
    Thank you for your reply first. Your method doesn't work in my case.  Can you tell me the steps of creating a new layout for added records and draft documents.  I have created a quotation layout which work with added records only, the steps has been show below and please comments, thanks.
    1. In Crystal Report > new blank report > create new connection > Choose "SAP Business One" > Select OQUT under "B1 Tables".
    2. Insert "CardName" field to report > Create DocKey@ parameter and  set it equal to DocEntry in select expert record function
    3. Click Add-ins > SAP Business One > Save > Choose company database and input manager password.
    Regards,
    Ivan

  • How to use multiple table in single control file?

    Hi,
    How to use multiple table and data file in sigle control file? I have a four table and four csv file i mean data file for that. I am running concurrent program to load the data from csv file to custom table. based on my input data file name, it has to take automatically from one control file.
    Can anyone share with me how can i acheive this?
    Thanks

    Hi,
    Can't we acehive like below. I don't this exactly corrcect.
    OPTIONS (SKIP=1)
    LOAD DATA
    INFILE << file name 1 >>
    APPEND INTO TABLE XXCZ_VA_SAMPLE1
    FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS
         PARENT_ITEM               "TRIM(BOTH FROM :PARENT_ITEM)"
    LOAD DATA
    INFILE << file name 2 >>
    APPEND INTO TABLE XXCZ_VA_SAMPLE2
    FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS
         ITEM_NUMBER               "TRIM(BOTH FROM :ITEM_NUMBER)"
    )Edited by: orasuriya on Sep 14, 2009 3:03 AM

  • Using table comparison can we use multiple tables as source?

    Using table comparison can we use multiple tables as source?
    Thank you very much for the helpful info.

    Table Comparison
    1) Input Data coming in
    2) Comparison table (table to which the data is compared)
    3) Output (input rows with respective opcodes based on the comparison result of input dataset with the comparison table)
    If your question is whether table comparison can accept union/join of multiple table sources, you can achieve by using merge/query transforms and then feeding to table comparison. Here, you have to be careful about choosing the primary keys inside table comparison

  • Writeback using Multiple tables

    Hello Everyone,
    1. Can we create a report with writeback capabilities using Multiple tables (Say one fact and several dimensions)?.
    Whatever examples I'm seeing in blogs or forums with screesnshots , explains writeback Reports created with just one table.
    2. If writeback can work with reports using multiple tables, how do we need to change the XML scripts in custom message folder(insert and update)?
    any example ?
    Your suggestions are appreciated.
    Thanks

    You can only send one statement. Then if you want update many tables, you have to use a procedure/function in your SQL statement. For instance with a table function:
    http://gerardnico.com/wiki/database/oracle/table_function
    But I will advice you to do it with the simplest way possible: then one answer for one table to update.
    Success
    Nico

  • "Failed to open the connection" problem related to multiple tables in the report?

    Post Author: Gadow
    CA Forum: Data Connectivity and SQL
    System specifics:
    Web environment using ASP.Net 2.0 (from Visual Studio 2005 Professional)
    Crystal Reports 2008, v. 12.0.0.549, Full
    We have set up the following method for displaying reports via our website:
    User is sent to a report-specific page. The user is given some filtering options specific to the report that will be viewed. When the user has specified the data filters, the user clicks a button.
    The page wraps up the report parameters -- selection query, formula values, report location, the name to be displayed, etc. -- into a class which gets put into the Session object.
    The page redirects to DisplayReport.aspx. ALL reports redirect to this page.
    DisplayReport.aspx retrieves the report parameters from Session. A ReportDocument object is created and loaded, then set with the data from the parameters class.
    A ConnectionInfo object is created and set with the relevant log on credentials. All of the reports draw from the same database, so the connection information is hard-coded as the same for all reports. The page then iterates through all of the tables in the Database.Tables collection of the ReportDocument and calls ApplyLogOnInfo to each table using the ConnectionInfo object.
    The page is rendered and the user gets the filtered report.
    We currently have seven reports. Five reports work fine and display the correctly filtered data with no error messages. Two reports generate a Failed to open the connection error and do not display. I have verified that the queries being sent to DisplayReport.aspx are valid, and as I said the connection information itself is hard-coded in the one page that displays the reports and this is identical to all reports.
    The five reports that do work all have a single data table, either an actual database table or a single view. The two reports that do not work all have multiple tables. As far as I can tell, this is the only difference between the sets; all seven reports are based on the same DSN and I have verified the database on all of the reports. All of the reports were written using Crystal Reports 8, and all of the reports display fine in a Windows app I wrote some years ago using Crystal Reports 8. Again, the only difference between those reports that do work and those that do not is the number of tables used in the report: one table or view in the reports that display, more than one table (tables only, none use views) in the reports that do not display.
    As for the code I am using, below are the relevant methods. The function MakeConnectionInfo simply parses out the components of a standard SQL connection string into a ConnectionInfo object. DisplayedReport is the ID of the CrystalReportViewer on the page.Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs)
            Dim o As Object = Session("ReportParams")
            Dim ReportURL As String = ""
            'Verify that there is a ReportParameters object
            If o Is Nothing OrElse o.GetType IsNot GetType(ReportParameters) Then 'Redirect to the error page
                Response.Redirect("/errors/MissingReport.aspx")
            End If
            ReportParams = CType(o, ReportParameters)
            'Verify that the report exists
            ReportURL = "/Reports/ReportFiles/" + ReportParams.ReportName
            ReportPath = Server.MapPath(ReportURL)
            If Not File.Exists(ReportPath) Then
                Response.Redirect("/errors/MissingReport.aspx?Report=" + ReportParams.ReportTitle)
            End If
            InitializeReport()       
        End Sub
        Protected Sub InitializeReport()
            Dim RD As New ReportDocument
            Dim CI As ConnectionInfo = MakeConnectionInfo(DB_Bonus)
            Dim RPF As CrystalDecisions.Shared.ParameterField = Nothing
            RD.Load(ReportPath)
            If ReportParams.SelectString <> "" Then
                Dim Adapt As New SqlDataAdapter(ReportParams.SelectString, DB_Bonus)
                Dim DS As New Data.DataSet
                Adapt.Fill(DS)
                RD.SetDataSource(DS.Tables(0))
            End If
            For Each kvp As KeyValuePair(Of String, String) In ReportParams.Formulas
                Dim FFD As FormulaFieldDefinition = Nothing
                Try
                    FFD = RD.DataDefinition.FormulaFields(kvp.Key)
                Catch ex As Exception
                    'Do nothing
                End Try
                If FFD IsNot Nothing Then
                    Select Case FFD.ValueType
                        Case FieldValueType.DateField, FieldValueType.DateTimeField
                            If IsDate(kvp.Value) Then
                                FFD.Text = String.Format("Date()", Convert.ToDateTime(kvp.Value).ToString("yyyy, MM, dd"))
                            Else
                                FFD.Text = "Date(1960, 01, 01)"
                            End If
                        Case FieldValueType.StringField
                            FFD.Text = String.Format("""""", kvp.Value)
                        Case Else
                            'For now, treat these as if they were strings. If things blow up here,
                            'we will need to add the appropriate formatting for the field type.
                            FFD.Text = String.Format("""""", kvp.Value)
                    End Select
                End If
            Next
            For Each T As CrystalDecisions.CrystalReports.Engine.Table In RD.Database.Tables
                Dim TLI As TableLogOnInfo = T.LogOnInfo
                TLI.ConnectionInfo = CI
                T.ApplyLogOnInfo(TLI)
            Next
            DisplayedReport.ReportSource = RD
        End Sub
    Does this approach not work with reports containing multiple tables, or is there something I'm missing? Any meaningful suggestions would be much appreciated.

    Dear Dixit,
    Please refer to the Crystal report landing page to get the details
    information about the support for crystal report issues.
    Please use the following thread to post your questions related to
    crystal report.
    SAP Business One and Crystal Reports
    Regards,
    Rakesh Pati
    SAP Business One Forum Team.

  • Reports using multiple tables

    I am trying to create a report using portal that use links between multiple columns. The info I want is mainly in two tables. Some of the info in the table is numeric (Foreign Keys). I want to display them in readable format so set up joins to the respective parent tables. When I do this the result only produces 12 lines of output irrespective of the number of lines I set per page. When I show only the data from the main tables, without the joins to the other parent tables, i.e. the foreign keys as numbers I get all the rows. I have tried to create the report by using all three options given but get the same result.
    I am using 9iAS verison 1.0.2.0 and Portal version 3.0.7.
    Can someone please explain why this happens and how I can solve this problem urgently.

    Hi Ashok,
    Sorry for posting the solution with delay. Actually I ran into the similar situation and upon deep analysis, I could crack it., the very next day.
    This is how your write back template should be for updating on multiple tables
    <?xml version="1.0" encoding="utf-8" ?>
    <WebMessageTables xmlns:sawm="com.siebel.analytics.web/message/v1">
    <WebMessageTable lang="en-us" system="WriteBack" table="Messages">
    <WebMessage name="WRITE">
    <XML>
    <writeBack connectionPool="Oracle Data Warehouse Connection Pool">
    <insert> </insert>
    <update> UPDATE FACT SET COUNT = '@{c4}', W_UPDATE_DT = CURRENT_DATE
    WHERE EXISTS (SELECT ROW_WID FROM DIM WHERE DIM.ROW_WID = FACT.DIM_WID AND
    DIM.X = '@{c1}' AND DIM.Y= '@{c2}' AND DIM.Z = '@{c3}' ) AND EXISTS (SELECT ROW_WID FROM DT WHERE DT.ROW_WID = FACT.DT_WID AND DT.PER_NAME_YEAR = '@{c0}') </update>
    </writeBack>
    </XML>
    </WebMessage>
    </WebMessageTable>
    </WebMessageTables>
    =====
    Using exits, will improve the performance.
    Hope it helps. If yes, pls award points. Thanks
    Regards,
    Sarat Nallapati

  • Left outer join using multiple table

    Hi,
    I am trying to use left outer join with multiple tables , the join condition will be based on  PERNR and BEGDA & ENDA for each infotype in selection screen.
      select pa00~pernr pa00~begda pa00~endda pa00~massn pa00~massg pa00~stat2 pa00~aedtm pa00~uname
        pa01~begda pa01~endda pa01~bukrs pa01~persg pa01~persk pa01~mstbr pa01~ename pa01~aedtm pa01~uname
        pa02~begda pa02~endda pa02~nachn pa02~vorna pa02~midnm pa02~aedtm pa02~uname
        pa016~begda pa016~endda pa016~cttyp pa016~aedtm pa016~uname
        into CORRESPONDING FIELDS OF TABLE i_pall
        from  ( PA0000 as pa00 left OUTER JOIN pa0001 as pa01 on pa00~pernr = pa01~pernr )
        left OUTER JOIN pa0002 as pa02 on pa00~pernr eq pa02~pernr )
        left OUTER JOIN  pa0016 as pa016 on pa00~pernr eq pa016~pernr )
        where pa00~pernr in S_pernr
        AND pa00~begda in s_bg0000
        and pa00~endda in s_nd0000.
    but this fails  to fetch the value of begda enda from each pa0000,pa0001,pa0002,pa0016.
    Please help!
    Monirul

    Why don't you use the standard logical database PNPCE and then Provide statement?

  • How to use multiple tables in DRIVING_SITE

    Hi All,
    I see very bad performance with my query having dblinks to remote database.
    How can I use DRIVING_SITE for multiple remote tables here?
    Does it it useful to use on DRIVING_SITE multiple tables?
    What is impact of using ORDER BY on local table column ( table A in below case) in the query?
    SELECT A.col1, B.col2 , C.col3
    FROM A, B@dblink1, C@dblink1, D@dblink2
    WHERE <few join conditions>
    ORDER BY A.col1 ;
    Join conditions in above query is taken care to have better performance. But from our analysis it is understood that poor performance is due to DB Links to remoate database. What is best approach to get good performance with DB Links?
    Regards,
    Ram

    http://download.oracle.com/docs/cd/E11882_01/server.112/e17120/ds_appdev004.htm#ADMIN12196
    Will give you an idea of where to start.

  • How to set aggregation rule (SUM) to a query which uses multiple tables

    Hi,
    I have a doubt like i have a query .i want to get the sum of few columns in that..how can i achieve it as it joins multiple tables . i am posting the query under this. please help me to resolve this. i need to get summation of column which is marked in bold . i am so sorry to post such a big query.. thanks in advance.
    SELECT DISTINCT
        SAS.ACCOUNT_MONTH_NO,
        SAS.BILL_TO_MAJOR_SALES_CHANNEL,
        SAS.BUS_AREA_ID,
        SAS.CUST_NAME,
        SAS.PART_NO,
        SAS.PART_DESC,
        SAS.PRODUCT_CLASS_CODE,
        SAS.SUPER_FAMILY_CODE,
        *SAS.NET_SALES_AMT_COA_CURR,* 
      *SAS.GROSS_SALES_AMT_COA_CURR*,
        *SAS.SHIPPED_QTY*,
        SAS.SRCE_SYS_ID,
        GWS.SRC_LOCATION,
        GWS.PART_CF_PART_NUMBER,
        GWS.ANALYST_COMMENTS,
        NVL(GWS.CLAIM_QUANTITY,0) AS *CLAIM_QUANTITY*,
        GWS.CUSTOMER_CLAIM_SUBMISSION_DATE,
        GWS.CLAIM_TYPE,
        GWS.CREDIT_MEMO_NO,
        NVL(GWS.CREDIT_MEMO_AMT,0) AS *CREDIT_MEMO_AMT*,
        GWS.TRANS_CREATED_BY,
        GWS.COMPONENT_CODE,
        GWS.DATE_OF_THE_FAILURE,
        GWS.DATE_PART_IN_SERVICE,
        GWS.PROBLEM_CODE,
        NVL(GWS.TOT_AMT_REVIEWED_BY_CA,0) AS *TOT_AMT_REVIEWED_BY_CA*,
        GWS.REGION
      FROM
    SELECT
            TO_CHAR(A.STATUS_DATE, 'YYYYMM') AS ACCOUNT_MONTH_NO,
            A.LOCATION_ID SRC_LOCATION,
            A.CF_PN PART_CF_PART_NUMBER,
            A.ANALYST_COMMENTS,
            A.CLAIM_QUANTITY, 
         A.CUST_CLAIM_SUBM_DATE CUSTOMER_CLAIM_SUBMISSION_DATE,
            A.CLAIM_TYPE,
            A.CREDIT_MEMO_NO,
            A.CREDIT_MEMO_AMT,
            A.CREATED_BY TRANS_CREATED_BY,
            A.FAULT_CODE COMPONENT_CODE,
            A.PART_FAILURE_DATE DATE_OF_THE_FAILURE,
            A.PART_IN_SERVICE_DATE DATE_PART_IN_SERVICE,
            A.FAULT_CODE PROBLEM_CODE,
            A.TOT_AMT_REVIEWED_BY_CA,
            A.PART_BUS_AREA_ID AS BUS_AREA_ID,
            A.PART_SRC_SYS_ID,
            C.CUST_NAME,
            C.BILL_TO_MAJOR_SALES_CHANNEL,
            P.PART_NO,
            P.PART_DESC,
            P.PRODUCT_CLASS_CODE,
            L.REGION
          FROM
            EDWOWN.MEDW_BIS_DTL_FACT A,
            EDWOWN.EDW_MV_DB_CUST_DIM C,
            EDWOWN.EDW_BUSINESS_LOCATION_DIM L,
            EDWOWN.EDW_V_ACTV_PART_DIM P
          WHERE
            A.PART_KEY                       = P.PART_KEY
          AND A.CUSTOMER_KEY                 = C.CUSTOMER_KEY
          AND A.LOCATION_KEY                 = L.LOCATION_KEY
          AND A.PART_SRC_SYS_ID              = 'SOMS'
          AND A.PART_BUS_AREA_ID             = 'USA'
          AND C.BILL_TO_MAJOR_SALES_CHANNEL <> 'IN'
        GWS,
          SELECT
            A.ACCOUNT_MONTH_NO,
            A.BUS_AREA_ID,
            A.NET_SALES_AMT_COA_CURR,
            A.GROSS_SALES_AMT_COA_CURR,
            A.SHIPPED_QTY,
            B.BILL_TO_MAJOR_SALES_CHANNEL,
            A.SRCE_SYS_ID,
            B.CUST_NAME,
            D.PART_NO,
            D.PART_DESC,
            D.PRODUCT_CLASS_CODE,
            D.SUPER_FAMILY_CODE
          FROM
            SASOWN.SAS_V_CORP_SHIP_FACT A,
            SASOWN.SAS_V_CORP_CUST_DIM B,
            SASOWN.SAS_V_CORP_LOCN_DIM C,
            SASOWN.SAS_V_CORP_PART_DIM D
          WHERE
                C.DIVISION_CODE = A.DIVISION_CODE
            AND
                B.B_HIERARCHY_KEY = A.B_HIERARCHY_KEY
            AND
                D.PART_NO = A.PART_NO
            AND
                A.SRCE_SYS_ID = 'SOMS'
            AND
                A.BUS_AREA_ID = 'USA'
            AND
                B.BILL_TO_MAJOR_SALES_CHANNEL <> 'IN'
        SAS
      WHERE
        SAS.ACCOUNT_MONTH_NO              = GWS.ACCOUNT_MONTH_NO(+)
      AND SAS.BILL_TO_MAJOR_SALES_CHANNEL = GWS.BILL_TO_MAJOR_SALES_CHANNEL(+)
      AND SAS.BUS_AREA_ID                 = GWS.BUS_AREA_ID(+)
      AND SAS.PRODUCT_CLASS_CODE          = GWS.PRODUCT_CLASS_CODE(+);thanks in advance
    aswin

    You get rid of the distinct.
    You put sum() around your starred items.
    You put all the remaining columns in a GROUP BY clause.
    You hope that that none of the other tables has more than one row that matches the SAS table, which would cause you to count that row more than once.

  • How to use multiple tables in developing one Graph in Endeca Integrator

    We have the requirement where we want to show the matrix for a particular entity which is coming from two separate table, there is a join which is possible on both the tables to get the correct data. But we are not able to find how to use data from two tables. We can create the SQL query with all the joining conditions but there are many tables which are involved so performance of query will be a problem. Is there any way in Endeca where I can create two data sources using two separate queries and while showing the matrix , I can join both the tables to get the matrix .

    You have not mentioned the version of Endeca that is used for your application. Joins are recently introduced in version 2.3 and could be used for avoiding complex DEFINE analytical statements. For this to work, the data should be present in the same dgraph and a single data source in Studio should point to data from both sources.
    These may not yet be the type of SQL joins that you may expect them to be as performing complex joins is also costly in Endeca. Hope you are not expecting to join huge data sets.
    The best possible solution I could think for addressing this problem is to load denormalized data (at least for now) into Endeca and do aggregations in queries. We can denormalize data in multiple ways even using ETL tools not just SQL queries as the above comment states.

  • Issue with using Multiple Tables in Join

    Post Author: dwessell
    CA Forum: .NET
    Hi, I'm using the Basic version of Crystal Reports that shipped with Visual Studio 2k5.I'm doing a report with three tables, CQ_HEADER, SO_HEADER and SALESPERSON. Both the CQ_HEADER and the SO_HEADER tables link to the SALESPERSON table via a SPN_AUTO_KEY field. However, I always receive duplicates in my result set, due to the joins made. Here's the query that's produced by CR.  SELECT "CQ_HEADER"."CQ_NUMBER", "CQ_HEADER"."ENTRY_DATE", "CQ_HEADER"."TOTAL_PRICE", "SALESPERSON"."SALESPERSON_NAME", "SO_HEADER"."ENTRY_DATE", "SO_HEADER"."TOTAL_PRICE" FROM   "CQ_HEADER" "CQ_HEADER" INNER JOIN ("SO_HEADER" "SO_HEADER" INNER JOIN "SALESPERSON" "SALESPERSON" ON "SO_HEADER"."SPN_AUTO_KEY"="SALESPERSON"."SPN_AUTO_KEY") ON "CQ_HEADER"."SPN_AUTO_KEY"="SALESPERSON"."SPN_AUTO_KEY" WHERE  ("CQ_HEADER"."ENTRY_DATE">={ts '2007-12-01 00:00:00'} AND "CQ_HEADER"."ENTRY_DATE"<{ts '2007-12-18 00:00:00'}) AND ("SO_HEADER"."ENTRY_DATE">={ts '2007-12-01 00:00:00'} AND "SO_HEADER"."ENTRY_DATE"<{ts '2007-12-18 00:00:00'}) ORDER BY "SALESPERSON"."SALESPERSON_NAME" There is no link between the SO_HEADER and the CQ_HEADER. Can anyone make a suggestion as to how I could go about structuring this such that it doesn't return duplicate values? ThanksDavid        

    Post Author: dwessell
    CA Forum: .NET
    Addendum: I've partially been able to solve it.. The information that I'm after is: Salesperson     # of Quotes   # of Sales    #Total Sales (Sum(Total_Price))  #Total Quoted Salesperson is what I group after, and I was able to get correct numbers for # of Quotes and # of sales by changing COUNT to DISTINCT COUNT. However, for the summations I'm still getting duplicate rows. ThanksDavid    

  • Random select using multiple tables

    Hello World!!!
    I'm trying to fix a form I modified last month and it's causing me fits!
    I need to add another validation element (email address) to my password validation Form. The problem lies in the fact that I can't simply add an additional SELECT Statement to the query because it won't randomly select the same number that the first one did (records won't match). When I try to JOIN on the tables inside the inner SELECT, basically the same thing happens. I get an a result for the "e-mail" column but it doesn't match the same record as the first two.
    Is there an easier way of doing this??? Here's the code I'm using that works for my first two column returns (from the agent_sec_questions Table). I'm trying to add one more column (email) from the agent_data Table.
    Thanks in advance for any suggestions.
    SELECT security_question, question_number
    FROM (SELECT security_question, question_number
    FROM agent_sec_questions
    WHERE agent_id =
    (SELECT agent_id
    FROM agent_data
    WHERE username = 'john doe')
    ORDER BY DBMS_RANDOM.VALUE (1, 9))
    WHERE ROWNUM = 1;

    Here's the solution I came up with if interested. I got the random number first, then joined my tables. If you have a better one, please let me know...
    Chow!
    M
    SELECT DBMS_RANDOM.VALUE(1,3) INTO Sel_Num FROM DUAL;
    MESSAGE ('Sel_Num= '||Sel_Num||' ID= '||UPPER(:LOGON_BLOCK.USERID));
    pause;
                   SELECT b.email, a.security_question, a.question_number
                   INTO L_email, L_sec_q, L_q_num
              FROM lookup.agent_sec_questions a, lookup.agent_data b
              WHERE b.agent_id = a.agent_id
              AND b.username = TRIM(UPPER(:LOGON_BLOCK.USERID))
              AND a.question_number = sel_Num
                   AND ROWNUM = 1;

  • Reports using multiple tables (Reposting)

    After no response for two weeks I am reposting this. Can anyone please help me on this one?
    I am trying to create a report using portal that use links between multiple columns. The info I want is mainly in two tables. Some of the info in the table is numeric (Foreign Keys). I want to display them in readable format so set up joins to the respective parent tables. When I do this the result only produces 12 lines of output irrespective of the number of lines I set per page. When I show only the data from the main tables, without the joins to the other parent tables, i.e. the foreign keys as numbers I get all the rows. I have tried to create the report by using all three options given but get the same result.
    I am using 9iAS verison 1.0.2.0 and Portal version 3.0.7.
    Can someone please explain why this happens and how I can solve this problem urgently.

    Hello,
    It looks like someone answered your question in thread UIX tutorial
    I would also recommend reading the Databinding chapter and the Business Components for Java Integration chapter under UIX Developer's Guide and Reference.
    Also, you can download demos from this page:
    http://otn.oracle.com/products/ids/uix/content.html

  • How can we create an entity object using multiple tables?

    Hi All,
    I'm a newbie to OAF.
    I'm trying to create a simple page using OAF.
    While creating Entity object, there is an option to add the database objects from which we can create our Entity Object.
    There we can enter only one database object.
    If suppose I need to create a Entity object by using mutiple data base objects, how can I add other database objects?
    Is there any option for multiple selection of database objects there?
    Thanks in Advance

    User,
    a). You should use the [url http://forums.oracle.com/forums/forum.jspa?forumID=210]OA Framework Forum for this question.
    b). Entity objects always correspond to a single table. I think you want to create a View object instead.
    c). Really, you want to be using the OA Framework forum.
    John

Maybe you are looking for