Plz correct my query

I want to update the news_date from Apr to May
update news set news_date=to_char(news_date,'dd-May-yy HH:MI:SS AM')
where to_char(news_date,'dd-Mon-yy HH:MI:SS AM')=to_char(news_date,'dd-Apr-yy HH:MI:SS AM')
/

Sorry, the page expired error was appeared and resubmitted thats why.I've got the same phenomenon from time to time...
Nicolas.

Similar Messages

  • Plz correct this query

    iam trying to take input at the prompt in one statement only...
    but unable to do it..
    so plz correct my query
    accept var prompt "enter deptno=>" select * from emp where deptno=&var;
    error:
    SQL> accept var prompt "enter deptno=>" select * from emp where deptno=&var;
    Enter value for var: 20
    SP2-0003: Ill-formed ACCEPT command starting as select * from emp where deptno=2
    0
    SQL>
    thank u
    rajiv

    These are two statements you need to exceute separately
    SQL> accept var prompt "enter deptno=>"
    enter deptno=>10
    SQL> select * from emp where deptno=&var;
    old   1: select * from emp where deptno=&var
    new   1: select * from emp where deptno=10
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM
        DEPTNO
          7782 CLARK      MANAGER         7839 09-JUN-81       2450
            10
          7839 KING       PRESIDENT            17-NOV-81       5000
            10
          7934 MILLER     CLERK           7782 23-JAN-82       1300
            10
    SQL>

  • PROBLE IN ADDING A FIELD IN STRUCTURE...PLZ CORRECT THIS CODE

    HI, PLZ CORRECT IT.
    TYPES : BEGIN OF FS_OUTPUT .
          TEXT(20) TYPE C.
            INCLUDE STRUCTURE HRPDV_EXPIRED_Q.
    TYPES       TEXT(20) TYPE C.
    TYPES    END OF FS_OUTPUT.
    LOOP AT P_GT_FIELDCAT INTO WA_FIELDCAT.
        l_tabix = sy-tabix.
        CASE WA_FIELDCAT-FIELDNAME.
          when 'OTYPE'.
            WA_FIELDCAT-DDICTXT = 'L'.
          when 'SOBID'.
            WA_FIELDCAT-DDICTXT = 'L'.
          WHEN 'STEXT'.
            WA_FIELDCAT-DDICTXT = 'L'.
          when 'PTYPE'.
            WA_FIELDCAT-DDICTXT = 'L'.
          when 'POBID'.
            WA_FIELDCAT-DDICTXT = 'L'.
          when 'PSHORT'.
            WA_FIELDCAT-DDICTXT = 'L'.
          WHEN 'PTEXT'.
            WA_FIELDCAT-DDICTXT = 'L'.
          WHEN 'QUALID'.
            WA_FIELDCAT-DDICTXT = 'L'.
          WHEN 'QUALSTXT'.
            WA_FIELDCAT-DDICTXT = 'L'.
          WHEN 'EXPBEGDA'.
            WA_FIELDCAT-DDICTXT = 'L'.
          WHEN 'EXPENDDA'.
            WA_FIELDCAT-DDICTXT = 'L'.
          WHEN 'ICON_S_EVENTS'.
            IF P_H_EVENTS IS INITIAL.
              WA_FIELDCAT-NO_OUT = 'X'.
            else.
              WA_FIELDCAT-DDICTXT = 'X'.
            endif.
        ENDCASE.
        MODIFY P_GT_FIELDCAT FROM WA_FIELDCAT INDEX l_tabix.
      ENDLOOP.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-FIELDNAME = ' TEXT '.
      WA_FIELDCAT-SELTEXT_1 = hTEXT.
      wa_fieldcat-tabname   = ALV_OUTPUT.
      APPEND WA_FIELDCAT TO P_GT_FIELDCAT.
    ENDFORM.

    As you have added te fields below, add the other required fields:
    when 'OTYPE'.
    WA_FIELDCAT-DDICTXT = 'L'.
    when 'SOBID'.
    WA_FIELDCAT-DDICTXT = 'L'.
    WHEN 'STEXT'.
    WA_FIELDCAT-DDICTXT = 'L'.
    when 'PTYPE'.
    WA_FIELDCAT-DDICTXT = 'L'.
    when 'POBID'.
    WA_FIELDCAT-DDICTXT = 'L'.
    when 'PSHORT'.
    WA_FIELDCAT-DDICTXT = 'L'.
    WHEN 'PTEXT'.
    WA_FIELDCAT-DDICTXT = 'L'.
    WHEN 'QUALID'.
    WA_FIELDCAT-DDICTXT = 'L'.
    WHEN 'QUALSTXT'.
    WA_FIELDCAT-DDICTXT = 'L'.
    WHEN 'EXPBEGDA'.
    WA_FIELDCAT-DDICTXT = 'L'.
    WHEN 'EXPENDDA'.
    WA_FIELDCAT-DDICTXT = 'L'.

  • How do I correct this query ?

    here is a query:
    select roleid from Apps_USERROLE where guid in (select guid from Apps_USER_MASTER order by userid)
    This does not work ...because the internal subquery retruns multiple result.
    How do I correct this query ?

    Satish Kandi wrote:
    select roleid from Apps_USERROLE where guid in (select guid from Apps_USER_MASTER order by userid)ORDER BY clause is not supported in subqueries since it makes no sense.
    If you want an ordered result set, you need add order by clause to the main query.
    select roleid from Apps_USERROLE where guid in (select guid from Apps_USER_MASTER)
    order by roleid;
    HTH...we have a problem then . Apps_USER_MASTER has userid as primary key .
    select guid from Apps_USER_MASTER => this could give duplicate guid then .

  • Plz correct the following IFlogic

    Hi Xpertz
    I need the corrections in the following cide basically its in BW transfer rules..
    My logic i have to take a customer and compare it in two tables in BW side
    SELECT SINGLE MATERIAL FROM /BIC/PCUST1 INTO RESULT
    if  /BIC/KUNNR  = TRAN_STRUCTURE-/BIC/KUNNR
        AND /BIC/KDMAT = TRAN_STRUCTURE-/BIC/KDMAT
    else
         IF /BIC/KDMAT=TRAN_STRUCTURE-/BIC/KDMAT
          AND CUSTOMER-/BIC/CONSCUST= 11060.
         ENDIF.
    the above is the code my aim is first it should look up a cust1 table after else condition it needs to look up another table CUSTOMER2 table.
    Based on KDMAT
    If the KDMAT of transfer sture is = cust1-Kdmat
    i have to compare the corrosponding customer - consolidated number with customer 2 table consolidated customer and it should be equal to 11060.
    But bad thing is that i am not well versed ABAPER. plz correct me..
    Points assured..
    Regards
    K M R

    hi K M R
    do u want anything like this?
    if /BIC/KUNNR = TRAN_STRUCTURE-/BIC/KUNNR AND /BIC/KDMAT = TRAN_STRUCTURE-/BIC/KDMAT.
    ... "Condition 1
    ELSEIF /BIC/KDMAT=TRAN_STRUCTURE-/BIC/KDMAT AND CUSTOMER-/BIC/CONSCUST= 11060.
    ... "Condition 2
    ENDIF.
    Regards
    Allan Cristian

  • Accent insensitive Search - plz help me correcting this query

    Hello,
    I just realized that with that query, if I search for "Montreal" (without the accent), I have all the following results, which is what I want
    SELECT
    "ID","TIT"
    from   "REGDOSSIERS" "RDO"
           where
             TRANSLATE(UPPER("TIT"),'ÀÂÉÈÊÎÔÛÙÜ','AAEEEIOUUU')
             like upper(nvl(replace('%' || "P1_REPORT_SEARCH || '%',' ','%'),"TIT"))
    RESULTS
    TIT
    Annuaires Lovell (Montréal et banlieue)
    Juridiction royale de Montréal. Dossiers, 1677-1769
    Montreal Witness, 1845-1938
    {code}
    But how to change it so when I look for: "Montréal" (with the accent) , I have also the same results? Right now, with Montréal, I have nothing
    thanks,
    Roseline
    Edited by: Roseline on 2009-10-01 18:58
    Edited by: Roseline on Oct 1, 2009 7:34 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    If you are on Oracle 10g you can use regexp expressions to do the search.
    Example
    with testdata as (select 'Montreal' txt from dual
                      union all select 'Montréal' txt from dual
                      union all select 'Montreâl' txt from dual
                      union all select 'Montreaux' txt from dual)
    /* end of test data creation */
    select txt from testdata
    where regexp_like (txt, 'Montr[[=e=]]al');
    txt
    Montreal
    Montréal[[=e=]] would be an equivalence class for the letter "e" and includes also searches for é, è, ê etc.
    The best solution mainly depends how your search string is build.
    If you just want to sort, then the nlssort function would be useful.
    Mentioning Nlssort I remembered there is a much better way to implement Accent insensitive search. You just need to set your NLS_SORT parameter correctly. Either to BINARY_AI (the AI means accent and case insensitiv) or add _AI to your nls langage.
    example
    ALTER SESSION SET NLS_COMP=LINGUISTIC;
    alter session set nls_sort = 'FRENCH';
    with testdata as (select 'Montreal' txt from dual
                      union all select 'Montréal' txt from dual
                      union all select 'Montreâl' txt from dual
                      union all select 'Montreaux' txt from dual)
    /* end of test data creation */
    select txt from testdata
    where txt = 'MONTREAL';
    no rows selects
    /* now change the nls sorting */
    alter session set nls_sort = 'FRENCH_AI';
    with testdata as (select 'Montreal' txt from dual
                      union all select 'Montréal' txt from dual
                      union all select 'Montreâl' txt from dual
                      union all select 'Montreaux' txt from dual)
    /* end of test data creation */
    select txt from testdata
    where txt = 'MONTREAL';
    txt
    Montreal
    Montréal
    MontreâlEdited by: Sven W. on Oct 2, 2009 8:34 AM
    Edited by: Sven W. on Oct 2, 2009 10:22 AM - corrected misleading regexp example.

  • Can you pls correct this query :: ( In Oracle Core HRMS )

    Dear all,
    i have created query get result :: ( In Oracle Core HRMS )
    •     EE Number
    •     Forename
    •     Surname
    •     Dept
    •     Start Date
    •     Leave Date
    •     Date of Birth
    •     Address
    •     Salary (New & Existing Employee)
    •     Car Allowance
    •     Effective date (changes/updates)
    •     Creation Date/Update date
    •     Email address
    •     Gender
    •     Job Description
    •     Grade
    •     From and to date for parametres
    •     Last Modified Date
    SELECT
    papf.EMPLOYEE_NUMBER emp_no
    , papf.FIRST_NAME forname
    , papf.LAST_NAME surname
    , replace(replace(hou.attribute1,'10-',''), '14-', '') department
    , pps.date_start strt_date
    , pps.actual_termination_date leave_date
    , papf.DATE_OF_BIRTH dob
    , pdd.ADDRESS_LINE1||''||pdd.ADDRESS_LINE2||','||pdd.ADDRESS_LINE3 Address
    , ppp.proposed_salary_n salary
    , papf.EFFECTIVE_START_DATE estart_date
    , papf.EFFECTIVE_END_DATE eend_date
    , papf.CREATION_DATE crt_date
    , papf.EMAIL_ADDRESS mail_addrs
    , papf.SEX GENDER
    , pj.NAME Job_Des
    , substr(pg.name, 1, 1) GRADE
    , papf.LAST_UPDATE_DATE Last_Modified_Date
    FROM per_all_people_f papf
    , per_all_assignments_f paaf
    , per_addresses pdd
    , per_pay_proposals ppp
    , per_grades pg
    , pay_payrolls_f pp
    , per_jobs pj
    , per_periods_of_service pps
    , per_person_types ppt
    , per_person_type_usages_f pptu
    -- , pay_element_entries_f pee
    , hr_organization_units hou
    WHERE papf.person_id = paaf.person_id
    AND papf.person_id = pdd.person_id
    AND papf.person_id = pptu.person_id
    and papf.person_id = pps.person_id
    and pps.period_of_service_id = paaf.period_of_service_id
    AND ppp.assignment_id = paaf.assignment_id
    -- AND pee.assignment_id = paaf.assignment_id
    AND paaf.grade_id = pg.grade_id
    AND paaf.payroll_id = pp.payroll_id
    AND pptu.person_type_id = ppt.person_type_id
    AND paaf.organization_id = hou.organization_id
    AND pj.job_id = paaf.job_id
    AND ppp.pay_proposal_id = (SELECT MAX (pay_proposal_id)
    FROM per_pay_proposals
    WHERE assignment_id = paaf.assignment_id)
    AND pp.payroll_id = 224
    AND pdd.primary_flag = 'Y'
    AND pee.element_type_id = 221 for car allowance
    AND papf.employee_number <> 'NONE'
    AND ppt.user_person_type in ('Employee', 'Ex-employee' ,'Intern')
    AND ppt.system_person_type in ('EX_EMP', 'EMP')
    AND TRUNC(SYSDATE) between papf.effective_start_date and papf.effective_end_date
    AND TRUNC(SYSDATE) between paaf.effective_start_date and paaf.effective_end_date
    AND TRUNC(SYSDATE) between pptu.effective_start_date and pptu.effective_end_date ;
    can you pls correct this
    still i need to add Car Allowance and Bank details in above query pls tell me where i can get dept details in oracle core HR
    Thanks all
    Edited by: 981527 on Jan 30, 2013 3:41 AM
    Edited by: 981527 on Jan 31, 2013 1:22 AM
    Edited by: 981527 on Jan 31, 2013 1:30 AM
    Edited by: 981527 on Jan 31, 2013 9:03 PM
    Edited by: 981527 on Feb 1, 2013 4:50 AM

    I am taking a guess that 'Dept' is where the employee works, so that will be the column 'NAME' in the table HR_ALL_ORGANIZATION_UNITS; you will need to join with this table on the assignment's organization_id value
    Edited to add: Whilst you're testing this, you might want to consider removing the table PAY_ELEMENT_ENTRIES_F from the table list, otherwise you can look forward to potentially large cartesian product of returned rows!
    Clive
    Edited by: clive_t on 31-Jan-2013 09:59

  • Correct my query.

    Hi gurus,
    I am in need of correction of my query to get the correct output.
    The table structure and data is as follows:
    create table sample_pid (
    pid char(1),
    asof date,
    edf number
    select * from table sample_pid;
         PID     ASOF     EDF
         A     29/08/2011     0.1
         A     31/07/2011     0.2
         B     21/08/2011     0.3
         B     31/07/2011     0.4
         C     31/07/2011     0.5
         D     15/07/2011     0.6
         D     30/06/2011     0.7
    I have to make a list of PIDs with date sysdate-1.If there are no records for sysdate-1, then get the previous month's records with date between the last seven days of the month.If there are both sysdate-1 and date between the last seven days of the month records available for a PID, then the sysdate-1 record should only be selected.
    The output should be:
    PID     ASOF     EDF
    A     29/08/2011     0.1
    B     31/07/2011     0.4
    C     31/07/2011     0.5
    As per the requirement, B 21/08/2011 is not selected because it is neither sysdate-1 nor a date between last seven days of the previous month.
    Likewise D has not been selected since both the dates of D are neither sysdate-1 nor a date between last seven days of the previous month.
    I have written a sql but the result set is wrong.I mean i am not getting the desired output.
    select pid, asof, edf
    from sample_eid
    where
    *1=case when asof=to_date('30/08/2011', 'dd/mm/yyyy') - 1 then 1*
    when asof between last_day(add_months(to_date('30/08/2011', 'dd/mm/yyyy') - 1, -1)) - 6 and
    last_day(add_months(to_date('30/08/2011', 'dd/mm/yyyy') - 1, -1)) then 1 end;
    I get as follows which is wrong:
         PID     ASOF          EDF
         A     29/08/2011     0.1
         A     31/07/2011     0.2
         B     31/07/2011     0.4
         C     31/07/2011     0.5
    Can anyone help me in this?
    Thanks in advance.
    Edited by: mythili varada on Sep 6, 2011 11:13 AM

    is this what you are looking for ?
    SELECT *
      FROM (SELECT pid, asof, edf,
                   ROW_NUMBER () OVER (PARTITION BY pid ORDER BY asof DESC) rn
              FROM sample_pid
             WHERE 1 =
                      CASE
                         WHEN asof = TO_DATE ('30/08/2011', 'dd/mm/yyyy') - 1
                            THEN 1
                         WHEN asof
                                BETWEEN   LAST_DAY
                                             (ADD_MONTHS (  TO_DATE ('30/08/2011',
                                                                     'dd/mm/yyyy'
                                                          - 1,
                                                          -1
                                        - 6
                                    AND LAST_DAY
                                             (ADD_MONTHS (  TO_DATE ('30/08/2011',
                                                                     'dd/mm/yyyy'
                                                          - 1,
                                                          -1
                            THEN 1
                      END)
    WHERE rn = 1

  • Correct the query

    Hi,
    I am getting different output. could anybody please suggest me what is the difference between below two query and correct the 2nd query
    SELECT
    COUNT(DISTINCT CASE WHEN B.LSDT >= SYSDATE - 45 AND A.COUNTRY_CD='IN' THEN B.INDIVIDUAL_ID END) AS US_45
    ,COUNT(DISTINCT CASE WHEN B.LSDT >= SYSDATE - 105 AND A.COUNTRY_CD='IN' THEN B.INDIVIDUAL_ID END) AS US_105
    ,COUNT(DISTINCT CASE WHEN B.LSDT >= SYSDATE - 195 AND A.COUNTRY_CD='IN' THEN B.INDIVIDUAL_ID END) AS US_195
    ,COUNT(DISTINCT CASE WHEN B.LSDT >= SYSDATE - 380 AND A.COUNTRY_CD='IN' THEN B.INDIVIDUAL_ID END) AS US_380
    ,COUNT(DISTINCT CASE WHEN B.LSDT >= SYSDATE - 745 AND A.COUNTRY_CD='IN' THEN B.INDIVIDUAL_ID END) AS US_745
    FROM order B, addr A
    WHERE B.INDIVIDUAL_ID = A.INDIVIDUAL_ID
    AND B.INDIVIDUAL_ID IN (
    SELECT C.INDIVIDUAL_ID
    FROM order C
    WHERE C.PROD_STAT_MKE_CD IN ('A', 'B')
    AND C.LAST_PAYMENT_DT >= SYSDATE - 745)
    AND A.COUNTRY_CD ='IN';
    SELECT
    COUNT(DISTINCT CASE WHEN B.LSDT >= SYSDATE - 45 AND A.COUNTRY_CD='IN' THEN B.INDIVIDUAL_ID END) AS US_45
    ,COUNT(DISTINCT CASE WHEN B.LSDT >= SYSDATE - 105 AND A.COUNTRY_CD='IN' THEN B.INDIVIDUAL_ID END) AS US_105
    ,COUNT(DISTINCT CASE WHEN B.LSDT >= SYSDATE - 195 AND A.COUNTRY_CD='IN' THEN B.INDIVIDUAL_ID END) AS US_195
    ,COUNT(DISTINCT CASE WHEN B.LSDT >= SYSDATE - 380 AND A.COUNTRY_CD='IN' THEN B.INDIVIDUAL_ID END) AS US_380
    ,COUNT(DISTINCT CASE WHEN B.LSDT >= SYSDATE - 745 AND A.COUNTRY_CD='IN' THEN B.INDIVIDUAL_ID END) AS US_745
    FROM order B, addr A
    WHERE B.INDIVIDUAL_ID = A.INDIVIDUAL_ID and A.COUNTRY_CD ='IN'
    and (PROD_STAT_MKE_CD IN ('A', 'B') AND LAST_PAYMENT_DT >= SYSDATE - 745);

    The two queries are asking quite different questions.
    The first looks for all individuals who have a country code of IN and also have a row in the order table (possibly even a different one with prod_stat_mke_cd either A or B and a last_payment_dt sometime in the last 745 days.
    The second, looks for a row where the country code is IN and prod_stat_mke_cd is either A or B and has a last_payment_dt sometime in the last 745 days.
    So, given these three rows:
    individual_id  country_code prod_stat_mke_cd last_payment_dt
    12345          IN           C                01-Jan-2011
    12345          IN           A                01-Jan-2011
    12345          IN           B                01-Jan-2011your first query will return the all three, while your second query will only return the last two rows.
    What exactly are you expecting?
    John

  • Help in correcting the query

    Hi,
    I have below query:
    select u.v_um_code,v_um_name,count(f.v_fc_code), count(s.n_sl_no), count(distinct s.n_agent_no)
    from subm_buss_um_master u,subm_buss_fc_master f,submitted_business_raw s
    where u.v_um_code=f.v_um_code and f.v_fc_code=s.n_agent_no
    and f.v_status='A' and u.v_status='A'
    and trunc(d_submitted) between '01-JUL-2004' AND '31-JUL-2004'
    group by u.v_um_code,v_um_name;
    the output should be such that first all the records should be fetched from subm_buss_um_master table (where u.v_status='A')--> then count(f.v_fc_code) then -->count(s.n_sl_no), count(distinct s.n_agent_no)
    the data/columns in these tables is large, I cannot paste here.
    Thanks in advance
    Tariq.

    Hi,
    If SET operator UNION helps then great!!!
    For example: As per my requirement, first all employees and sum of salary.....is the query.
    SELECT ename, sal FROM emp
    UNION
    SELECT 'Grand Total ', SUM(sal) FROM emp
    ORDER BY sal;
    Regards,
    Sailaja

  • Help with Correcting the Query

    Hi Gurus,
    Could someone let me know if this query is right? When i am building a report i am getting an error that
    Incorrectly defined logical table source (for fact table MTL_DESCR_ELEMENT_VALUES) does not contain mapping for [IBE_MSITES_B.ATTRIBUTE10]. (HY000)
    Incorrectly defined logical table source (for fact table MTL_SYSTEM_ITEMS_FVL) does not contain mapping for [MTL_DESCR_ELEMENT_VALUES.ELEMENT_VALUE].
    from inv.mtl_system_items_b mtlb,
    inv.mtl_descr_element_values mtld,
    apps.mtl_item_Caterogies_v cat,
    apps.mtl_system_items_fvl fvl,
    ibe.ibe_msites_b imb,
    ibe.ibe_dsp_section_items idsi,
    ibe.ibe_dsp_msite_sct_items idmsi
    where mtlb.inventory_item_id = mtld.inventory_item_id
    AND cat.inventory_item_id = mtlb.inventory_item_id
    AND mtlb.inventory_item_id = fvl.inventory_item_id
    AND mtlb.inventory_item_id = idsi.inventory_item_id
    AND idsi.section_item_id = idmsi.section_item_id
    AND imb.msite_id = idmsi.mini_site_id
    Regards

    Hi,
    792011 wrote:
    Hi Gurus,
    Could someone let me know if this query is right? When i am building a report i am getting an error that I'm not sure what you mean by "right". If you're getting an error, doesn't that mean that it's not right?
    Incorrectly defined logical table source (for fact table MTL_DESCR_ELEMENT_VALUES) does not contain mapping for [IBE_MSITES_B.ATTRIBUTE10]. (HY000)
    Incorrectly defined logical table source (for fact table MTL_SYSTEM_ITEMS_FVL) does not contain mapping for [MTL_DESCR_ELEMENT_VALUES.ELEMENT_VALUE].Are those the exact error messages you're getting? What version of Oracle, and what tool, are producing them?
    from inv.mtl_system_items_b mtlb,
    inv.mtl_descr_element_values mtld,
    apps.mtl_item_Caterogies_v cat,
    apps.mtl_system_items_fvl fvl,
    ibe.ibe_msites_b imb,
    ibe.ibe_dsp_section_items idsi,
    ibe.ibe_dsp_msite_sct_items idmsi
    where mtlb.inventory_item_id = mtld.inventory_item_id
    AND cat.inventory_item_id = mtlb.inventory_item_id
    AND mtlb.inventory_item_id = fvl.inventory_item_id
    AND mtlb.inventory_item_id = idsi.inventory_item_id
    AND idsi.section_item_id = idmsi.section_item_id
    AND imb.msite_id = idmsi.mini_site_idEvery query must have a SELECT clause.
    I don't see any other obvious errors in what you posted, though, without the CREATE TABLE statments, there's no way I could see much besides syntax errors. Reading unformatted code is very difficult, however, so I may have missed siomething. Never write, let alone post, unformatted code.
    See the following thread for how to pinpoint errors by taking baby steps:
    What is wrong with my SQL Keeps Errroring out I cannot see where!  HELP

  • PL/SQL body function body returning  not correct SQL query

    Hello,
    Please help!
    There are 2 select lists (gender and ethnicity) on the page.
    When user selects only from one select list or not selects anything - query works fine.
    But if user selects for example: male and white - no data found
    This is a code under Region Source:
    declare
    v_sql varchar2(2000);
    BEGIN
    v_sql:= 'select subject_id,ethnicity,sex from clinical_demo_v
    where 1 = 1';      
    IF :P12_RACE != '%null%' THEN
    v_sql := v_sql ||' and ethnicity = '||'''||:P12_RACE||''';
    ELSE v_sql := v_sql;
    END IF;
    IF :P12_SEX != '%null%' THEN
    v_sql := v_sql ||' and sex = '||'''||:P12_SEX||''';
    ELSE v_sql := v_sql;
    END IF;
    return v_sql;
    end;
    Thank you in advance!

    Try this:
    BEGIN
       v_sql :=
            'SELECT subject_id, ethnicity, sex FROM clinical_demo_v
    where 1 = 1';
       IF :p12_race != '%null%'
       THEN
          v_sql := v_sql || ' and ethnicity = ' || :p12_race;
       ELSE
          v_sql := v_sql;
       END IF;
       IF :p12_sex != '%null%'
       THEN
          v_sql := v_sql || ' and sex = ' || :p12_sex;
       ELSE
          v_sql := v_sql;
       END IF;
       RETURN v_sql;
    END;Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://htmldb.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • BDC FOR f-02 plz correct it

    hi experts,
    i am uploading xl data to F-02 using BDC.
    see my code and correct me
    THIS IS FLAT FILE.
    DDAT        DTY CC     PDAT        REFF       CK  PK ACC G/LTY     AMOUNT   REFF         DUEDATE
    01.04.2008 DR KAP  01.04.2008 MW/S6-06 INR 09 6000   A             10         MW/S6-06 01.04.2008
    01.04.2008 DR KAP     01.04.2008 3489      INR 09 6000   A              20              1234         01.04.2008
    01.04.2008 DR KAP     01.04.2008 3456      INR 09 6000    A             30         3456         01.04.2008
    01.04.2008 DR KAP 01.04.2008   Upload      INR 11 6000                  60         upload         01.04.2008
    *& Report  ZBDC_FI_GL_F42
    REPORT  ZBDC_FI_GL_F42.
    include bdcrecx1.
    data : BEGIN OF wa_it,
          BLDAT TYPE STRING ,"document date
          BLART TYPE BKPF-BLART,"document type
          BUKRS TYPE BKPF-BUKRS ,"com code
          BUDAT TYPE STRING,"posting date
          XBLNR TYPE BKPF-XBLNR ,"reference
          WAERS TYPE BKPF-WAERS ,"currency key
          NEWBS TYPE RF05A-NEWBS ,"posting key for next line item
          NEWKO TYPE RF05A-NEWKO,"account
          NEWUM TYPE RF05A-NEWUM," g/l
          WRBTR TYPE STRING ," amount
          BARCOPY TYPE RF05A-BARCOPY, " referene docu
          ZFBDT TYPE STRING, "due-date
        END OF wa_it.
    DATA : wa_item LIKE WA_IT.
    DATA : it_item like STANDARD TABLE OF wa_item .
    data : it_return like STANDARD TABLE OF ALSMEX_TABLINE,
           wa_return like ALSMEX_TABLINE,
           wa_returns like ALSMEX_TABLINE.
    SELECTION-SCREEN BEGIN OF BLOCK b1.
    PARAMETERS: p_file like RLGRAP-FILENAME OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK B1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
       EXPORTING
         PROGRAM_NAME        = SYST-CPROG
        DYNPRO_NUMBER       = SYST-DYNNR
        FIELD_NAME          = ' '
        STATIC              = ' '
        MASK                = ' '
        CHANGING
          FILE_NAME           = P_FILE.
      EXCEPTIONS
        MASK_TOO_LONG       = 1
        OTHERS              = 2
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      START-OF-SELECTION.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          FILENAME                      = p_file
          I_BEGIN_COL                   = 1
          I_BEGIN_ROW                   = 1
          I_END_COL                     = 12
          I_END_ROW                     = 488
        TABLES
          INTERN                        = it_return
      EXCEPTIONS
        INCONSISTENT_PARAMETERS       = 1
        UPLOAD_OLE                    = 2
        OTHERS                        = 3
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      if sy-SUBRC = 0 .
    sort it_return by row col.
    loop at it_return into wa_returns.
      wa_return = wa_returns.
      case wa_return-col.
      WHEN 1.
        wa_item-BLDAT = wa_return-value.
        when 2.
        wa_item-BLART = wa_return-value.
        when 3.
        wa_item-BUKRS = wa_return-value.
        when 4.
        wa_item-BUDAT = wa_return-value.
        WHEN 5.
        wa_item-xblnr = wa_return-value.
        when 6.
        wa_item-WAERS = wa_return-value.
        when 7.
        wa_item-NEWBS = wa_return-value.
        when 8 .
        wa_item-newko = wa_return-value.
        WHEN 9.
        wa_item-newum = wa_return-value.
        when 10.
        wa_item-WRBTR = wa_return-value.
        WHEN 11.
        wa_item-barcopy = wa_return-value.
        when 12.
        wa_item-zfbdt = wa_return-value.
      endcase.
    at END OF row.
    APPEND wa_item to it_item.
      clear : wa_item , wa_return.
    endat.
    ENDLOOP.
    endif.
    perform open_group.
    LOOP AT it_item INTO wa_item .
    if SY-TABIX = 1  .
      perform 1 .
    ELSEIF SY-TABIX > 1 and  SY-TABIX < 4.
      PERFORM 2 .
    ELSEIF SY-TABIX = 4 .
    PERFORM 3 .
    endif.
    perform bdc_transaction using 'F-02'.
    ENDLOOP.
    perform close_group.
    form 1.
    perform bdc_dynpro      using 'SAPMF05A' '0100'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'BKPF-XBLNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BKPF-BLDAT'
                                  wa_item-bldat.
    perform bdc_field       using 'BKPF-BLART'
                                  wa_item-blart.
    perform bdc_field       using 'BKPF-BUKRS'
                                  wa_item-bukrs.
    perform bdc_field       using 'BKPF-BUDAT'
                                  wa_item-budat.
    perform bdc_field       using 'BKPF-WAERS'
                                  wa_item-WAERS.
    perform bdc_field       using 'BKPF-XBLNR'
                                  wa_item-XBLNR.
    perform bdc_field       using 'FS006-DOCID'
    perform bdc_field       using 'RF05A-BARCOPY'
                                  wa_item-barcopy.
    perform bdc_field       using 'RF05A-NEWBS'
                                  wa_item-newbs.
    perform bdc_field       using 'RF05A-NEWKO'
                                  wa_item-NEWko.
    perform bdc_field       using 'RF05A-NEWUM'
                                  wa_item-newum.
    perform bdc_dynpro      using 'SAPMF05A' '0304'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'BSEG-ZFBDT'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=BU'.
    perform bdc_field       using 'BSEG-WRBTR'
                                  wa_item-WRBTR.
    perform bdc_field       using 'BSEG-ZFBDT'
                                  wa_item-zfbdt.
    ENDFORM.
    form 2.
    perform bdc_dynpro      using 'SAPMF05A' '0700'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'BKPF-XBLNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BKPF-XBLNR'
                                  wa_item-xblnr.
    perform bdc_field       using 'RF05A-NEWBS'
                                  wa_item-NEWBS.
    perform bdc_field       using 'RF05A-NEWKO'
                                  wa_item-newko.
    perform bdc_field       using 'RF05A-NEWUM'
                                  wa_item-newum.
    perform bdc_dynpro      using 'SAPMF05A' '0304'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'BSEG-ZFBDT'.
    perform bdc_field       using 'BDC_OKCODE'
                                  'BU'.
    perform bdc_field       using 'BSEG-WRBTR'
                                  wa_item-WRBTR.
    perform bdc_field       using 'BSEG-ZFBDT'
                                  wa_item-ZFBDT.
    ENDFORM.
    form 3.
    perform bdc_dynpro      using 'SAPMF05A' '0700'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'BKPF-XBLNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BKPF-XBLNR'
                                  wa_item-xblnr.
    perform bdc_field       using 'RF05A-NEWBS'
                                  wa_item-NEWBS.
    perform bdc_field       using 'RF05A-NEWKO'
                                  wa_item-newko.
    perform bdc_dynpro      using 'SAPMF05A' '0301'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'BSEG-WRBTR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=BU'.
    perform bdc_field       using 'BSEG-WRBTR'
                                  wa_item-wrbtr.
    perform bdc_field       using 'BSEG-ZFBDT'
                                  wa_item-ZFBDT.
    ENDFORM.

    Hi Kumar
    Check this link for :
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/bdc%252bon%252bf-02
    Regards
    Neha

  • Plz correct Code given or tell error

    Hi all,
    I am trying to find solution but no result.
    The code is given below. It compile without any error... but when run it, it gives an error
    " Object read error ! Writing aborted; java.io.NotSerializableException Class name
    Exception in Thread "main" java.lang.NullPointerException "
    import java.io.*;
    public class MemberMaintainer
    public static void main(String[] args) throws IOException, ClassNotFoundException
    Membership membs = null;
    try {
    FileInputStream fis = new FileInputStream("Membership.data");
    ObjectInputStream ois = new ObjectInputStream(fis);
    ClubMember.membershipNumber = ois.readInt();
    membs = (Membership)ois.readObject();
    ois.close();
    catch(FileNotFoundException e)
    membs = new Membership(5);
    catch(Exception e)
    System.out.println( "Object read error! " + e.getMessage() );
    // System.exit( 1 );
    I hope i will get reply positively
    Regards,
    Dave

    Thanks for reply dear,
    I also request you to plz tell me the solution means how to rectify this error.
    Regards,
    Dave

  • Correction in query using rank

    Hi All,
    I have a sample table as below:
    CREATE TABLE sample_obj (appno VARCHAR2(10),universe VARCHAR2(100),rank_univers NUMBER,country VARCHAR2(100),industrie VARCHAR2(10));
    insert into sample_obj (APPNO, UNIVERSE, RANK_UNIVERS, COUNTRY, INDUSTRIE)
    values ('E001', 'RE', 1, 'US', 'PS');
    insert into sample_obj (APPNO, UNIVERSE, RANK_UNIVERS, COUNTRY, INDUSTRIE)
    values ('E002', 'RM', 2, '', 'PD');
    I have written the following query which orders the recods by rank_univers
    SELECT country,
         industrie,
         rank() over(ORDER BY rank_univers) rank_univ
    FROM sample_obj;
    Result set :
    COUNTRY     INDUSTRIE     RANK_UNIV
    US     PS     1
         PD     2
    I need the result set to have only the record that has non null values of COUNTRY and INDUSTRIE. Here above, I need only US,PS,1 record.
    If for both the records, either all the values for COUNTRY and INDUSTRIE are either null or not null, then i should get records as per the rank_univ.
    CASE 1:
    If the records both have COUNTRY AND INDUSTRI not null then I should get only
    RANK_UNIV=1 record.
    CASE 2:
    If for any of the records either COUNTRY or INDUSTRIE is null , then record that has the not null value has to be chosen.
    Can anyone help me out?
    Thanks

    Having re-read your question I think I now understand (it was a little cryptic to understand :-) ).
    If both country and industrie are not null, that have high priority.
    If country is not null and industrie is null, that have medium priority.
    If country is null and industrie is not null, that have medium priority.
    If both country and industrie are null, that have low priority.
    That can also be included in the CASE logic:
    SELECT
    country,
    industrie,
    rank() over(
      ORDER BY
      case
        when country is not null and industrie is not null then 1
        when country is not null and industrie is null then 2
        when country is null and industrie is not null then 2
        else 3
      end,
      rank_univers
    ) rank_univ
    FROM sample_obj;The CASE statement gives a priority for the ranking.
    Then if there are more than one record with same priority, they are ordered by rank_univers.
    Using such a method you can express practically any ranking/ordering logic in your order by clause.

Maybe you are looking for

  • When I convert a trailer to a project and add content, how can I get the music track to repeat longer

    Hey fellow Apple Geniuses - I just got the latest iMovie11 so excited for the new trailer feature, only to discover that these teenie weenie movie trailers are not near long enough for my taste, however I do like the cool transitions and layouts, so

  • Help with a weird problem

    I have a site just taking over and am having an issue figuring out why a Social link will not work. I've examined the code and can't see what is wrong. The site is here Southern Oregon Music Festival | Tickets On the home page the social links all wo

  • I am installing windows on my computer.

    I cannot eject the windows disc so that I can install the bootcamp drivers.  Does anyone have any suggetions.

  • Generate PDF Files Dynamically Using XSL-FO

    Hi, I have downloaded the strutscx sample application and helped me lot in generting a PDF report and quite comfortable with that. But we have webapplication where in we dynmically need to generate a PDF report. But the data is really huge. So I have

  • Simulating an iPad App

    I just started a new job and tauted all the great things that Captivate can do.  My new company bought Captivate 5.5 for me.  One of my new bosses asked me if I can simulate an iPad app to teach users how to use it as a tutorial.  This would not actu