Query.....mapping

have 2 tables…
1) Table X with 5 columns.
2) Table Y with 2 columns
Table Y: Column 1 à Position of the columns in Table X
Table Y: Column 2 à It has the data as column names of table X
Is there any way to map the column names in Table Y with the columns in Table X ??????

Your question is not very clear, but I think you should look up dynamic sql...

Similar Messages

  • Table for Webtemplate and Query mapping

    Hi Experts,
    Is there any table which has the mapping for BW Web template and the Query on which this Web Template is built.
    Any help would be highly appreciated.
    Regards,
    Rk.

    >
    Matthias Nutt wrote:
    > Hi,
    >
    > the WebTemplate is stored as XML document. This is the XML code which is shown in the Web Application Designer. You need to read throught the XML using the Web Application Designer or using report RS_TEMPLATE_MAINTAIN_70.
    >
    > Regards Matthias Nutt
    > SAP Consulting Switzerland
    Hi,
    Thanks for the reply.
    What is the output for this report?
    I just need the query name which is used for creating the Web Template.
    Any table, FM or ABAP program for getting the query name for a Web Template will be sufficient for my requirement.
    Regards,
    Rk.

  • SQL Query - Mapping Groups to Batches

    I am using Oracle 11g Release 2.
    I have the following dataset:
    CREATE TABLE RoomGroups
    (group_id NUMBER,
    group_name VARCHAR2(30),
    group_capacity NUMBER);
    INSERT INTO RoomGroups VALUES(1, 'SEECS UG Block', 100);
    INSERT INTO RoomGroups VALUES(2, 'IAEC Building', 70);
    INSERT INTO RoomGroups VALUES(3, 'RIMMS Building', 90);
    Commit;
    CREATE TABLE DegreeBatches
    (batch_id NUMBER, batch_name VARCHAR2(30), batch_strength NUMBER);
    INSERT INTO DegreeBatches VALUES(10,'BIT-10',35);
    INSERT INTO DegreeBatches VALUES(20,'BIT-11',40);
    INSERT INTO DegreeBatches VALUES(30,'BSCS-2',35);
    INSERT INTO DegreeBatches VALUES(40,'BSCS-3',40);
    INSERT INTO DegreeBatches VALUES(50,'BEE-4',50);
    INSERT INTO DegreeBatches VALUES(60,'BICSE-7',25);
    INSERT INTO DegreeBatches VALUES(70,'BESE-3',30);
    Commit;
    I want to achieve the following thr single or multiple SQL queries:
    Firstly, get all possible sets of DegreeBatches for each group - in such a way that for each set the SUM(batch_strength) <= Capacity of that group as show below.
    GroupId     Batches     StrengthStr     StrengthTotal     Capacity
    1.     {BIT-10, BIT-11, BICSE-7}     {35, 40, 25}     100     100
    1.     {BSCS-2, BSCS-3, BICSE-7}     {35, 40, 25}     100     100
    1.     {BEE-4, BSCS-3}     {50, 40}     90     100
    2.     {BIT-10, BSCS-2}     {35, 35}     70     70
    2.     {BSCS-3, BESE-3}     {40, 30}     70     70
    2.     {BIT-11, BICSE-7}     {40, 25}     65     70
    and so on...
    Secondly, I want to retrieve only non-overlapping sets based on minimum value of Capacity-StrengthTotal for each group
    GroupId     Batches     StrengthStr     StrengthTotal     Capacity
    1.     {BIT-10, BIT-11, BICSE-7}     {35, 40, 25}     100     100
    2.     {BSCS-3, BESE-3}     {40, 30}     70     70
    3.     {BSCS-2, BEE-4}     {35, 50}     85     90
    And finally, the final result must have all the batches in it...
    Which in this case is true...
    Any help will be highly appreciated...
    Thanks
    Bilal

    Is this not a duplicate thread?
    Re: SQL Query for mapping a set of batches to a class rooms group

  • Query Mapping in R12

    Hi All,
    I have below query in my form. This was Oracle 11.0.3 version query. But Now I want to use this qury in Oracle R12.
    Can anybody help me to map this query in R12
    SELECT order_number_source_id
    FROM apps.so_order_types_all
    WHERE order_type_id = :Profile.returns_order_type_id;
    Thanks in advance

    This forum is for general Oracle Forms questions. Please post your question in the General EBS Discussion forum. If you have a general Forms question, by all means, ask it here! ;-)
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • Query map the DB Link Table

    Hi Team
    I have query like
    select site_id from site;
    O/P :-
    12323
    12444
    12333
    but i want to stored this date on variable like
    v_site (12323,12444,12333)
    because i about using dblink for other be i need to put this values like
    select * from table@dblink
    where site_id in ( v_site);
    Thanks for Advance...

    Hi,
    why dont you put like
    ----Not tested-----
    site_id in (select site_id from site)Regards,
    CKLP
    Pls mark posts and answered/helpful it you consider it really was.
    Edited by: CKLP on Sep 26, 2011 5:12 AM

  • Dynamic Query Mapping using Toplink Entity

    Hi,
    We have a requirement that the column names of the table dynamically gets changed for different customers.
    eg;
    Client 1 , will have
    Select EMP_ID, EMP_NAME from EMPLOYEE
    Client 2 will have
    SELECT CEMP_ID, EMP_NAME, CEMP_ADDR from EMPLOYEE
    Is it possible to make a Toplink Entity Employee object to support both the queries at runtime ?ie; we should not modify the java entity object for each customer.
    With normal JDBC , we can perform SELECT * from EMPLOYEE ,get the resultset , and using metadata , we can find the column names and process it accordingly.
    Is this functionality possible with toplink JPA at all ?
    Thanks
    prabu

    Hi,
    I am trying to use DynamicEntity class. Is Joined Table Inheritance supported in DynamicEntity ? Since I need to create an HybridEntity on the fly by selecting all the fields from TABLE A and TABLE B by joining key fields, whose fields will dynamically change based upon the customer. Below is what I am currently trying to do. But the Entity Object that I got contains fields only from TABLE A and not from TABLE B
    EntityManagerFactory emf = new EntityManagerFactoryImpl(setup,EclipseLinkJPATest.getEMFProperties());
    SchemaManager manager = new SchemaManager(JpaHelper.getServerSession(emf));
    Vector <DatabaseRecord>tableAEntityFieldNames = manager.getAllColumnNames("TABLE A");
    Vector <DatabaseRecord>tableBFieldNames = manager.getAllColumnNames("TABLE B");
    EntityType tableAType = EntityTypeFactory.create("TableAEntity","DynamicEntity$TableAEntity", "TABLE A", loader);
    String columnName = null;
    for(DatabaseRecord tableAObj: tableAEntityFieldNames){
    columnName = tableAObj.get("COLUMN_NAME").toString();
    EntityTypeFactory.addBasicProperty(tableAType, columnName, columnName,
    "TABLE A_ID".equals(columnName) ? Long.class : String.class, "TABLE A_ID".equals(columnName) ? true : false);
    EntityTypeFactory.addToPersistenceUnit(emf, tableAType);
    EntityType stepType = EntityTypeFactory.create("TableBEntity","DynamicEntity$TableBEntity", "TABLE B", loader);
    for(DatabaseRecord tableBObj: tableBEntityFieldNames) { 
    columnName = tableBObj.get("COLUMN_NAME").toString();
    EntityTypeFactory.addBasicProperty(tableBType, columnName, columnName,"TABLE B_ID".equals(columnName) ? Long.class : String.class, "TABLE B_ID".equals(columnName) ? true : false);
    EntityTypeFactory.addToPersistenceUnit(emf, tableBType);
    EntityManager em = emf.createEntityManager();
    List <DynamicEntity> entityList = null;
    entityList = em.createQuery("select s from TableAEntity s, TableBEntity st where s.TABLE A_ID= st.TABLE B_IDand s.TABLE A_ID=?1")
              .setParameter(1, 1397)
              .getResultList();
    System.out.println("entityList..."+entityList);
    Thanks
    Prabu

  • Unable to find Searchable Item in Query Criteria Map

    Hi ,
    Am try to personalize Advacned Search Region to Include new search Criteria in R12 iSupplier Portal->Home->Orders Tab->Advanced search.
    Am trying to create new search field in the Add another row field through personalization.
    I have created new row criteria,when am trying to create Query Criteria Map,Am unable to list the Searchable Item as it is Drop down list.
    This causing unable to query the records based on the newly created row criteria item.
    Please advise.
    Thansk<Sarath.

    Hi Jobnish,
    There is no code in this requirement.
    There is no error...Issue is unable to query data based on newly create criteria row in Advanced search.
    I can give you navigation:
    iSupplier Portal->Home->Orders Tab->Press advanced search Region
    Click on the Personalize Page(I hope you know how to enable the personalize link using profile option).
    In SupplierRN ->Advanced Search Criteria and creating custom item Criteria Row..
    We need to map this field in Advanced Query Mapping.
    However the issue is the Am unbale find the Searchable item (which is created in Criteria Row) in the drop downlist.
    I can provide screen-shot if you need.
    Thanks,Sarath.

  • Mapping an object's property to a field computed from 2 database fields

    Hi,
    Is there a way to do a WorkBench mapping of a business object's property to a field computed from 2 separate database fields?
    If not in WB, how would you do that?
    Thanks,
    Michal

    You could define this mapping through a TransformationMapping using you own code in the mappings transformer to divide the values. However you are probably much better off to just map the two values directly, and add a method in your object model to get the rate buy dividing the values.
    If terms of being able to order-by the calculated value in the a TopLink query, mapping the calculated value using a transformation mapping would not help this.
    To do this order by you can use,
    query.addOrdering(ExpressionMath.multiply(ExpressionMath.divide(builder.get("numberOfSuccess"), builder.get("numberOfAttempts")), 100);

  • Common query method

    Hi,
    I need to query an oracle database using bind variables. To do so, I have a method to execute any query, that would receive the query in a "SELECT fieldFROM table WHERE id = :param1" fashion, and a list of the params for the binded variables in the where clause. This params them need to be set by its type's corresponding method, for example, ints would use the preparedStatement.setInt(index, integer) method.
    I might try to receive as the parameters list an object of type List<Object> and then map the each item in the list with instance of, for every method declared in the PreparedStatement interface, like
    if (parametro instanceof Short) {
         statement.setShort(index, (Short) parametro);
    }but surely there is a better way...
    Since this would be used by any query, would you suggest to design it as a class where all related methods to execute the query, map the fields to set methods, and, transform result sets into domain objects live?
    Thanks in advance.

    I have fixed a template method structure where the abstract class is holding the executeQuery method, that will first call a method to prepare de query, then set the paramethers for the query and finally delegate de execute query on the preparedStatement. Both the prepareQuery and the setParameters methods are left for the extending classes to implement, so they will know what method on PreparedStatement to use to add the named variables with its right type.

  • Suggestions required to change the query to improve its performance.

    By using the following query I Created a View. If i query the view for the required data it is taking around 1 minute to fetch the data.
    The output of the query gives all the time slots for which each seat is available on each day starting with the effective start date in the xxcgs_adm_seat_mst table
    It ends with last CAL_DAY of the xxcgs_admin_calendar table.
    The XXCGS_SEAT_MST table contains all the seats data and XXCGS_ADM_ALLOCATION table contains all the allocated seat data.
    Tables used in this view
    1)
    CREATE TABLE XXCGS_ADM_ALLOCATION
    SEAT_ID NUMBER,
    ALLOCFROM_DATE DATE ,
    ALLOCTO_DATE DATE ,
    TIME_FROM VARCHAR2(11),
    TIME_TO VARCHAR2(11));
    The table is having the following sample data:
    Insert into xxcgs_adm_allocation Values(1121, '12-DEC-2007', '27-12-2007', '00:00', '04:59');
    Insert into xxcgs_adm_allocation Values(1140, '12-DEC-2007', '27-12-2007', '00:00', '04:59');
    Insert into xxcgs_adm_allocation Values(1122, '12-DEC-2007', '27-12-2007', '04:30', '10:59');
    Insert into xxcgs_adm_allocation Values(1054, '12-DEC-2007', '27-12-2007', '00:00', '04:59');
    Insert into xxcgs_adm_allocation Values(1141, '12-DEC-2007', '27-12-2007', '00:00', '04:59');
    Insert into xxcgs_adm_allocation values(1142, '12-DEC-2007', '27-12-2007', '00:00', '04:59');
    Insert into xxcgs_adm_allocation Values(1120, '12-DEC-2007', '27-12-2007', '00:00', '04:59');
    COMMIT;
    2) CREATE TABLE XXCGS_ADM_SEAT_MST
    SEAT_ID NUMBER,
    EFFECTIVE_START DATE,
    EFFECTIVE_END DATE);
    Sample data:
    Insert into xxcgs_adm_seat_mst Values (1053, '15-OCT-2007',NULL);
    Insert into xxcgs_adm_seat_mst Values (1049, '15-OCT-2007',NULL);
    Insert into xxcgs_adm_seat_mst Values (1054, '16-OCT-2007',NULL);
    Insert into xxcgs_adm_seat_mst Values (1121, '12-DEC-2007',NULL);
    Insert into xxcgs_adm_seat_mst Values (1120, '12-JAN-2007', NULL);
    Insert into xxcgs_adm_seat_mst Values (1080, '11-DEC-2007',NULL);
    Insert into xxcgs_adm_seat_mst Values (1100, '11-DEC-2007',NULL);
    Insert into xxcgs_adm_seat_mst Values (1122, '01-DEC-2007',NULL);
    Insert into xxcgs_adm_seat_mst Values (1140, '01-DEC-2007',NULL);
    Insert into xxcgs_adm_seat_mst Values (1141, '01-DEC-2007',NULL);
    Insert into xxcgs_adm_seat_mst Values (1142, '01-DEC-2007',NULL);
    COMMIT;
    3)
    CREATE TABLE XXCGS_ADMIN_CALENDAR
    CAL_DAY DATE,
    SL_NO NUMBER
    This table contains 3 years data.
    In this table I inserted data with this code:
    declare
    v_cal_day DATE ;
    V_SL_NO NUMBER;
    BEGIN
    V_CAL_DAY := '01-JAN-2007';
    V_SL_NO := 1;
    LOOP
    INSERT INTO XXCGS_ADMIN_CALENDAR VALUES (V_CAL_DAY,V_SL_NO);
    V_CAL_DAY := V_CAL_DAY+1;
    V_SL_NO := V_SL_NO+1;
    EXIT WHEN V_CAL_DAY > '31-DEC-2009';
    END LOOP;
    END;
    4)
    CREATE TABLE TIME_SLOTS
    S_NO NUMBER(2),
    HOURS VARCHAR2(6 BYTE),
    FROM_TIME VARCHAR2(6 BYTE),
    TO_TIME VARCHAR2(6 BYTE)
    Data in this Table:
    insert into time_slots values(1, '00:30', '00:00', '00:29');
    insert into time_slots values(2, '01:00', '00:30', '00:59');
    insert into time_slots values(3, '01:30', '01:00', '01:29');
    insert into time_slots values(4, '02:00', '01:30', '01:59');
    insert into time_slots values(5, '02:30', '02:00', '02:29');
    insert into time_slots values(6, '03:00', '02:30', '02:59');
    insert into time_slots values(7, '03:30', '03:00', '03:29');
    insert into time_slots values(8, '04:00', '03:30', '03:59');
    insert into time_slots values(9, '04:30', '04:00', '04:29');
    insert into time_slots values(10, '05:00', '04:30', '04:59');
    insert into time_slots values(11, '05:30', '05:00', '05:29');
    insert into time_slots values(12, '06:00', '05:30', '05:59');
    insert into time_slots values(13, '06:30', '06:00', '06:29');
    insert into time_slots values(14, '07:00', '06:30', '06:59');
    insert into time_slots values(15, '07:30', '07:00', '07:29');
    insert into time_slots values(16, '08:00', '07:30', '07:59');
    insert into time_slots values(17, '08:30', '08:00', '08:29');
    insert into time_slots values(18, '09:00', '08:30', '08:59');
    insert into time_slots values(19, '09:30', '09:00', '09:29');
    insert into time_slots values(20, '10:00', '09:30', '09:59');
    insert into time_slots values(21, '10:30', '10:00', '10:29');
    insert into time_slots values(22, '11:00', '10:30', '10:59');
    insert into time_slots values(23, '11:30', '11:00', '11:29');
    insert into time_slots values(24, '12:00', '11:30', '11:59');
    insert into time_slots values(25, '12:30', '12:00', '12:29');
    insert into time_slots values(26, '13:00', '12:30', '12:59');
    insert into time_slots values(27, '13:30', '13:00', '13:29');
    insert into time_slots values(28, '14:00', '13:30', '13:59');
    insert into time_slots values(29, '14:30', '14:00', '14:29');
    insert into time_slots values(30, '15:00', '14:30', '14:59');
    insert into time_slots values(31, '15:30', '15:00', '15:29');
    insert into time_slots values(32, '16:00', '15:30', '15:59');
    insert into time_slots values(33, '16:30', '16:00', '16:29');
    insert into time_slots values(34, '17:00', '16:30', '16:59');
    insert into time_slots values(35, '17:30', '17:00', '17:29');
    insert into time_slots values(36, '18:00', '17:30', '17:59');
    insert into time_slots values(37, '18:30', '18:00', '18:29');
    insert into time_slots values(38, '19:00', '18:30', '18:59');
    insert into time_slots values(39, '19:30', '19:00', '19:29');
    insert into time_slots values(40, '20:00', '19:30', '19:59');
    insert into time_slots values(41, '20:30', '20:00', '20:29');
    insert into time_slots values(42, '21:00', '20:30', '20:59');
    insert into time_slots values(43, '21:30', '21:00', '21:29');
    insert into time_slots values(44, '22:00', '21:30', '21:59');
    insert into time_slots values(45, '22:30', '22:00', '22:29');
    insert into time_slots values(46, '23:00', '22:30', '22:59');
    insert into time_slots values(47, '23:30', '23:00', '23:29');
    insert into time_slots values(48, '24:00', '23:30', '23:59');
    commit;
    The query
    Part 1:
    This Query maps the seat_id in the master table with each time slot and with effective start date between sysdate-60 and sysdate+365 assuming that a seat can be allocated not more than a year. so if there are 10 seats in this table then this table contains 10*48*425 records
    SELECT mst.seat_id
    , cal.sl_no
    , cal.cal_day
    , tm.s_no
    , tm.from_time
    , tm.to_time
    FROM xxcgs_adm_seat_mst mst
    , xxcgs_admin_calendar cal
    , time_slots tm
    WHERE cal.cal_day >= NVL (mst.effective_start,SYSDATE - 60)
    AND cal.cal_day <= NVL (mst.effective_end, SYSDATE + 365)
    Part 2:
    This query is based on the allocation table and it checks the allocated seats with all the time slots and between the allocated date range and marks the timeslot as 0 if it is not allocated and 1 if it is allocated
    SELECT seat_id
    , sl_no
    , cal_day
    , s_no
    , from_time
    , to_time
    FROM
    (SELECT alloc.seat_id
         , cal.sl_no
         , cal.cal_day
    , tm.s_no
    , tm.from_time
         , tm.to_time
    ,SUM(DECODE(LEAST(alloc.time_from,tm.from_time),alloc.time_from,
              DECODE(GREATESTalloc.time_to,tm.to_time),alloc.time_to, 1,0),0))AVAILABILITY
    FROM
    xxcgs_adm_allocation alloc
    ,xxcgs_admin_calendar cal
         ,time_slots tm     
    WHERE
    cal.cal_day >= alloc.allocfrom_date
    AND cal.cal_day <= alloc.allocto_date
    GROUP BY alloc.seat_id
    ,cal.sl_no
              ,cal.cal_day
              ,tm.s_no
              ,tm.from_time
              ,tm.to_time
    ORDER BY cal.sl_no, tm.s_no) a     
    WHERE a.AVAILABILITY = 1
    Part 3:
    Here i am substracting the 2nd query output from the 1st to get all the available time slots for all seats
    SELECT mst.seat_id
    ,cal.sl_no
         ,cal.cal_day
         ,tm.s_no
         ,tm.from_time
         ,tm.to_time
         FROM xxcgs_adm_seat_mst mst
         ,xxcgs_admin_calendar cal
         ,time_slots tm
    WHERE cal.cal_day >= NVL (mst.effective_start,SYSDATE - 60)
    AND cal.cal_day <= NVL (mst.effective_end, SYSDATE + 365)
    MINUS
    SELECT seat_id
    , sl_no
         , cal_day
         , s_no
         , from_time
         , to_time
    FROM
    (SELECT alloc.seat_id
         ,cal.sl_no
                   ,cal.cal_day, tm.s_no
                   ,tm.from_time
                   ,tm.to_time
                   ,SUM(DECODE(LEAST(alloc.time_from,tm.from_time),alloc.time_from,
                   DECODE(GREATEST(alloc.time_to,tm.to_time),alloc.time_to, 1,0),0))AVAILABILITY
    FROM
    xxcgs_adm_allocation alloc
    ,xxcgs_admin_calendar cal
         ,time_slots tm     
    WHERE
    cal.cal_day >= alloc.allocfrom_date
    AND cal.cal_day <= alloc.allocto_date
    GROUP BY alloc.seat_id
    ,cal.sl_no
              ,cal.cal_day
              ,tm.s_no
              ,tm.from_time
              ,tm.to_time
    ORDER BY cal.sl_no, tm.s_no) a     
    WHERE a.AVAILABILITY = 1

    Any chance to get your Oracle version, release and patchset ? Any chance to get your OS and plateform ? Any chance to use tags &#091;pre&#093; and &#091;/pre&#093; around your code to keep tabs as well on the forum side ?
    Any chance to get explain plan as well explained When your query takes too long ... ?
    Nicolas.

  • Query doesn't exist on server

    Hello,
    I have issue with workbook.
    I have workbook with 5 queries.
    I've replaced all 5 queries to another queries and delete old queries from server after saving workbook with new queries.
    Now I'm opening workbook, entering login and password and face error:
    Requested Query  ZFI_M11/ZZFI_M09_Q009 doesn't exist on server.
    If I choose Ok nothing happend, workbook wouldn't open.
    It's strange, because I couldn't delete query from server, before I've delete it from workbook and technical name of query is strange, it has / symbol.
    I tried to create query with ZZFI_M09_Q009 name, but it doesn't help me.
    How I can open workbook to fix it?
    Regards,
    Romano

    Hi
    If the specified query is not intended to use in that work book,  remove / delete the workbook - Query Mapping, then work book would work appropriately.
    and If you are using BI7 work book, in design mode of workbook identify which are the BEx  objects are accessing the query and correct them to right infoprovider.
    In BI7 Workbook - settings you can view the List of Data Providers used in that work book. so you can validate and correct the data provides mapping to respective elements in workbook
    If you are using the BW 3.5, check the queries used in Metadata repository and remove the mapping for deleted query from the work book.
    Best Wishes,
    BVC

  • How to execute query after login?

    Hi Gurus,
    I'm developing nowadays a small system,that shows every employee his data( attendance time,vacations,execuses..etc),I just want to execute query (pop up data) once the employee logged in,as I get his login name and sysdate and execute the query.
    how could this happen? do I need a process ? what is it?
    How to get the system date?
    thanks in advance
    Pardon me,am just new here and still my terms for Developer 2000.

    You can do it with a process (call it onload) or with a simple sql query mapped to a region in the home page of your application.
    hope this helps

  • Active Catalog Mapping Views

    As I understand it, I created my Cubes using Analytical Workspace Manager, so we can consider its metadata as Standard Form and call it Active Catalog.
    In contrast, if I created my cubes using OEM(as SYSDBA), or OWB, my metadata would've been confusingly called OLAP Catalog Metadata that consists of ordinary relational tables.
    Fortunate for OLAP Catalog Metadata users, they can query Mapping information using OLAP Catalog Mapping Views.
    I was wondering if I can also query Mapping information for Active Catalog...
    Does anyone know how or which "Active Catalog View" to query (to know which dimension/cube is mapped to a certain table)?

    Hi Swetha,
    In my opinion this may be due to a timeout in mapping process. Which CCM SP level are you running?.
    Have you had a look to the SAP Note 926007?.
    I hope this help.
    Best Regards

  • Suggestions Required to change the query

    The output of the query gives all the time slots for which each seat is available on each day starting with the effective start date in the xxcgs_adm_seat_mst table
    It ends with last CAL_DAY of the xxcgs_admin_calendar table.
    The XXCGS_SEAT_MST table contains all the seats data and XXCGS_ADM_ALLOCATION table contains all the allocated seat data.
    Tables used in this view
    1)
    CREATE TABLE XXCGS_ADM_ALLOCATION
    SEAT_ID NUMBER,
    ALLOCFROM_DATE DATE ,
    ALLOCTO_DATE DATE ,
    TIME_FROM VARCHAR2(11 BYTE),
    TIME_TO VARCHAR2(11 BYTE),
    Foreign Key(seat_id) references XXCGS_ADM_SEAT_MST(SEAT_ID));
    The table is having the following sample data:
    Insert into xxcgs_adm_allocation Values(1121,'12-DEC-2007','27-DEC-2007','00:00', '04:59');
    Insert into xxcgs_adm_allocation Values(1140,'12-DEC-2007','27-DEC-2007','00:00', '04:59');
    Insert into xxcgs_adm_allocation Values(1122,'12-DEC-2007','27-DEC-2007','04:30', '10:59');
    Insert into xxcgs_adm_allocation Values(1054,'12-DEC-2007','27-DEC-2007','00:00', '04:59');
    Insert into xxcgs_adm_allocation Values(1141,'12-DEC-2007','27-DEC-2007','00:00', '04:59');
    Insert into xxcgs_adm_allocation values(1142,'12-DEC-2007','27-DEC-2007','00:00', '04:59');
    Insert into xxcgs_adm_allocation Values(1120,'12-DEC-2007','27-DEC-2007','00:00', '04:59');
    COMMIT;
    2) CREATE TABLE XXCGS_ADM_SEAT_MST
    SEAT_ID NUMBER PRIMARY KEY,
    EFFECTIVE_START DATE,
    EFFECTIVE_END DATE);
    Sample data:
    Insert into xxcgs_adm_seat_mst Values (1053, '15-OCT-2007',NULL);
    Insert into xxcgs_adm_seat_mst Values (1049, '15-OCT-2007',NULL);
    Insert into xxcgs_adm_seat_mst Values (1054, '16-OCT-2007',NULL);
    Insert into xxcgs_adm_seat_mst Values (1121, '12-DEC-2007',NULL);
    Insert into xxcgs_adm_seat_mst Values (1120, '12-JAN-2007', NULL);
    Insert into xxcgs_adm_seat_mst Values (1080, '11-DEC-2007',NULL);
    Insert into xxcgs_adm_seat_mst Values (1100, '11-DEC-2007',NULL);
    Insert into xxcgs_adm_seat_mst Values (1122, '01-DEC-2007',NULL);
    Insert into xxcgs_adm_seat_mst Values (1140, '01-DEC-2007',NULL);
    Insert into xxcgs_adm_seat_mst Values (1141, '01-DEC-2007',NULL);
    Insert into xxcgs_adm_seat_mst Values (1142, '01-DEC-2007',NULL);
    COMMIT;
    3)
    CREATE TABLE XXCGS_ADMIN_CALENDAR
    CAL_DAY DATE,
    SL_NO NUMBER
    This table contains 3 years data.
    In this table I inserted data with this code:
    declare
    v_cal_day DATE ;
    V_SL_NO NUMBER;
    BEGIN
    V_CAL_DAY := '01-JAN-2007';
    V_SL_NO := 1;
    LOOP
    INSERT INTO XXCGS_ADMIN_CALENDAR VALUES (V_CAL_DAY,V_SL_NO);
    V_CAL_DAY := V_CAL_DAY+1;
    V_SL_NO := V_SL_NO+1;
    EXIT WHEN V_CAL_DAY > '31-DEC-2009';
    END LOOP;
    END;
    4)
    CREATE TABLE TIME_SLOTS
    S_NO NUMBER(2),
    HOURS VARCHAR2(6 BYTE),
    FROM_TIME VARCHAR2(6 BYTE),
    TO_TIME VARCHAR2(6 BYTE)
    Data in this Table:
    insert into time_slots values(1, '00:30', '00:00', '00:29');
    insert into time_slots values(2, '01:00', '00:30', '00:59');
    insert into time_slots values(3, '01:30', '01:00', '01:29');
    insert into time_slots values(4, '02:00', '01:30', '01:59');
    insert into time_slots values(5, '02:30', '02:00', '02:29');
    insert into time_slots values(6, '03:00', '02:30', '02:59');
    insert into time_slots values(7, '03:30', '03:00', '03:29');
    insert into time_slots values(8, '04:00', '03:30', '03:59');
    insert into time_slots values(9, '04:30', '04:00', '04:29');
    insert into time_slots values(10, '05:00', '04:30', '04:59');
    insert into time_slots values(11, '05:30', '05:00', '05:29');
    insert into time_slots values(12, '06:00', '05:30', '05:59');
    insert into time_slots values(13, '06:30', '06:00', '06:29');
    insert into time_slots values(14, '07:00', '06:30', '06:59');
    insert into time_slots values(15, '07:30', '07:00', '07:29');
    insert into time_slots values(16, '08:00', '07:30', '07:59');
    insert into time_slots values(17, '08:30', '08:00', '08:29');
    insert into time_slots values(18, '09:00', '08:30', '08:59');
    insert into time_slots values(19, '09:30', '09:00', '09:29');
    insert into time_slots values(20, '10:00', '09:30', '09:59');
    insert into time_slots values(21, '10:30', '10:00', '10:29');
    insert into time_slots values(22, '11:00', '10:30', '10:59');
    insert into time_slots values(23, '11:30', '11:00', '11:29');
    insert into time_slots values(24, '12:00', '11:30', '11:59');
    insert into time_slots values(25, '12:30', '12:00', '12:29');
    insert into time_slots values(26, '13:00', '12:30', '12:59');
    insert into time_slots values(27, '13:30', '13:00', '13:29');
    insert into time_slots values(28, '14:00', '13:30', '13:59');
    insert into time_slots values(29, '14:30', '14:00', '14:29');
    insert into time_slots values(30, '15:00', '14:30', '14:59');
    insert into time_slots values(31, '15:30', '15:00', '15:29');
    insert into time_slots values(32, '16:00', '15:30', '15:59');
    insert into time_slots values(33, '16:30', '16:00', '16:29');
    insert into time_slots values(34, '17:00', '16:30', '16:59');
    insert into time_slots values(35, '17:30', '17:00', '17:29');
    insert into time_slots values(36, '18:00', '17:30', '17:59');
    insert into time_slots values(37, '18:30', '18:00', '18:29');
    insert into time_slots values(38, '19:00', '18:30', '18:59');
    insert into time_slots values(39, '19:30', '19:00', '19:29');
    insert into time_slots values(40, '20:00', '19:30', '19:59');
    insert into time_slots values(41, '20:30', '20:00', '20:29');
    insert into time_slots values(42, '21:00', '20:30', '20:59');
    insert into time_slots values(43, '21:30', '21:00', '21:29');
    insert into time_slots values(44, '22:00', '21:30', '21:59');
    insert into time_slots values(45, '22:30', '22:00', '22:29');
    insert into time_slots values(46, '23:00', '22:30', '22:59');
    insert into time_slots values(47, '23:30', '23:00', '23:29');
    insert into time_slots values(48, '24:00', '23:30', '23:59');
    commit;
    The query
    Part 1:
    This Query maps the seat_id in the master table with each time slot and with effective start date between sysdate-60 and sysdate+365 assuming that a seat can be allocated not more than a year. so if there are 10 seats in this table then this table contains 10*48*425 records
    SELECT mst.seat_id
    , cal.sl_no
    , cal.cal_day
    , tm.s_no
    , tm.from_time
    , tm.to_time
    FROM xxcgs_adm_seat_mst mst
    , xxcgs_admin_calendar cal
    , time_slots tm
    WHERE cal.cal_day >= NVL (mst.effective_start,SYSDATE - 60)
    AND cal.cal_day <= NVL (mst.effective_end, SYSDATE + 365)
    I created a view TEST_MST_V on the above query
    Part 2:
    This query is based on the allocation table and it checks the allocated seats with all the time slots and between the allocated date range and marks the timeslot as 0 if it is not allocated and 1 if it is allocated
    SELECT seat_id
    , sl_no
    , cal_day
    , s_no
    , from_time
    , to_time
    FROM
    (SELECT alloc.seat_id
    , cal.sl_no
    , cal.cal_day
    , tm.s_no
    , tm.from_time
    , tm.to_time
    ,SUM(DECODE(LEAST(alloc.time_from,tm.from_time),alloc.time_from,
    DECODE(GREATESTalloc.time_to,tm.to_time),alloc.time_to, 1,0),0))AVAILABILITY
    FROM
    xxcgs_adm_allocation alloc
    ,xxcgs_admin_calendar cal
    ,time_slots tm
    WHERE
    cal.cal_day >= alloc.allocfrom_date
    AND cal.cal_day <= alloc.allocto_date
    GROUP BY alloc.seat_id
    ,cal.sl_no
    ,cal.cal_day
    ,tm.s_no
    ,tm.from_time
    ,tm.to_time
    ORDER BY cal.sl_no, tm.s_no) a
    WHERE a.AVAILABILITY = 1
    I created TEST_ALLOC_V on the above query
    Part 3:
    Here i am substracting the 2nd query output from the 1st to get all the available time slots for all seats. In this i used the views created on the above 2 queries
    SELECT seat_id
    ,sl_no
    ,cal_day
    ,s_no
    ,from_time
    ,to_time
    FROM test_mst_v
    MINUS
    SELECT seat_id
    , sl_no
    , cal_day
    , s_no
    , from_time
    , to_time
    FROM test_alloc_v
    WHERE AVAILABILITY = 1
    Part 4:
    I need to squeeze the time slots to get the available start time and available end time. For that i used the following query on the substracted data
    SELECT seat_id
    ,sl_no
    ,cal_day
    ,MIN (s_no) min_s_no
    ,MAX (s_no) max_s_no
    ,MIN (from_time) min_time
    ,MAX (to_time) max_time
    FROM
    (SELECT
    seat_id
    ,sl_no
    ,cal_day
    ,s_no
    ,prev_s_no
    ,from_time
    ,to_time
    ,COUNT (CASE WHEN prev_s_no IS NULL THEN 'x'
    WHEN prev_s_no != s_no - 1 THEN 'x'
    ELSE NULL
    END)
    OVER (PARTITION BY seat_id, sl_no ORDER BY s_no) grp
    FROM (SELECT seat_id
    ,sl_no
    ,cal_day
    ,s_no
    ,from_time
    ,to_time,
    LAG (s_no) OVER (PARTITION BY seat_id, sl_no ORDER BY s_no) prev_s_no
    FROM(SELECT seat_id
    ,sl_no
    ,cal_day
    ,s_no
    ,from_time
    ,to_time
    FROM test_mst_v
    MINUS
    SELECT seat_id
    , sl_no
    , cal_day
    , s_no
    , from_time
    , to_time
    FROM test_alloc_v
    WHERE AVAILABILITY = 1)))
    GROUP BY seat_id, sl_no, cal_day, grp
    ORDER BY seat_id, cal_day
    But this query is taking long time to fetch the data. Presently we have only 12 seats of data. For this it is taking 40 seconds to fetch the data. Once this project goes live we will have around 10000 seats in the XXCGS_ADM_SEAT_MST table.
    I request any of the experts who can give me a solution based on the data i posted here to modify the query which produces the same results with better performance.
    Thanks and Regards
    Deekshit

    The problem with your query is the approach to this problem. In the given query you are first expanding your data set to time slots and calculate with this rather huge set.
    If you first calculate the gaps and do the expansion to days and time slots as a last step, you gain a lot:
    SQL> set autotrace on
    SQL> SELECT seat_id
      2         , sl_no
      3         , cal_day
      4         , MIN (s_no) min_s_no
      5         , MAX (s_no) max_s_no
      6         , MIN (from_time) min_time
      7         , MAX (to_time) max_time
      8    FROM ( SELECT seat_id
      9               , sl_no
    10               , cal_day
    11               , s_no
    12               , prev_s_no
    13               , from_time
    14               , to_time
    15               , COUNT (CASE WHEN prev_s_no IS NULL THEN 'x'
    16                     WHEN prev_s_no != s_no - 1 THEN 'x'
    17                     ELSE NULL
    18                     END)
    19                 OVER (PARTITION BY seat_id, sl_no ORDER BY s_no) grp
    20            FROM ( SELECT seat_id
    21                     , sl_no
    22                     , cal_day
    23                     , s_no
    24                     , from_time
    25                     , to_time
    26                     , LAG (s_no) OVER (PARTITION BY seat_id, sl_no ORDER BY s_no) prev_s_no
    27                  FROM ( SELECT seat_id
    28                           , sl_no
    29                           , cal_day
    30                           , s_no
    31                           , from_time
    32                           , to_time
    33                        FROM test_mst_v
    34                       MINUS
    35                      SELECT seat_id
    36                           , sl_no
    37                           , cal_day
    38                           , s_no
    39                           , from_time
    40                           , to_time
    41                        FROM test_alloc_v
    42                       )
    43                 )
    44           )
    45   GROUP BY seat_id
    46         , sl_no
    47         , cal_day
    48         , grp
    49   ORDER BY seat_id
    50         , cal_day
    51         , min_time
    52  /
       SEAT_ID      SL_NO CAL_DAY               MIN_S_NO   MAX_S_NO MIN_TI MAX_TI
          1049        288 15-10-2007 00:00:00          1         48 00:00  23:59
          1049        289 16-10-2007 00:00:00          1         48 00:00  23:59
          1049        290 17-10-2007 00:00:00          1         48 00:00  23:59
    <...>
          1142        719 19-12-2008 00:00:00          1         48 00:00  23:59
          1142        720 20-12-2008 00:00:00          1         48 00:00  23:59
    4694 rows selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE
       1    0   SORT (ORDER BY)
       2    1     SORT (GROUP BY)
       3    2       VIEW
       4    3         WINDOW (BUFFER)
       5    4           VIEW
       6    5             WINDOW (SORT)
       7    6               VIEW
       8    7                 MINUS
       9    8                   SORT (UNIQUE)
      10    9                     NESTED LOOPS
      11   10                       NESTED LOOPS
      12   11                         TABLE ACCESS (FULL) OF 'TIME_SLOTS' (TABLE)
      13   11                         TABLE ACCESS (FULL) OF 'XXCGS_ADMIN_CALENDAR' (TABLE)
      14   10                       TABLE ACCESS (FULL) OF 'XXCGS_ADM_SEAT_MST' (TABLE)
      15    8                   SORT (UNIQUE)
      16   15                     VIEW
      17   16                       FILTER
      18   17                         SORT (GROUP BY)
      19   18                           NESTED LOOPS
      20   19                             NESTED LOOPS
      21   20                               TABLE ACCESS (FULL) OF 'TIME_SLOTS' (TABLE)
      22   20                               TABLE ACCESS (FULL) OF 'XXCGS_ADMIN_CALENDAR' (TABLE)
      23   19                             TABLE ACCESS (FULL) OF 'XXCGS_ADM_ALLOCATION' (TABLE)
    Statistics
             47  recursive calls
             21  db block gets
    737202 consistent gets
           4015  physical reads
              0  redo size
         119371  bytes sent via SQL*Net to client
           3940  bytes received via SQL*Net from client
            314  SQL*Net roundtrips to/from client
              4  sorts (memory)
              3  sorts (disk)
           4694  rows processed
    SQL> select f.seat_id
      2         , c.sl_no
      3         , c.cal_day
      4         , s_min.s_no
      5         , s_max.s_no
      6         , to_char(greatest(f.free_from,c.cal_day),'hh24:mi') min_time
      7         , to_char(least(f.free_to,c.cal_day + to_dsinterval('0 23:59:00')),'hh24:mi') max_time
      8    from ( select f.seat_id
      9               , greatest(f.free_from,nvl(s.effective_start,trunc(sysdate)-60)) free_from
    10               , least(f.free_to,nvl(s.effective_end,trunc(sysdate)+366-interval '1' minute)) free_to
    11            from ( select seat_id
    12                     , allocto_date + interval '1' minute free_from
    13                     , lead(allocfrom_date,1,date '2100-01-01') over (partition by seat_id order by allocfrom_date)
    14                       - interval '1' minute free_to
    15                  from ( select a.seat_id
    16                           , a.allocfrom_date + t.column_value - 1 + to_dsinterval('0 '||time_from||':00') allocfrom_date
    17                           , a.allocfrom_date + t.column_value - 1 + to_dsinterval('0 '||time_to||':00') allocto_date
    18                        from xxcgs_adm_allocation a
    19                           , table
    20                             ( cast
    21                            ( multiset(select level from dual connect by level <= (a.allocto_date-a.allocfrom_date)+1)
    22                              as sys.dbms_debug_vc2coll
    23                            )
    24                             ) t
    25                       union all
    26                      select seat_id
    27                           , date '1900-01-01'
    28                           , date '1900-01-01'
    29                        from xxcgs_adm_seat_mst
    30                       )
    31                 ) f
    32               , xxcgs_adm_seat_mst s
    33              where free_from <= free_to
    34             and f.seat_id = s.seat_id
    35           ) f
    36           , xxcgs_admin_calendar c
    37           , time_slots s_min
    38           , time_slots s_max
    39   where c.cal_day >= trunc(f.free_from)
    40       and c.cal_day < trunc(f.free_to) + 1
    41       and to_char(greatest(f.free_from,c.cal_day),'hh24:mi') between s_min.from_time and s_min.to_time
    42       and to_char(least(f.free_to,c.cal_day + to_dsinterval('0 23:59:00')),'hh24:mi') between s_max.from_time and s_max.to_time
    43   order by f.seat_id
    44         , cal_day
    45         , min_time
    46  /
       SEAT_ID      SL_NO CAL_DAY                   S_NO       S_NO MIN_T MAX_T
          1049        288 15-10-2007 00:00:00          1         48 00:00 23:59
          1049        289 16-10-2007 00:00:00          1         48 00:00 23:59
          1049        290 17-10-2007 00:00:00          1         48 00:00 23:59
    <...>
          1142        719 19-12-2008 00:00:00          1         48 00:00 23:59
          1142        720 20-12-2008 00:00:00          1         48 00:00 23:59
    4694 rows selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=5204 Card=2256 Bytes=279744)
       1    0   SORT (ORDER BY) (Cost=5204 Card=2256 Bytes=279744)
       2    1     MERGE JOIN (Cost=5138 Card=2256 Bytes=279744)
       3    2       SORT (JOIN) (Cost=5134 Card=18803 Bytes=1899103)
       4    3         MERGE JOIN (Cost=4696 Card=18803 Bytes=1899103)
       5    4           SORT (JOIN) (Cost=4692 Card=156692 Bytes=12221976)
       6    5             HASH JOIN (Cost=832 Card=156692 Bytes=12221976)
       7    6               MERGE JOIN (CARTESIAN) (Cost=17 Card=12056 Bytes=638968)
       8    7                 TABLE ACCESS (FULL) OF 'XXCGS_ADM_SEAT_MST' (TABLE) (Cost=3 Card=11 Bytes=341)
       9    7                 BUFFER (SORT) (Cost=14 Card=1096 Bytes=24112)
      10    9                   TABLE ACCESS (FULL) OF 'XXCGS_ADMIN_CALENDAR' (TABLE) (Cost=1 Card=1096 Bytes=24112)
      11    6               VIEW (Cost=655 Card=57187 Bytes=1429675)
      12   11                 WINDOW (SORT) (Cost=655 Card=57187 Bytes=1772797)
      13   12                   VIEW (Cost=161 Card=57187 Bytes=1772797)
      14   13                     UNION-ALL
      15   14                       NESTED LOOPS (Cost=159 Card=57176 Bytes=2687272)
      16   15                         TABLE ACCESS (FULL) OF 'XXCGS_ADM_ALLOCATION' (TABLE) (Cost=3 Card=7 Bytes=315)
      17   15                         COLLECTION ITERATOR (SUBQUERY FETCH)
      18   17                           CONNECT BY (WITHOUT FILTERING)
      19   18                             FAST DUAL (Cost=2 Card=1)
      20   14                       INDEX (FAST FULL SCAN) OF 'SYS_C0013270' (INDEX (UNIQUE)) (Cost=2 Card=11 Bytes=143)
      21    4           FILTER
      22   21             SORT (JOIN) (Cost=4 Card=48 Bytes=1104)
      23   22               TABLE ACCESS (FULL) OF 'TIME_SLOTS' (TABLE) (Cost=3 Card=48 Bytes=1104)
      24    2       FILTER
      25   24         SORT (JOIN) (Cost=4 Card=48 Bytes=1104)
      26   25           TABLE ACCESS (FULL) OF 'TIME_SLOTS' (TABLE) (Cost=3 Card=48 Bytes=1104)
    Statistics
            293  recursive calls
              0  db block gets
    114 consistent gets
              0  physical reads
              0  redo size
         119363  bytes sent via SQL*Net to client
           4395  bytes received via SQL*Net from client
            314  SQL*Net roundtrips to/from client
             18  sorts (memory)
              0  sorts (disk)
           4694  rows processedRegards,
    Rob.

  • Report

    Requirement is that enhanced the extractor by adding fields mapped the fields in bw in DSO,added in dimension in cube and also mapped in multiprovider ,this fields has to be reflected in report (not as a key figure) suggest how we can reflect it in report (need to create copy of existing query),mapping at data target level is done just need to create copy query and adding fields in reports ,how can achieve this

    Hi,
    After adding new Field/Fields to the multi provider, you can see those new fields under  the Info provider tab in the left panel in query designer.
    1)Now if you want to copy the same query to a totaly new query, click on Query from the Menu and then select save as    give the technical name and description of the new query ,
    2) Now drag and drop the newly added fileds to the multiprovider in to the query desinger. And finally save the query.

  • If statement in DI

    Hi all
    I'm wondering what the format of IF-ELSE block is in DI. I wan to check validation rules in my query in DI but my IF statement comes with an error. I searched a lot on the Internet but couldn't find the correct syntax. What I wrote is :
    If dateOfBirth < sysdate()
    datafobirth
    end
    Unfortunately there is no help for using functions in DI     It takes me a lot to figure out the correct syntax!!
    Any help is greatly appreciated.

    you can't put a block of logic in Query mapping, you mapping expression should evaluate to a value that will be assgined to the output column
    for Query mapping you will either use constants or expressions along with input columns, or use functions, you either put the logic in a custom function or use thefunctions provided by DI . the DI functions are documented with examples in the technical manual
    for you case you can use ifthenelse() function, or put the same logic in a custom function and call that here
    for example:- in a Query your mapping can be, if your source is a EMP table with DOJ as date column
    ifthenelse(EMP.DOJ < sysdate(), DOJ, NULL)
    or you can take DOJ as input to custom function and return the output based on your requirement

Maybe you are looking for