How to include conditions in select query

i want to write a select query wherein plants have to to be fetched from table vekp
and if it is a plant then the  set movement type to 999 else leave for exiting.please help me on this

>
deep shikha wrote:
> (This is module pool programming)
what is modulepool programming doing in form printing forum.
Please use appropriate forum next time.
кu03B1ятu03B9к

Similar Messages

  • URGENT: To change the where condition in select query at runtime ?

    Hi,
    I have to develop a report, 4 which I have created a selection screen with 7 Input Parameters whose value is to be filled by the user while executing the report.
    On the basis of this I do the desired selection of output.
    But the problem is that how do I write my select Query(where condition) if the user enetrs only 2 Input parameters or 3 or whatever he feels like.
    Pls help me out...

    hi,
    check this sample code.
    Here i am populating where condition at runtime.
    DATA: V_WHERE TYPE STRING.
    SELECTION-SCREEN BEGIN OF BLOCK INPUT WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS : S_VBELN FOR VBAK-VBELN,
                     S_ERDAT FOR VBAK-ERDAT.
    SELECTION-SCREEN END OF BLOCK INPUT.
    START-OF-SELECTION.
      PERFORM POPULATE_WHERE.
      PERFORM GET_VBAK_DATA.
    *&      Form  POPULATE_WHERE
    *       Populate Where
    FORM POPULATE_WHERE .
      IF NOT S_ERDAT[] IS INITIAL.
        CONCATENATE 'VBELN IN S_VBELN'
                    'AND'
                    'ERDAT IN S_ERDAT'
              INTO V_WHERE
              SEPARATED BY SPACE.
      ELSE.
        V_WHERE = 'VBELN IN S_VBELN'.
      ENDIF.
    ENDFORM.                    " POPULATE_WHERE
    *&      Form  GET_VBAK_DATA
    *       GET VBAK DATA
    FORM GET_VBAK_DATA .
      SELECT VBELN
             ERDAT
             VBTYP
             NETWR
             WAERK
             VKORG
             VTWEG
             SPART
        INTO CORRESPONDING FIELDS OF TABLE IT_VBAK
        FROM VBAK
        WHERE VBELN IN S_VBELN
        AND   ERDAT IN S_ERDAT.
       WHERE (V_WHERE).
    endform.
    Regards
    Sailaja.

  • How to include 0STOCK_VAL in a Query based on APO DataSource?

    Hi All,
    I have a requirement to include *0STOCK_VAL" from Inventory to the APO InfoCube. But the problem with this is, this particular KeyFigure is not present in the APO hence it cannot be included in the APO DataSource i.e. we cannot get this from the Source System.
    I checked the Production system, 0STOCK_VAL InfoObject is avaiable in one of the InfoCube but it is not present in any DSO's. Since it is not present in any of the DSO's we cannot write a Routine to read it from any of the table.
    I even thought of including the InfoCube where 0STOCK_VAL is present into a MultiProvider along with the APO InfoCube. I can define the joining condition based on Plant and Material. But if I drill down any other characteristics which are not common in both the  InfoCube then we will have a blank line in the Query which is not recommended.
    But this KeyFigure is very much needed in the Query.
    My question is how to include this in the APO InfoCube or How to get this in the Query with values??
    Can anybody please help me on this.
    Thanks in advance.
    Prasapbi

    hi Matt,
      In your example like a transaction was paid for with a payment type of PTAM, then you need all the transaction details. I suppose that all the required transaction details along with payment type PTAM will be loaded into an infoprovider and you run a report on top of this infoprovider. Then for that report you need to have a selection screen variable for Payment Type and if the user enters the payment type PTAM, then he can get all the other transaction details from the infoprovider.
    Let me know if i don't understand the requirement correctly.
    Hope it helps....

  • How to do outer join select query for an APEX report

    Hello everyone,
    I am Ann.
    I have one select statement that calculate the statistics for one 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','MON YYYY'))
    THEN last_day(TO_DATE('Oct 2012','MON YYYY'))
    ELSE ph.date_finished
    END )
    - ph.date_started + 1) / count(def.def_id) as avg_days
    from phase_membership ph
    inner join court_engagement ce on ph.mpm_eng_id = ce.engagement_id
    inner join defendant def on ce.defendant_id = def.def_id
    where def.active = 1
    and ph.date_started <= last_day(TO_DATE('Oct 2012','MON YYYY'))
    and ph.active = 1
    and UPPER(ce.court_name) LIKE '%'
    group by rollup(phase_number)
    Result is as below
    Phase_Number     AVG_DAYS
    Phase One     8.6666666666666667
    Phase Two     14.6
    Phase Three     12
         11.4615365
    I have other select list mainly list the months between two date value.
    select to_char(which_month, 'MON YYYY') as display_month
    from (
    select add_months(to_date('Aug 2012','MON YYYY'), rownum-1) which_month
    from all_objects
    where
    rownum <= months_between(to_date('Oct 2012','MON YYYY'), add_months(to_date('Aug 2012','MON YYYY'), -1))
    order by which_month )
    Query result is as below
    DISPLAY_MONTH
    AUG 2012
    SEP 2012
    OCT 2012
    Is there any way that I can join these two select statement above to generate a result like:
    Month          Phase Number     Avg days
    Aug 2012     Phase One     8.666
    Sep 2012     Phase One     7.66
    Oct 2012     Phase One     5.66
    Aug 2012     Phase Two     8.666
    Sep 2012     Phase Two     7.66
    Oct 2012     Phase Two     5.66
    Aug 2012     Phase Three     8.666
    Sep 2012     Phase Three     7.66
    Oct 2012     Phase Three     5.66
    Or
    Month          Phase Number     Avg days
    Aug 2012     Phase One     8.666
    Aug 2012     Phase Two     7.66
    Aug 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 order by either Phase Number or Month.
    My other colleague suggest I should use an left outer join but after trying so many ways, I am still stuck.
    One of the select I tried is
    select a.display_month,b.* from (
    select to_char(which_month, 'MON YYYY') as display_month
    from (
    select add_months(to_date('Aug 2012','MON YYYY'), rownum-1) which_month
    from all_objects
    where
    rownum <= months_between(to_date('Oct 2012','MON YYYY'), add_months(to_date('Aug 2012','MON YYYY'), -1))
    order by which_month )) a left outer join
    ( select to_char(ph.date_finished,'MON 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,'MON YYYY'))
    THEN last_day(TO_DATE(a.display_month,'MON YYYY'))
    ELSE ph.date_finished
    END )
    - ph.date_started + 1) / count(def.def_id) as avg_days
    from phase_membership ph
    inner join court_engagement ce on ph.mpm_eng_id = ce.engagement_id
    inner join defendant def on ce.defendant_id = def.def_id
    where def.active = 1
    and ph.date_started <= last_day(TO_DATE(a.display_month,'MON YYYY'))
    and ph.active = 1
    and UPPER(ce.court_name) LIKE '%'
    group by to_char(ph.date_finished,'MON YYYY') , rollup(phase_number)) 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 display a report on APEX with option for people to download at least CSV format.
    I already have 1 inteactive report in the page, so don’t think can add another interactive report without using the iframe trick.
    If any of you have any ideas, please help.
    Thanks a lot.
    Ann

    First of all, a huge thanks for following this Frank.
    I have just started working here, I think the Oracle version is 11g, but not sure.
    To run Oracle APEX version 4, I think they must have at least 10g R2.
    This report is a bit challenging for me.I has never worked with PARTITION before.
    About the select query you suggested, I run , and it seems working fine, but if I try this,
    it return error ORA-01843: not a valid month
    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
    , sum ( (case
    WHEN ph.date_finished IS NULL OR ph.date_finished > last_day(TO_DATE(am.which_month,'MON YYYY'))
    THEN last_day(TO_DATE(am.which_month,'MON YYYY'))
    ELSE ph.date_finished
    END )
    - ph.date_started + 1) / count(def.def_id) as avg_days
    FROM           all_months          am
    LEFT OUTER JOIN  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(TO_DATE(am.which_month,'MON YYYY'))  -- May not be needed
                               AND ph.active = 1
    LEFT OUTER join  court_engagement  ce  on  ph.mpm_eng_id = ce.engagement_id
                                        and ce.court_name IS NOT NULL  -- or something involving LIKE
    LEFT OUTER join  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
    ;Here is the shorted versions of the three tables:
    A_DEFENDANT, A_ENGAGEMENT, A_PHASE_MEMBERSHIP
    CREATE TABLE "A_DEFENDANT"
        "DEF_ID"     NUMBER NOT NULL ENABLE,
        "FIRST_NAME" VARCHAR2(50 BYTE),
        "SURNAME"    VARCHAR2(20 BYTE) NOT NULL ENABLE,
        "DOB" DATE NOT NULL ENABLE,
        "ACTIVE" NUMBER(2,0) DEFAULT 1 NOT NULL ENABLE,
        CONSTRAINT "A_DEFENDANT_PK" PRIMARY KEY ("DEF_ID"))
    Sample Data
    Insert into A_DEFENDANT (DEF_ID,FIRST_NAME,SURNAME,DOB,ACTIVE) values (101,'Joe','Bloggs',to_date('12/12/99','DD/MM/RR'),1);
    Insert into A_DEFENDANT (DEF_ID,FIRST_NAME,SURNAME,DOB,ACTIVE) values (102,'John','Smith',to_date('20/05/00','DD/MM/RR'),1);
    Insert into A_DEFENDANT (DEF_ID,FIRST_NAME,SURNAME,DOB,ACTIVE) values (103,'Jane','Black',to_date('15/02/98','DD/MM/RR'),1);
    Insert into A_DEFENDANT (DEF_ID,FIRST_NAME,SURNAME,DOB,ACTIVE) values (104,'Minnie','Mouse',to_date('13/12/88','DD/MM/RR'),0);
    Insert into A_DEFENDANT (DEF_ID,FIRST_NAME,SURNAME,DOB,ACTIVE) values (105,'Daisy','Duck',to_date('05/08/00','DD/MM/RR'),1);
    CREATE TABLE "A_ENGAGEMENT"
        "ENGAGEMENT_ID" NUMBER NOT NULL ENABLE,
        "COURT_NAME"    VARCHAR2(50 BYTE) NOT NULL ENABLE,
        "DATE_REFERRED" DATE,
        "DETERMINATION_HEARING_DATE" DATE,
        "DATE_JOINED_COURT" DATE,
        "DATE_TREATMENT_STARTED" DATE,
        "DATE_TERMINATED" DATE,
        "TERMINATION_TYPE" VARCHAR2(50 BYTE),
        "ACTIVE"           NUMBER(2,0) DEFAULT 1 NOT NULL ENABLE,
        "DEFENDANT_ID"     NUMBER,
        CONSTRAINT "A_ENGAGEMENT_PK" PRIMARY KEY ("ENGAGEMENT_ID"))
    Insert into A_ENGAGEMENT (ENGAGEMENT_ID,COURT_NAME,DATE_REFERRED,DETERMINATION_HEARING_DATE,DATE_JOINED_COURT,DATE_TREATMENT_STARTED,DATE_TERMINATED,TERMINATION_TYPE,ACTIVE,DEFENDANT_ID) values (1,'AA',to_date('12/08/12','DD/MM/RR'),null,to_date('12/08/12','DD/MM/RR'),null,null,null,1,101);
    Insert into A_ENGAGEMENT (ENGAGEMENT_ID,COURT_NAME,DATE_REFERRED,DETERMINATION_HEARING_DATE,DATE_JOINED_COURT,DATE_TREATMENT_STARTED,DATE_TERMINATED,TERMINATION_TYPE,ACTIVE,DEFENDANT_ID) values (2,'BB',to_date('01/09/12','DD/MM/RR'),null,to_date('02/09/12','DD/MM/RR'),null,null,null,1,102);
    Insert into A_ENGAGEMENT (ENGAGEMENT_ID,COURT_NAME,DATE_REFERRED,DETERMINATION_HEARING_DATE,DATE_JOINED_COURT,DATE_TREATMENT_STARTED,DATE_TERMINATED,TERMINATION_TYPE,ACTIVE,DEFENDANT_ID) values (3,'AA',to_date('02/09/12','DD/MM/RR'),null,to_date('15/09/12','DD/MM/RR'),null,null,null,1,103);
    Insert into A_ENGAGEMENT (ENGAGEMENT_ID,COURT_NAME,DATE_REFERRED,DETERMINATION_HEARING_DATE,DATE_JOINED_COURT,DATE_TREATMENT_STARTED,DATE_TERMINATED,TERMINATION_TYPE,ACTIVE,DEFENDANT_ID) values (4,'BB',to_date('01/10/12','DD/MM/RR'),null,to_date('02/10/12','DD/MM/RR'),null,null,null,1,105);
    CREATE TABLE "A_PHASE_MEMBERSHIP"
        "MPM_ID"       NUMBER NOT NULL ENABLE,
        "MPM_ENG_ID"   NUMBER NOT NULL ENABLE,
        "PHASE_NUMBER" VARCHAR2(50 BYTE),
        "DATE_STARTED" DATE NOT NULL ENABLE,
        "DATE_FINISHED" DATE,
        "NOTES"  VARCHAR2(2000 BYTE),
        "ACTIVE" NUMBER(2,0) DEFAULT 1 NOT NULL ENABLE,
        CONSTRAINT "A_PHASE_MEMBERSHIP_PK" PRIMARY KEY ("MPM_ID"))
    Insert into A_PHASE_MEMBERSHIP (MPM_ID,MPM_ENG_ID,PHASE_NUMBER,DATE_STARTED,DATE_FINISHED,NOTES,ACTIVE) values (1,1,'PHASE ONE',to_date('15/09/12','DD/MM/RR'),to_date('20/09/12','DD/MM/RR'),null,1);
    Insert into A_PHASE_MEMBERSHIP (MPM_ID,MPM_ENG_ID,PHASE_NUMBER,DATE_STARTED,DATE_FINISHED,NOTES,ACTIVE) values (2,1,'PHASE TWO',to_date('21/09/12','DD/MM/RR'),to_date('29/09/12','DD/MM/RR'),null,1);
    Insert into A_PHASE_MEMBERSHIP (MPM_ID,MPM_ENG_ID,PHASE_NUMBER,DATE_STARTED,DATE_FINISHED,NOTES,ACTIVE) values (3,2,'PHASE ONE',to_date('12/09/12','DD/MM/RR'),null,null,1);
    Insert into A_PHASE_MEMBERSHIP (MPM_ID,MPM_ENG_ID,PHASE_NUMBER,DATE_STARTED,DATE_FINISHED,NOTES,ACTIVE) values (4,3,'PHASE ONE',to_date('20/09/12','DD/MM/RR'),to_date('01/10/12','DD/MM/RR'),null,1);
    Insert into A_PHASE_MEMBERSHIP (MPM_ID,MPM_ENG_ID,PHASE_NUMBER,DATE_STARTED,DATE_FINISHED,NOTES,ACTIVE) values (5,3,'PHASE TWO',to_date('02/10/12','DD/MM/RR'),to_date('15/10/12','DD/MM/RR'),null,1);
    Insert into A_PHASE_MEMBERSHIP (MPM_ID,MPM_ENG_ID,PHASE_NUMBER,DATE_STARTED,DATE_FINISHED,NOTES,ACTIVE) values (6,4,'PHASE ONE',to_date('03/10/12','DD/MM/RR'),to_date('10/10/12','DD/MM/RR'),null,1);
    Insert into A_PHASE_MEMBERSHIP (MPM_ID,MPM_ENG_ID,PHASE_NUMBER,DATE_STARTED,DATE_FINISHED,NOTES,ACTIVE) values (7,3,'PHASE THREE',to_date('17/10/12','DD/MM/RR'),null,null,0);
    Insert into A_PHASE_MEMBERSHIP (MPM_ID,MPM_ENG_ID,PHASE_NUMBER,DATE_STARTED,DATE_FINISHED,NOTES,ACTIVE) values (8,1,'PHASE THREE',to_date('30/09/12','DD/MM/RR'),to_date('16/10/12','DD/MM/RR'),null,1);
    The requirements are:
    The user must be able to request the extract for one or more calendar months, e.g.
    May 2013
    May 2013 – Sep 2013.
    The file must contain a separate row for each calendar month in the requested range. Each row must contain the statistics computed for that calendar month.
    The file must also include a row of totals.
    The user must be able to request the extract for either Waitakere or Auckland or Consolidated (both courts’ statistics accumulated).
    Then the part that I am stuck is
    For each monitoring phase:
    Phase name (e.g. “Phase One”)
    Avg_time_in_phase_all_particip
    for each phase name,
    Add up days in each “phase name” Monitoring Phase, calculated as:
    If Monitoring Phase.Date Finished is NULL or > month end date,
    +(*Month end date* Minus Monitoring Phase.Date Started Plus 1)+
    Otherwise (phase is complete)
    +(Monitoring Phase.Date Finished Minus Monitoring Phase.Date Started Plus 1.)+
    Divide by the numbers of all participants who have engaged in “phase name”.
    This is the words of the Business Analyst,
    I try to do as required but still struggle to identify end_month for the above formula to display for the range of months.
    Of course, I can write two nested cursor. The first one run the list of month, then for each month, run the parameterised report.
    But I prefer if possible just use SQL statements, or at least a PL/SQL but return a query.
    With this way, I can create an APEX report, and use their CSV Extract function.
    Yes, you are right, court_name is one of the selection parameters.
    And the statistics is not exactly for one month. It is kind of trying to identify all phases that are running through the specified month (even phase.date_started is before the month start).
    This is the reason why I put the condition AND ph.date_started <= last_day(TO_DATE('Oct 2012','MON YYYY')) (otherwise I get negative avg_days)
    User can choose either one court "AA" or "BB" or combined which is all figures.
    Sorry for bombarding you a lot of information.
    Thanks a lot, again.
    Edited by: Ann586341 on Oct 29, 2012 9:57 PM
    Edited by: Ann586341 on Oct 29, 2012 9:59 PM

  • How to get result of select query from  oracle  in VC

    Dear All ,
    I have a application in oracle which insert the data in the oracle database table.
    Now i want to show all the data that has been inserted into the database table in my VC application but i don't know how to handle select query in VC.
    Regards
    Krishan

    Hi Goivndu
    Thanks for your reply .
    I know all those things.
    I have created the system & alias  for my backend oracle system.
    I can also see all the stored procedure that are there in my oracle system.
    I just want to know how to write a select query in a stored procedure .
    you can insert data , Update data through oracle procedure but i don't think there is any way to get the result of select query in stored procedure .
    If you know any way to do that please do let me know .
    Regards
    Krishan

  • How to use offset in select query

    Suppose i have data like ssonje     00000001 as a one field in database table . i have to segregate this two data. how should I do this.the first part is of 12 characters and the last is of 10 character long.

    Hi Naveen,
    I am again in trouble, Now the requirement were changed. I am sending you the code which i had implemented.
    Now, the user enter username(ie UNAMED) and document id (ie. TEMPD) and the output should be doucment id, which has been search through database table RFDT , field SRTFD, this field contains both the username and the document id.
    That means: suppose user enters UNAMED as SSONJE and TEMPD as 0000000030, then i want to fier the select query from RFDT on field SRTFD and get only the document id of that user which user enter on input field-UNAMED.
    i had tried but result were not coming.
    please go through the code.
    data:uname type UF05A-UNAMD.
    data:temp type UF05A-TEMPD.
    TYPES: BEGIN OF TEITAB_RFDT,
           SRTFD TYPE RFDT-SRTFD,
           END OF TEITAB_RFDT.
    DATA: ITAB_RFDT TYPE TABLE OF TEITAB_RFDT.
    DATA: WA_RFDT TYPE TEITAB_RFDT.
    DATA: STR(22) TYPE c.
    SELECT-OPTIONS:UNAMED FOR uname,
    TEMPD FOR TEMP.
    UNAMED-option = 'CP'.
    append UNAMED.
    CONCATENATE UNAMED TEMPD INTO STR.
    SELECT SRTFD FROM RFDT INTO CORRESPONDING FIELDS OF TABLE ITAB_RFDT WHERE SRTFD eq str.
    LOOP AT ITAB_RFDT INTO WA_RFDT.
    SPLIT WA_RFDT AT SPACE INTO STR1 STR2.
      WRITE: / STR1,STR2.
    ENDLOOP.
    Please mentioned what is the way to do this.
    Thanks

  • How to put loop in select query..?

    Hi All,
    I am setting select query which CRecordSet is going to execute.
    Existing query is,
    Select branchNumber,Count(*) from branches where branchNumber = %d and dowloadType >%d;  
    Here %d is getting filled every time with new value. Now this query is getting execute 500 times if 500 branches are there.
    We want to improve performance. and want branchnumber and count(*) in One go.
    something like, 
    select branchNumber,Count(*) from Branches where 
    (branch =1 and dowloadType >2)
    (branch =2 and dowloadType >100)
     (branch =3 and dowloadType >234)
    how can we do that?
    Kindly help me on this.
    Thanks,
    Sachin.

    Thanks For reply. but here values are coming from different collection from source code.
    For e.g.  Map[branchNumber][DownloadType] = [1,233],[2,444],[30,234],[5,456].
    Now these values i need to insert at the place of  S.branch   and    S.DownloadType                              
    SELECT GB.Branch ,
    COUNT(*)
    FROM @Sample S
    INNER JOIN @GroupBy GB ON GB.Branch = (value from map)
    AND GB.DownloadType < (value from map)
    GROUP BY GB.Branch;

  • How to mention index in select query?

    Hi All,
       If I am using fields of two diffrent secondary index in a single select query on a table how I can mention that data should be picked according to first index used in the query?
    Regards
    Deepak

    Please search before asking basic questions.
    Thread locked.
    Rob

  • How to ignore zero in select query

    select * from EINA where  EINAMATNR = <b>yyyy</b> and EINALIFNR = <b>zzzz</b>
    In select query, how to ignore zero? for example, EINAMATNR = 0000000yyyy, EINALIFNR=000zzz
    Maybe I can use LIKE keyword in sql query. Any other way?
    Thanks.

    Use the following conversion routines to convert yyyy & zzzz  to remove the leading zeros and then pass it to your select query.
    For Matnr -> CONVERSION_EXIT_MATN1_INPUT
    For LIFNR ->CONVERSION_EXIT_alpha_input.
       CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
            EXPORTING
              input  = yyyy
            IMPORTING
              output = t_lifnr.
          CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
            EXPORTING
              input  = zzzz
            IMPORTING
              output = t_matnr.
    select * from EINA where EINA~MATNR = t_matnr  and EINA~LIFNR = t_lifnr .

  • How to get fieldnames from Select * query ?

    How can I get the fieldnames returned with a SELECT * query ?
    When I use GetFieldName or GetFieldOriginalName I only get fieldnames of "*".

    You should use the fields collection, in the OraDynaset object.
    All you need to do is :
    for i = 0 to Recordset.Fields.Count -1
    debug.print Recordset.Fields(i).name
    debug.print Recordset.Fields(i).OriginalName 'this will print the field's name before an alias
    next i

  • How can we split a select query to 3 or 4 if it is fetching much records?

    I am running a query like:
    select * from table_name
    it will be fetching 152940696 records. Now i want to fetch this result as 3 or 4 select statements. That is, in the second query I want to fetch the records from where i stopped in the first query. and similar for the 3rd i have to continue from the 2nd query. And for the 4th query i have to start from where i have stopped in the 3rd query.
    when i tried with rownum we can fetch the records upto < or <= to a particular count like 100000000. But above this count i cannot fetch using rownum. Because > or >= wont work with rownum.
    Is there anyother way to split the select query as i explained.
    Thanks in advance

    I'll assume you want to split the query up for performance reasons.
    The easiest way to do this if you have the license is to use the parallel query option, which can help, hurt or do nothing. The only way to find out is to try. PQO would be best from a performance standpoint if possible, provided it will do what you need.
    Failing that as has been suggested you need a logical, scalable way to divide up the queries. It has already been pointed out that the rownum solution probably will not work correctly. Also, the MINUS with ROWNUM idea has the disadvantage of having to read a lot of the same data twice, making the query run longer.
    Perhaps a range would provide a way to split up the data - something like
    select whatever
      from table
    where primary_key < 10000000;
    select whatever
      from table
    where primary key between 10000001 and 199999999;
    ...

  • How to improve performance of select query when primary key is not referred

    Hi,
    There is a select query where we are unable to refrence primary key of the tables:
    Since, the the below code is refrensing to vgbel and vgpos fields instead of vbeln and posnr..... the performance is very  slow.
    select vbeln posnr into (wa-vbeln1, wa-posnr1)             
           from lips                                            
           where ( pstyv ne 'ZBAT'    
               and pstyv ne 'ZNLN' )  
               and vgbel = i_vbap-vbeln                         
               and vgpos = i_vbap-posnr.                        
    endselect.                                                 
    Please le t me know if you have some tips..

    hi,
    I hope you are using the select statement inside a loop ...endloop get that outside to improve the performance ..
    if not i_vbap[] is initial.
    select vbeln posnr into table it_lips
    from lips
    for all entries in  i_vbap
    where ( pstyv ne 'ZBAT'
    and pstyv ne 'ZNLN' )
    and vgbel = i_vbap-vbeln
    and vgpos = i_vbap-posnr.
    endif.

  • How to include condition types in tax codes

    Hi
    can anyone help me in including the user defined condition types in the tax codes creation ..
    that is in FTXP i would like to add my condition types so that i can specify the % of tax against my condition types..
    and also how these amounts get updated in PO after giving the respective tax code in PO
    regards,
    Raja

    Hi Raja,
    As per below mail it seems that you are using TAXINJ.
    I assume that for your country setting you have assigned TAXINJ procedure.
    After the above setting you can go and add your customer defined condition types in TAXINJ procedure or be it any procedure combination you have selected.
    Once you have added your condition types in TAXINJ the same would be available in FTXP for its Rate maintenance as system picks all the condition types for the procedure as per Country and Tax procedure assignment.
    Trust it helps to sort the issue out.
    Rgds,
    Rajeev Ganju

  • How to improve on insert-select query performance

    Hi,
    Would like to get some opinion on how to improve this query inside my stored proc.
    This insert stmt has run more than 4 hours for inserting around 62k records.
    I have identified the bottleneck is in the function within the select stmt.
    Could anyone help to finetune?
    INSERT INTO STG_PRICE_OUT
    (     ONPN,
         EFFECTIVE_DT,
         PRICE_CATENAME,
         QUEUE_ID
    SELECT P.ONPN, P.EFFECTIVE_DT,
         gps_get_catename(P.PART_STATUS ,P.PROGRAM_CD ,P.MARKET_CD),
         '1'
    FROM      PRICE P,
         GPS_INV_ITEMS GII
    WHERE P.ONPN = GII.ONPN
    FUNCTION Gps_Get_Catename
         p_status      VARCHAR2,
         p_pgm           VARCHAR2,
         p_market      VARCHAR2
    RETURN VARCHAR2
    IS
         catename VARCHAR2(30);
    BEGIN
         SELECT PRICE_CATENAME
         INTO catename
         FROM PRICE_CATEGORY PC
         WHERE NVL(PC.PART_STATUS,' ')= NVL(p_status,' ')
         AND NVL(PC.PROGRAM_CD,' ') = NVL(p_pgm,' ')
         AND NVL(PC.MARKET_CD,' ') = NVL(p_market,' ')
         RETURN catename;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    RETURN NULL;
    WHEN OTHERS
    THEN
    DBMS_OUTPUT.PUT_LINE('gps_get_catename: Exception caught!! (' || SQLCODE || ') : ' || SQLERRM);
         RETURN catename;
    END;
    STG_PRICE_OUT has around 1 mil records
    GPS_INV_ITEMS has around 140K records
    PRICE has around 60k records
    INDEX:
    STG_PRICE_OUT - INDEX 1(ONPN), INDEX2(ONPN,QUEUE_ID)
    GPS_INV_ITEMS - INDEX 3(ONPN)
    PRICE - INDEX 4(ONPN)
    PRICE_CATEGORY - INDEX 5(PART_STATUS ,PROGRAM_CD ,MARKET_CD)
    Thanks and regards,
    WH

    Only use PL/SQL when you can't do it all in SQL...
    INSERT INTO STG_PRICE_OUT
    ( ONPN,
    EFFECTIVE_DT,
    PRICE_CATENAME,
    QUEUE_ID
    SELECT P.ONPN, P.EFFECTIVE_DT,
    PC.PRICE_CATENAME,
    '1'
    FROM PRICE_CATEGORY PC, PRICE P,
    GPS_INV_ITEMS GII
    WHERE P.ONPN = GII.ONPN
    AND PC.PART_STATUS(+) = P.PART_STATUS
    AND PC.PROGRAM_CD(+) = P.PROGRAM_CD
    AND PC.MARKET_CD(+) = P.MARKET_CD
    /Cheers, APC
    P.S. You may need to tweak the outer joins - I'm not quite sure what your business rule is.

  • How to set conditions as a query in cfl?

    i have a combo box and a matrix. i have a cfl in the matrix column, once i select the particular value in the combobox the corresponding values must appear in the cfl. how can this be done?

    Hi Metilda,
    You can try this, i'use this code to set conditions in a CFL for item list. I put this code in the et_CHOOSE_FROM_LIST event in beforeaction=True :
                                            SAPbouiCOM.EditText oEdit;
                                            oEdit = (SAPbouiCOM.EditText)oForm.Items.Item("7").Specific;
                                            string typeMag = oEdit.Value.ToString().Trim();
                                            oCons = oCFL.GetConditions();
                                            if (oCons.Count == 0)
                                                if (typeMag.Substring(0, 1) == "C")
                                                    oCon = oCons.Add();
                                                    oCon.BracketOpenNum = 2;
                                                    oCon.Alias = "SellItem";
                                                    oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                                                    oCon.CondVal = "Y";
                                                    oCon.BracketCloseNum = 1;
                                                    oCon.Relationship = SAPbouiCOM.BoConditionRelationship.cr_AND;
                                                    oCon = oCons.Add();
                                                    oCon.BracketOpenNum = 1;
                                                    oCon.Alias = "U_IFC_CAT";
                                                    oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                                                    oCon.CondVal = typeMag;
                                                    oCon.BracketCloseNum = 2;
                                                    oCFL.SetConditions(oCons);
                                                else
                                                    oCon = oCons.Add();
                                                    oCon.BracketOpenNum = 2;
                                                    oCon.Alias = "SellItem";
                                                    oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                                                    oCon.CondVal = "Y";
                                                    oCon.BracketCloseNum = 1;
                                                    oCon.Relationship = SAPbouiCOM.BoConditionRelationship.cr_AND;
                                                    oCon = oCons.Add();
                                                    oCon.BracketOpenNum = 2;
                                                    oCon.Alias = "U_IFC_CAT";
                                                    oCon.Operation = SAPbouiCOM.BoConditionOperation.co_IS_NULL;
                                                    //oCon.CondVal = null;
                                                    oCon.BracketCloseNum = 1;
                                                    oCon.Relationship = SAPbouiCOM.BoConditionRelationship.cr_OR;
                                                    oCon = oCons.Add();
                                                    oCon.BracketOpenNum = 1;
                                                    oCon.Alias = "U_IFC_CAT";
                                                    oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                                                    oCon.CondVal = "";
                                                    oCon.BracketCloseNum = 3;
                                                    oCFL.SetConditions(oCons);
                                            else
                                                oCons = null;
                                                oCFL.SetConditions(oCons);
                                                oCons = oCFL.GetConditions();
                                                if (typeMag.Substring(0, 1) == "C")
                                                    oCon = oCons.Add();
                                                    oCon.BracketOpenNum = 2;
                                                    oCon.Alias = "SellItem";
                                                    oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                                                    oCon.CondVal = "Y";
                                                    oCon.BracketCloseNum = 1;
                                                    oCon.Relationship = SAPbouiCOM.BoConditionRelationship.cr_AND;
                                                    oCon = oCons.Add();
                                                    oCon.BracketOpenNum = 1;
                                                    oCon.Alias = "U_IFC_CAT";
                                                    oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                                                    oCon.CondVal = typeMag;
                                                    oCon.BracketCloseNum = 2;
                                                    oCFL.SetConditions(oCons);
                                                else
                                                    oCon = oCons.Add();
                                                    oCon.BracketOpenNum = 2;
                                                    oCon.Alias = "SellItem";
                                                    oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                                                    oCon.CondVal = "Y";
                                                    oCon.BracketCloseNum = 1;
                                                    oCon.Relationship = SAPbouiCOM.BoConditionRelationship.cr_AND;
                                                    oCon = oCons.Add();
                                                    oCon.BracketOpenNum = 2;
                                                    oCon.Alias = "U_IFC_CAT";
                                                    oCon.Operation = SAPbouiCOM.BoConditionOperation.co_IS_NULL;
                                                    //oCon.CondVal = null;
                                                    oCon.BracketCloseNum = 1;
                                                    oCon.Relationship = SAPbouiCOM.BoConditionRelationship.cr_OR;
                                                    oCon = oCons.Add();
                                                    oCon.BracketOpenNum = 1;
                                                    oCon.Alias = "U_IFC_CAT";
                                                    oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                                                    oCon.CondVal = "";
                                                    oCon.BracketCloseNum = 3;
                                                    oCFL.SetConditions(oCons);
    It's work fine for me.

Maybe you are looking for

  • Printing templates not functioning correctly.

    I printed (2) 7x5 Prints using template browser. The top print is getting clipped about a quarter inch. In the top left-hand corner both horizontal boxes are stating that the size is 7x5.  I have double checked all the settings. Using a Epson 4900 pr

  • Validation on Posting Data in MIGO

    Dear Experts, My requirement is to put validation on Posting date during MIGO. How can i do that? Can i do it from OMJX? Regards,

  • Label with multiple sizes

    I need to see if in Crystal I can create a report has two different label sizes per line. It would be landscape with a 1x3 label then it starts 1x1 labels to the right of it.  It is east to do with the mailing label wizard with either version but I h

  • BigDecimal vs floating points...

    Hi all, I know its probably been asked amillion times before but I need to finally fully understand and get my head around the two. Firstly here are some bits I've been told by different people and read in different places (alot of people seem to thi

  • Multiple displays of connection paths

    When "My Network Places" is selected The "entire network" displays multiple alias's or clones. These are numbered and can be deleted in some cases. Anyone know the cause for these multiples ?