Select Materials based on Characteristics

Hello,
I would like to select specific materials (<b>MARA</b>) based on the assigned characteristics and values (<b>AUSP</b>).
My first approach would be the following: select table AUSP with the characteristic and value, then select MARA with <b>MARA-CUOBF</b> = <b>AUSP-OBJEK</b>.
But, the problem is, that there is no index on the field <b>MARA-CUOBF</b>.
Is there another way to select material based on characteristics and values? Does there any index table or reference table exist?
Thank you for your assistance in advance.
Best Regards,
Kurt.

Hi Kurt,
there is a way if u know the characteristic of the material.
give characteristic in AUSP-ATINN field in AUSP table.
collect all OBJEK's for that characteristics.
then go to table INOB, select objek from inob into itab where cuobj = ausp-objek.
INOB-OBJEK gives u a combination of material number and batch number for that material number. ( there might be different batches for one material).
so collect inob-objek and split into matnr and batch.
there u get all materials according to ur characteristic
and also collect those objeks where ur matnr is there.
and regarding to that matnr and batch in MSEG table u can do rest of the stuff....
reward if it helps
Regards
Message was edited by: srinu k

Similar Messages

  • In BI how to filter the selection options based on inputs on top field

    Hi Friends,
    In BI, How to filter the selection options based on inputs on top field.
    The system should automatically filter the lower level drop downs based on the selection of a higher level.
    For e.g. :
    If a user selects a Country then the States drop down should only display the State's belongs to the Country. Similarly when a State is selected, the District drop down should display only those District's belongs to the State.
    Thanks in Advance.
    Regards
    Jayaram M

    Hi Anil,
    Thanks for reply but I couldn't use Compounding Characteristic here. Need some other solution.
    Regards
    Jayaram M

  • Problem writing a sql query for a select list based on a static LOV

    Hi,
    I have the following table...
    VALIDATIONS
    ID          Number     (PK)
    APP_ID          Number     
    REQUESTED     Date          
    APPROVED     Date          
    VALID_TIL     Date
    DEPT_ID          Number     (FK)
    I have a search form with the following field item variables...
    P11_DEPT_ID (select list based on dynamic LOV from depts table)
    P11_VALID (select list based on static Yes/No LOV)
    A report on the columns of the Validations table is shown based on the values in the search form. So far, my sql query for the report is...
    SELECT v.APP_ID,
    v.REQUESTED,
    v.APPROVED,
    v.VALID_TIL,
    d.DEPT
    FROM DEPTS d, VALIDATIONS v
    WHERE d.DEPT_ID = v.DEPT_ID(+)
    AND (d.DEPT_ID = :P11_DEPT_ID OR :P11_DEPT_ID = -1)
    This query works so far. My problem is that I don't know how to do a search based on the P11_VALID item - if 'yes' is selected, then the VALID_TIL date is still valid. If 'no' is selected then the VALID_TIL date has passed.
    Can anyone help me to extend my query to include this situation?
    Thanks.

    Hello !
    Let's have a look at my example:create table test
    id        number
    ,valid_til date
    insert into test values( 1, sysdate-3 );
    insert into test values( 2, sysdate-2 );
    insert into test values( 3, sysdate-1 );
    insert into test values( 4, sysdate );
    insert into test values( 5, sysdate+1 );
    insert into test values( 6, sysdate+2 );
    commit;
    select * from test;
    def til=yes
    select *
      from test
      where decode(sign(trunc(valid_til)-trunc(sysdate)),1,1,0,1,-1)
           =decode('&til','yes',1,-1);
    def til=no
    select *                                                                               
      from test                                                                            
      where decode(sign(trunc(valid_til)-trunc(sysdate)),1,1,0,1,-1)
           =decode('&til','yes',1,-1);  
    drop table test;  It's working fine, I've tested it.
    The above changes to my first idea I did because of time portion of the DATE datatype in Oracle and therefore the wrong result for today.
    For understandings:
    1.) TRUNC removes the time part of DATE
    2.) The difference of to date-values is the number of days between.
    3.) SIGN is the mathematical function and gives -1,0 or +1 according to an negative, zero or positiv argument.
    4.) DECODE is like an IF.
    Inspect your LOV for the returning values. According to my example they shoul be 'yes' and 'no'. If your values are different, you may have to modify the DECODE.
    Good luck,
    Heinz

  • Select text based on format (free form style text)

    As suggested by Apple, I'm trying to create my first ePub using Pages as opposed to inDesign.
    I only have a PDF as a source file and don't want to re-type all the text.
    When I copy the text from the PDF and paste to Pages, the text comes in with the 'free form' style applied no matter what options I select during copy and paste.
    In order to produce an ePub, I need to set styles for the text. This is quite tedious.
    Is there any way to select text based on the way it is formatted when styles are not applied to the text?

    Here is a script which may be useful if your problem surface again.
    --{code}
    --[SCRIPT words_attributes_to_Style]
    Enregistrer le script en tant que Script : words_attributes_to_Style.scpt
    déplacer le fichier ainsi créé dans le dossier
    <VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:Applications:Pages:
    Il vous faudra peut-être créer le dossier Pages et peut-être même le dossier Applications.
    Ouvrir un document Pages contenant des mots soulignés
    Aller au menu Scripts , choisir Pages puis choisir “words_attributes_to_Style”
    Le script appliquera :
    le style "Souligné" aux mots soulignés
    le style "Accentuation" aux mots en gras
    le style "Italic" (si vous l'avez créé) aux mots en italique.
    --=====
    L’aide du Finder explique:
    L’Utilitaire AppleScript permet d’activer le Menu des scripts :
    Ouvrez l’Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
    Cochez la case “Afficher le menu des scripts dans la barre de menus”.
    Sous 10.6.x,
    aller dans le panneau “Général” du dialogue Préférences de l’Éditeur Applescript
    puis cocher la case “Afficher le menu des scripts dans la barre des menus”.
    --=====
    Save the script as a Script: words_attributes_to_Style.scpt
    Move the newly created file into the folder:
    <startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Pages:
    Maybe you would have to create the folder Pages and even the folder Applications by yourself.
    Select a Pages document embedding underlined words
    Go to the Scripts Menu, choose Pages, then choose “words_attributes_to_Style”
    The script will apply :
    the named style "Underlined" to the underlined words
    the named style "Emphasis" to bolded words
    the named style "Italic" (assuming that you defined it) to italicized words.
    --=====
    The Finder’s Help explains:
    To make the Script menu appear:
    Open the AppleScript utility located in Applications/AppleScript.
    Select the “Show Script Menu in menu bar” checkbox.
    Under 10.6.x,
    go to the General panel of AppleScript Editor’s Preferences dialog box
    and check the “Show Script menu in menu bar” option.
    --=====
    Yvan KOENIG (VALLAURIS, France)
    2011/11/13
    2011/11/13 enhanced by Nigel Garvey in : http://macscripter.net/viewtopic.php?pid=145883#p145883
    --=====
    on run
              set Underlined_loc to my getLocalizedStyleName("Pages", "Blank.template", "STYLE_Underline")
              set Emphasis_loc to my getLocalizedStyleName("Pages", "Blank.template", "STYLE_Emphasis")
              tell application "Pages" to tell document 1
                        set character style of words whose underline type is single underline or underline type is double underline to character style Underlined_loc
                        set character style of words whose bold is true to character style Emphasis_loc
    Assuming that you defined your own Italic style named "Italic", you may use : *)
                        try
                                  set character style of words whose italic is true to character style "Italic"
                        end try
              end tell
    end run
    --=====
    Example
    set Heading8_loc to my getLocalizedStyleName("Pages", "STYLE_Heading 8")
    Requires :
    getLocalizedName()
    on getLocalizedStyleName(theApp, tName, x)
      activate application theApp
              tell application "System Events"
                        (application file of application process theApp as text) & "Contents:Resources:Templates:" & tName & ":Contents:Resources:"
                        return my getLocalizedName(theApp, x, result)
              end tell
    end getLocalizedStyleName
    --=====
    on getLocalizedName(a, x, f)
              tell application a to return localized string x from table "Localizable" in bundle file f
    end getLocalizedName
    --=====
    List of default styles embedded in the Blank template :
    "STYLE_Body" = "Corps";
    "STYLE_Body Bullet" = "Puce du corps de texte";
    "STYLE_Bullet" = "Puce";
    "STYLE_Caption" = "Légende";
    "STYLE_Emphasis" = "Accentuation";
    "STYLE_Footnote Text" = "Texte de note de bas de page";
    "STYLE_Free Form" = "Format libre";
    "STYLE_Harvard" = "Harvard";
    "STYLE_Header & Footer" = "En-tête et bas de page";
    "STYLE_Heading 1" = "Sous-section 1";
    "STYLE_Heading 2" = "Sous-section 2";
    "STYLE_Heading 3" = "Sous-section 3";
    "STYLE_Heading 4" = "Sous-section 4";
    "STYLE_Heading 5" = "Sous-section 5";
    "STYLE_Heading 6" = "Sous-section 6";
    "STYLE_Heading 7" = "Sous-section 7";
    "STYLE_Heading 8" = "Sous-section 8";
    "STYLE_Heading 9" = "Sous-section 9";
    "STYLE_Legal" = "Légal";
    "STYLE_None" = "Aucun";
    "STYLE_Normal" = "Normal";
    "STYLE_Normal 22" = "Normal 22";
    "STYLE_Normal 4" = "Normal 4";
    "STYLE_Normal 8" = "Normal 8";
    "STYLE_Numbered List" = "Liste numérotée";
    "STYLE_Series_0" = "Series_0";
    "STYLE_Series_1" = "Series_1";
    "STYLE_Series_2" = "Series_2";
    "STYLE_Series_3" = "Series_3";
    "STYLE_Series_4" = "Series_4";
    "STYLE_Series_5" = "Series_5";
    "STYLE_Strikethrough" = "Barré";
    "STYLE_TOC" = "Table des matières";
    "STYLE_TOC Heading 1" = "Sous-section 1 de table des matières";
    "STYLE_TOC Heading 2" = "Sous-section 2 de table des matières";
    "STYLE_TOC Heading 3" = "Sous-section 3 de table des matières";
    "STYLE_TOC Heading 4" = "Sous-section 4 de table des matières";
    "STYLE_Title" = "Titre";
    "STYLE_Underline" = "Souligné";
    "STYLE_[Null]" = "[Nul]";
    You may use more sophisticated custom styles embedding several properties:
    baseline shift (real) : Raise or lower the target text.
    bold (boolean) : Whether the font style is bold.
    capitalization type (all caps/normal capitalization/small caps) : Whether a capitalization style is applied.
    character background color (color) : The color of the character's background.
    color (color) : The color of the font.
    font name (text) : The name of the font.
    font size (real) : The size of the font.
    italic (boolean) : Whether the font style is italic.
    ligatures (all ligatures/default ligatures/none) : Remove ligatures from the target text if the document is set to use ligatures.
    name (text) : The name of the style.
    outline (boolean) : Whether the font style is outline.
    shadow (boolean) : Whether the text box content casts a shadow or not.
    shadow angle (real) : The directional angle, in degrees, that the shadow is cast.
    shadow blur (integer) : The relative amount of blur of images seen through the shadow.
    shadow color (color) : The color of the shadow.
    shadow offset (real) : The offset from the text box content that the shadow extends to.
    shadow opacity (real) : The amount of opacity for the shadow, in percent.
    strikethrough color (color) : The color of the strikethrough line(s).
    strikethrough type (double strikethrough/none/single strikethrough) : Whether one or more lines are drawn through the characters.
    subscript (boolean) : Decrease the font size and lower the baseline of the text.
    superscript (boolean) : Decrease the font size and raise the baseline of the text.
    tracking (real) : The space between text characters, in percent.
    underline color (color) : The color of the underline(s).
    underline type (double underline/none/single underline) : Whether the font style is underline.
    --[/SCRIPT]
    --{code}
    Yvan KOENIG (VALLAURIS, France) lundi 2 janvier 2012
    iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2
    My iDisk is : http://public.me.com/koenigyvan
    Please : Search for questions similar to your own before submitting them to the community
    For iWork's applications dedicated to iOS, go to :
    https://discussions.apple.com/community/app_store/iwork_for_ios

  • SELECT QUERY  BASED ON SECONDARY INDEX

    Hi all,
    CAN ANYONE TELL ME HOW TO WRITE SELECT QUERY BASED ON SECONDARY INDEX.
    IN WHAT WAY DOES IT IMPROVE PERFORMANCE.
    i KNOW WHEN CREATING SECONDARY INDEX I NEED TO GIVE AN INDEX NO -iT SHOULD BE ANY NUMBER RIGHT?
    I HAVE TO LIST ALL PRIMARY KEYS FIRST AND THEN THE FIELD FOR WHICH I AM CREATING SECONDARY INDEX RIGHT?
    LETS SAY I HAVE 2 PRIMARY KEYS AND I WANT TO CREATE SEONDARY INDEX FOR 2 FIELDS THEN
    I NEED TO CREATE A SEPERTE SECONDARY INDEX FOR EACH ONE OF THOSE FIELDS OR ONE SHOULD BE ENOUGH
    pLS LET ME KNOW IF IAM WRONG

    HI,
    If you cannot use the primary index to determine the result set because, for example, none of the primary index fields occur in the WHERE or HAVINGclauses, the system searches through the entire table (full table scan). For this case, you can create secondary indexes, which can restrict the number of table entries searched to form the result set.
    You create secondary indexes using the ABAP Dictionary. There you can create its columns and define it as UNIQUE. However, you should not create secondary indexes to cover all possible combinations of fields.
    Only create one if you select data by fields that are not contained in another index, and the performance is very poor. Furthermore, you should only create secondary indexes for database tables from which you mainly read, since indexes have to be updated each time the database table is changed. <b>As a rule, secondary indexes should not contain more than four fields</b>, <b>and you should not have more than five indexes for a single database table</b>.
    <b>What to Keep in Mind for Secondary Indexes:</b>
    http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eb2d446011d189700000e8322d00/content.htm
    http://www.sap-img.com/abap/quick-note-on-design-of-secondary-database-indexes-and-logical-databases.htm
    Regards
    Sudheer

  • Changing the selection screen based on the option in list box option

    Hi Experts,
    I have a list box parameter in my selection screen,
    i have four options and i am changing my selection screen based the option selected.
    see my code below,
    at selection-screen output.
      GS_VRM_VALUES-KEY = '1'.
      GS_VRM_VALUES-TEXT = TEXT-S02.
      APPEND GS_VRM_VALUES TO GT_VRM_VALUES.
      GS_VRM_VALUES-KEY = '2'.
      GS_VRM_VALUES-TEXT = TEXT-S03.
      APPEND GS_VRM_VALUES TO GT_VRM_VALUES.
      GS_VRM_VALUES-KEY = '3'.
      GS_VRM_VALUES-TEXT = TEXT-S04.
      APPEND GS_VRM_VALUES TO GT_VRM_VALUES.
      GS_VRM_VALUES-KEY = '4'.
      GS_VRM_VALUES-TEXT = TEXT-S05.
      APPEND GS_VRM_VALUES TO GT_VRM_VALUES.
      CLEAR: GS_VRM_VALUES.
      CALL FUNCTION 'VRM_SET_VALUES'
        EXPORTING
          ID                    = 'P_DROP'
          VALUES                = GT_VRM_VALUES
      EXCEPTIONS
        ID_ILLEGAL_NAME       = 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.
    LOOP AT SCREEN .
        CASE P_DROP .
          WHEN '1'.
            IF SCREEN-GROUP1 = 'M2' OR
              SCREEN-GROUP1 = 'M3' OR SCREEN-GROUP1 = 'M4'.
              SCREEN-INPUT = 0.
             SCREEN-ACTIVE = 0.
              screen-invisible = 1.
              MODIFY SCREEN.
            ENDIF.
          WHEN '2'.
            IF SCREEN-GROUP1 = 'M3' OR SCREEN-GROUP1 = 'M4'.
              SCREEN-INPUT = 0.
             SCREEN-ACTIVE = 0.
              screen-invisible = 1.
              MODIFY SCREEN.
            ENDIF.
          WHEN '3'.
            IF SCREEN-GROUP1 = 'M2' OR
                SCREEN-GROUP1 = 'M4' .
              SCREEN-INPUT = 0.
             SCREEN-ACTIVE = 0.
              screen-invisible = 1.
              MODIFY SCREEN.
            ENDIF.
          WHEN '4'.
            IF SCREEN-GROUP1 = 'M2' OR
            SCREEN-GROUP1 = 'M3'.
              SCREEN-INPUT = 0.
             SCREEN-ACTIVE = 0.
              screen-invisible = 1.
              MODIFY SCREEN.
            ENDIF.
          WHEN OTHERS.
            IF SCREEN-GROUP1 = 'M2' OR
               SCREEN-GROUP1 = 'M3' OR SCREEN-GROUP1 = 'M4'.
              SCREEN-INPUT = 0.
             SCREEN-ACTIVE = 0.
          screen-invisible = 1.
              MODIFY SCREEN.
            ENDIF.
        ENDCASE.
      ENDLOOP.
    my problem is when i change the option in the list box, the particular modify group ie, the screen is getting changed only after i press enter, So please suggest me how i can change the screen without pressing enter.

    Hi,
    without using VRM_SET_VALUES...you just create one data element by going se11....create one domain for it...now give the values in the "value range" tab....and at the time of declaration just write ..
    PARAMETERS var1 TYPE <your created data element>
                        AS LISTBOX VISIBLE LENGTH 20
                        USER-COMMAND onli
                        DEFAULT <one value>.
    You will get the same effect as list box....and make it mandatory..
    Arunima

  • Creating a dynamic Selection List based on a View Object

    Hello,
    I'm new to JDeveloper and I would like to create a JSP Page with dynamic Selection List based on a runtime query or based on a view object (BC4J). The selection made by an user should serve another dynamic query with the necessary parameters that I built using createViewObjectFromQueryStmt(). By now I tried this using the InputSelectLOV from the Component Palette in JDeveloper. But without success. By the way: the selection list is not very large (5 values), so it's not necessary to have a form finding the desired value.
    Maybe someone had experience about creating this already. Please give me a tip or a little example.
    Thanks.

    http://otn.oracle.com/products/jdev/howtos/jsp/renderers.html

  • Selecting records based on user formula

    Post Author: Josh@RTA
    CA Forum: Formula
    I'm writing reports for a company that stores all of their dates as 8 digit numerical fields rather than a date or datetime datatype. I want to convert this field to a date type, then compare it to a parameter that stores user input as a date type.
    However, due to the way that Crystal does it's passes over the data, I can't use a selection formula based off of another formula. So I'm wondering , has anyone ever used a selection formula that references another formula and how have you been able to do it? Maybe use group selection instead of record selection? Just not sure.
    I'm including the formula I'm using to convert the date, as well as the selection formula so you get an Idea of what I'm doing.
    //This converts the numeric 'date' field to a dateshared stringvar DateString := totext({wotrans.ROP_TRAN_DATE}, 0, '');shared datevar ConvertedDate :=If {wotrans.ROP_TRAN_DATE} < 19590101 then Date (1959, 01, 01) else Date ( Val (DateString &#91;1 to 4&#93;),            Val (DateString &#91;5 to 6&#93;),            Val (DateString &#91;7 to 8&#93;) );
    //This is the select statement I'm using to compare the above formula to my parameter using record selection{@ConvertedTransDate} = {?TransDateRange}

    Post Author: SKodidine
    CA Forum: Formula
    Replace your formula with this and then equate it to your parameter value in your selection criteria and see if it will work.
    If {wotrans.ROP_TRAN_DATE} <= 19590101 then Date (1959, 01, 01)
    else
    date(
    tonumber(totext({wotrans.ROP_TRAN_DATE},0,'','')&#91;1 to 4&#93;),
    tonumber(totext({wotrans.ROP_TRAN_DATE},0,'','')&#91;5 to 6&#93;),
    tonumber(totext({wotrans.ROP_TRAN_DATE},0,'','')&#91;7 to 8&#93;));
    The process might be faster if you convert or change the data type of your parameter to numeric and then compare to the numeric date.

  • Select data based on status priority

    ID     PRO_ID     PRO_OBJ_ID     TASK_ID     DEVELOPER_ID     STATUS
    121243     4940     37506     5250     6532     REJECTED
    122063     4940     37506     5250     6532     CLOSE
    138306     4940     37506     5250     6532     ACCEPTED
    138307     4940     37506     5250     6532     WIP
    Hi,
    From the above table i need to select data based on status any status that is prior to CLOSE or ACCEPTED it must display all the status any status that is after CLOSE or ACCEPTED we must not consider.
    In the above scenioro it must display only the first three status. after ACCEPTED it must not display any thing
    Please suggest me a query how to write.
    Thanks
    Sudhir.

    Try:
    SQL> with t as (
      2  select 121243 id, 4940 pro_id, 37506 pro_obj_id, 5250 task_id, 6532 developer_id, 'REJECTED' status from dual union all
      3  select 122063, 4940, 37506, 5250, 6532, 'CLOSE' from dual union all
      4  select 138306, 4940, 37506, 5250, 6532, 'ACCEPTED' from dual union all
      5  select 138307, 4940, 37506, 5250, 6532, 'WIP' from dual union all
      6  select 138308, 4940, 37506, 5250, 6532, 'ACCEPTED' from dual union all
      7  select 138309, 4940, 37506, 5250, 6532, 'REJECTED' from dual union all
      8  select 121243, 4940, 37777, 5250, 6532, 'REJECTED' from dual union all
      9  select 122063, 4940, 37777, 5250, 6532, 'CLOSE' from dual union all
    10  select 138306, 4940, 37777, 5250, 6532, 'ACCEPTED' from dual union all
    11  select 138307, 4940, 37777, 5250, 6532, 'WIP' from dual union all
    12  select 138308, 4940, 37777, 5250, 6532, 'ACCEPTED' from dual union all
    13  select 138309, 4940, 37777, 5250, 6532, 'WIP' from dual
    14  ) -- actual query starts here:
    15  select t1.id
    16  ,      t1.pro_id
    17  ,      t1.pro_obj_id
    18  ,      t1.task_id
    19  ,      t1.developer_id
    20  ,      t1.status
    21  from   t t1
    22  where id <= (select max(id)
    23               from   t t2
    24               where  t2.status in ( 'ACCEPTED', 'CLOSED' )
    25               and    t1.pro_id = t2.pro_id
    26               and    t1.pro_obj_id = t2.pro_obj_id
    27               and    t1.task_id = t2.task_id
    28               and    t1.developer_id = developer_id
    29               );
            ID     PRO_ID PRO_OBJ_ID    TASK_ID DEVELOPER_ID STATUS
        121243       4940      37506       5250         6532 REJECTED
        122063       4940      37506       5250         6532 CLOSE
        138306       4940      37506       5250         6532 ACCEPTED
        138307       4940      37506       5250         6532 WIP
        138308       4940      37506       5250         6532 ACCEPTED
        121243       4940      37777       5250         6532 REJECTED
        122063       4940      37777       5250         6532 CLOSE
        138306       4940      37777       5250         6532 ACCEPTED
        138307       4940      37777       5250         6532 WIP
        138308       4940      37777       5250         6532 ACCEPTED
    10 rows selected.If that doesn't work then please provide us some representative sample data again.

  • Select records based on monthly anniversary date

    Hi,
    I have a table with a date_added field and I want to select records based on the monthly anniversary date of this field.
    eg. ID, Date_added
    1, 10-DEC-2012
    2, 11-NOV-2012
    3, 10-MAR-2012
    4, 28-FEB-2012
    5, 30-DEC-2012
    So For the 10th of Jan 2013, I would want to return records 1 and 3 only
    I started looking at the extract function, but this soon falls down for records at the end of the month. For example, on the 28th Feb, I would also want to include records where the date_added day is the 29th, 30th or 31st. So, in the table above I would want to return records 4 and 5, but extract would only return 4.
    Is there a simple function to do this month anniversary query - am I missing something very obvious? Or, do I need to write a query to explicitly cope with dates at the end of the month? So far I haven't found a sensible simple solution!
    I'm using 11g
    thanks

    I didn't look into leap year, but this should give you a starting point:
    select  *
      from  t
      where 1 = case last_day(to_date(:target_date,'mmddyyyy'))
                  when to_date(:target_date,'mmddyyyy')
                    then case
                           when to_char(date_added,'dd') >= to_char(to_date(:target_date,'mmddyyyy'),'dd')
                             then 1
                         end
                  else case
                           when to_char(date_added,'dd') = to_char(to_date(:target_date,'mmddyyyy'),'dd')
                             then 1
                         end
                end
    /For example, target date is 1/10/2013:
    SQL> variable target_date varchar2(8)
    SQL> exec :target_date := '01102013';
    PL/SQL procedure successfully completed.
    SQL> with t as (
      2             select 1 id,to_date('10-DEC-2012','dd-mon-yyyy') date_added from dual union all
      3             select 2,to_date('11-NOV-2012','dd-mon-yyyy') from dual union all
      4             select 3,to_date('10-MAR-2012','dd-mon-yyyy') from dual union all
      5             select 4,to_date('28-FEB-2012','dd-mon-yyyy') from dual union all
      6             select 5,to_date('30-DEC-2012','dd-mon-yyyy') from dual
      7            )
      8  select  *
      9    from  t
    10    where 1 = case last_day(to_date(:target_date,'mmddyyyy'))
    11                when to_date(:target_date,'mmddyyyy')
    12                  then case
    13                         when to_char(date_added,'dd') >= to_char(to_date(:target_date,'mmddyyyy'),'dd')
    14                           then 1
    15                       end
    16                else case
    17                         when to_char(date_added,'dd') = to_char(to_date(:target_date,'mmddyyyy'),'dd')
    18                           then 1
    19                       end
    20              end
    21  /
            ID DATE_ADDE
             1 10-DEC-12
             3 10-MAR-12
    SQL> And target date is 2/28/2013:
    SQL> exec :target_date := '02282013';
    PL/SQL procedure successfully completed.
    SQL> with t as (
      2             select 1 id,to_date('10-DEC-2012','dd-mon-yyyy') date_added from dual union all
      3             select 2,to_date('11-NOV-2012','dd-mon-yyyy') from dual union all
      4             select 3,to_date('10-MAR-2012','dd-mon-yyyy') from dual union all
      5             select 4,to_date('28-FEB-2012','dd-mon-yyyy') from dual union all
      6             select 5,to_date('30-DEC-2012','dd-mon-yyyy') from dual
      7            )
      8  select  *
      9    from  t
    10    where 1 = case last_day(to_date(:target_date,'mmddyyyy'))
    11                when to_date(:target_date,'mmddyyyy')
    12                  then case
    13                         when to_char(date_added,'dd') >= to_char(to_date(:target_date,'mmddyyyy'),'dd')
    14                           then 1
    15                       end
    16                else case
    17                         when to_char(date_added,'dd') = to_char(to_date(:target_date,'mmddyyyy'),'dd')
    18                           then 1
    19                       end
    20              end
    21  /
            ID DATE_ADDE
             4 28-FEB-12
             5 30-DEC-12
    SQL> SY.

  • Select list based on LOV - and allowing new values

    Hi All,
    I have a page that has a select list based on a dynamic list of values. I wanted to test out how the system was working, so I truncated all of my tables, and now my select list is blank (which makes sense). The problem is that I can't type anything into the select list. How can I make it so that if there isn't a value returned from the query that populates the LOV, I can just type one in? This also goes further in that if the value I wanted isn't already in the db, how does the user add in another value?
    Thanks in advance,
    Corey

    Hello,
    Well as you now know HTML based select lists don't work like that, that widget is called a combo box and there will be built in combo boxes in APEX 3.0, it's a fairly complex dhtml widget.
    What you might want to do is provide a text item next to your select box and an Add New Value Option in your select list.
    Carl

  • Select Product based on date

    Hai,
    Product Date
    pd0 2012-08-11 18:45:55.780
    Pd1 2012-08-11 18:55:17.020
    pd2 2012-08-11 19:06:58.623
    pd3 2012-08-18 12:00:01.193
    pd4 2012-08-25 12:13:04.077
    pd5 2012-08-25 17:28:30.347
    pd6 2012-08-25 18:23:16.473
    pd7 2012-09-18 18:29:58.360
    I want select the product based on from date and to date.
    For Example
    I want the select the product date in between 2012-08-11 to 2012-08-18
    Note:dont check the time.
    I want the query for select product based on only date not depend upon time

    >
    Product Date
    pd0 2012-08-11 18:45:55.780
    Pd1 2012-08-11 18:55:17.020
    pd2 2012-08-11 19:06:58.623
    pd3 2012-08-18 12:00:01.193
    pd4 2012-08-25 12:13:04.077
    pd5 2012-08-25 17:28:30.347
    pd6 2012-08-25 18:23:16.473
    pd7 2012-09-18 18:29:58.360
    I want select the product based on from date and to date.
    For Example
    I want the select the product date in between 2012-08-11 to 2012-08-18
    >
    Hopefully what you are calling 'Date', which is actually a timestamp value, is really being stored in a column of datatype TIMESTAMP and not being stored in a VARCHAR2.
    NEVER store date or datetime values in a character datatype. And the word BETWEEN, when used as an operator means that BOTH endpoints will be included.
    1. Data is stored in a TIMESTAMP column the way it should be stored
    WITH Q AS (SELECT 'pd0' PRODUCT, TO_TIMESTAMP('2012-08-11 18:45:55.780', 'YYYY-MM-DD HH24:MI:SS.FF3') myBadDateFormat from dual
    UNION ALL SELECT 'Pd1',TO_TIMESTAMP('2012-08-11 18:55:17.020', 'YYYY-MM-DD HH24:MI:SS.FF3') from dual
    UNION ALL SELECT 'pd2',TO_TIMESTAMP('2012-08-11 19:06:58.623', 'YYYY-MM-DD HH24:MI:SS.FF3') from dual
    UNION ALL SELECT 'pd3',TO_TIMESTAMP('2012-08-18 12:00:01.193', 'YYYY-MM-DD HH24:MI:SS.FF3') from dual
    UNION ALL SELECT 'pd4',TO_TIMESTAMP('2012-08-25 12:13:04.077', 'YYYY-MM-DD HH24:MI:SS.FF3') from dual
    UNION ALL SELECT 'pd5',TO_TIMESTAMP('2012-08-25 17:28:30.347', 'YYYY-MM-DD HH24:MI:SS.FF3') from dual
    UNION ALL SELECT 'pd6',TO_TIMESTAMP('2012-08-25 18:23:16.473', 'YYYY-MM-DD HH24:MI:SS.FF3') from dual
    UNION ALL SELECT 'pd7',TO_TIMESTAMP('2012-09-18 18:29:58.360', 'YYYY-MM-DD HH24:MI:SS.FF3') from dual)
    SELECT PRODUCT FROM Q
      WHERE myBadDateFormat BETWEEN TO_TIMESTAMP('2012-08-11', 'YYYY-MM-DD')
                                AND TO_TIMESTAMP('2012-08-18', 'YYYY-MM-DD')
    PRODUCT
    pd0
    Pd1
    pd2If you don't want the second endpoint included you need to use > and <= operators instead of BETWEEN.
    2. Data is stored in a VARCHAR2 column the way it should NEVER be stored
    WITH Q AS (SELECT 'pd0' PRODUCT, '2012-08-11 18:45:55.780' myBadDateFormat from dual
    UNION ALL SELECT 'Pd1','2012-08-11 18:55:17.020' from dual
    UNION ALL SELECT 'pd2','2012-08-11 19:06:58.623' from dual
    UNION ALL SELECT 'pd3','2012-08-18 12:00:01.193' from dual
    UNION ALL SELECT 'pd4','2012-08-25 12:13:04.077' from dual
    UNION ALL SELECT 'pd5','2012-08-25 17:28:30.347' from dual
    UNION ALL SELECT 'pd6','2012-08-25 18:23:16.473' from dual
    UNION ALL SELECT 'pd7','2012-09-18 18:29:58.360' from dual)
    SELECT PRODUCT FROM Q
      WHERE myBadDateFormat BETWEEN '2012-08-11' AND '2012-08-18'
    PRODUCT
    pd0
    Pd1
    pd2Neither of the solutions posted by others so far will work unless your data is stored in a TIMESTAMP column and even then Oracle will rewrite the filter to use TIMESTAMP values
    SQL> select product from test_timestamp
      2    WHERE myBadDateFormat < DATE '2012-08-18'
      3      AND myBadDateFormat >= DATE '2012-08-11'
      4  /
    Execution Plan
    Plan hash value: 3988574921
    | Id  | Operation         | Name           | Rows  | Bytes | Cost (%CPU)| Time   |
    |   0 | SELECT STATEMENT  |                |     3 |    54 |     3   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| TEST_TIMESTAMP |     3 |    54 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("MYBADDATEFORMAT"<TIMESTAMP'2012-08-18 00:00:00' AND
                  "MYBADDATEFORMAT">=TIMESTAMP'2012-08-11 00:00:00')
    Note
       - dynamic sampling used for this statement

  • Select List (based on LOV) query problem

    Hello experts! I have a small problem here, which I can't seem to overcome.
    I have a page item (select list based on LOV), which is based on a query. The query returns all potential employees of a department that are responsible for a certain duty. So far so good!
    The problem is that there are two departments, which should not only see there own employees but also the name of the employee that has carried out a certain task. However, due to my query, the name of that person is not displayed - only the pk is returned.
    Do you have a recommendation how I display all employees of a specific department and have additional values translated as well?
    My query is as follows: select str_bearbeiter, cnt_bearbeiter from vt_tbl_bearbeiter where cnt_bearbeiter in (SELECT
    CNT_REGIERUNGSBEZIRK FROM TBL_REGIERUNGSBEZIRK) union select str_bearbeiter, cnt_bearbeiter from vt_tbl_bearbeiter where int_behoerde in (SELECT
    CNT_REGIERUNGSBEZIRK FROM TBL_REGIERUNGSBEZIRK where STR_REGIERUNGSBEZIRK = lower (:app_user)) whereas :app_user holds the information of the department.
    Any hint is appreciated!
    Many thanks,
    Seb

    Okay, I just had the right idea and it's working well! Sorry for posting!
    I return the name of the employee that has edited a dataset and simply add all others of the logged on department! Really easy! Should have thought of that before posting! ;-(
    The correct code is select str_bearbeiter, cnt_bearbeiter from vt_tbl_bearbeiter a, vt_tbl_punktdaten b where a.cnt_bearbeiter = b.int_bearbeiter and
    inv_pt_id_sub = :P4_PTIDS
    union select str_bearbeiter, cnt_bearbeiter from vt_tbl_bearbeiter where int_behoerde in (SELECT
    CNT_REGIERUNGSBEZIRK FROM TBL_REGIERUNGSBEZIRK where STR_REGIERUNGSBEZIRK = lower (:app_user))Bye,
    Seb

  • Select query based on userinput

    Hi Folks...
    I posted this in another forum, but no reply,so I am posting it here too. I am trying to make a select query based on a user input. Earlier I was having probelms making a select query and printing out the result in the stack trace,with the advice given, I managed to solve that. I am now modifying that code to make a query based on user input, however it's not working, following is the code:
    String userId = request.getRemoteUser();  String sql = "SELECT hoursused FROM sysuser WHERE iduser = ?";    try      {        Connection connection = dataSource.getConnection();        PreparedStatement preparedStatement = connection.prepareStatement(sql);        preparedStatement.setString(1, userId);                ResultSet srs = preparedStatement.executeQuery(sql);                            while(srs.next()) {                          String hoursused = srs.getString("hoursused");                          System.out.println("The hours used are " + hoursused);    }                  }    catch (SQLException e)      {    e.printStackTrace();    }        } 
    stack trace seems to suggest I may have a probelm with this statement:
    "SELECT hoursused FROM sysuser WHERE iduser = ?"; 
    I am not sure how to rectify this, I hope someone can advise, thanks.

    Hi jschell..
    Thanks for responding, I appreciate it. The problem has been solved. No 'sysuser' is not a reserved word in Mysql. Based on the advice given in another forum and also from this site, I managed to solve the problem. I only made one change. This:
    ResultSet srs = preparedStatement.executeQuery(sql);     was changed to this:
    ResultSet srs = preparedStatement.executeQuery();  Thanks.

  • Select Query Based on date condition

    Hi ,
    Is it Possible.
    i want to run select query based on date condition.
    Eg...
    if the date between 01-jan-01 and 01-jan-05 then
    select * from table1;
    if the date between 02-jan-05 and 01-jan-08 then
    select * from table2;
    Becaz i have data in 2 diffrent tables , based on the date condition i wnt to run the select statement to diffrent tables.
    i dont want plsql here Just SQL needed.
    thanks,
    -R
    Edited by: infant_raj on May 5, 2009 11:48 PM

    Helo Kanish,
    this is not the one i was asking..
    wht i mean was .
    i use bind variable to get date while running the select statement , once i get the date then i want to choose any one of the table to run select query.
    EG..
    select col1,col2 from table1 where date between only if 01-jan-01 and 01-jan-05;
    select col1,col2 from table2 where date between only if 02-jan-05 and 01-jan-08;
    Run any one of the two . not all
    thanks,
    _raj                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for