Selection of records that are greater than the current week or

Hi I have a table with the table structure

CREATE TABLE OMPPRODUCTION
(
LOCATIONID VARCHAR2 (200 BYTE) NOT NULL,
IPC VARCHAR2 (200 BYTE) NOT NULL,
PRODUCTIONWEEK VARCHAR2 (200 BYTE) NOT NULL,
QUANTITY VARCHAR2 (2000 BYTE),
PRODUCTIONCODE VARCHAR2 (2000 BYTE),
MOULDQUANTITY VARCHAR2 (2000 BYTE),
VARCHAR2 (2000 BYTE) SOURCE,
VARCHAR2 (2000 BYTE) APPLICATION,
COMMENTS VARCHAR2 (2000 BYTE),
DATE OF TLM,
ADSTAT CHAR (1 BYTE),
SID NUMBER (10, 0),
SECURITYLEVEL VARCHAR2 (100 BYTE),
ENABLE CONSTRAINT PRIMARY KEY (LOCATIONID, CPI, PRODUCTIONWEEK) OMPPRODUCTION_PK
)

He has field PRODUCTIONWEEK that is to be given YYYYMMDD.

I want to select records that are starting the week underway (Monday as departure day).

for example, the date is 20120210 so I would choose the lines including the date more or equal to 20120206.

Can someone guide me how it is possible?

Published by: MaheshGx on 6 February 2012 16:16

MaheshGx wrote:
Select * from OMPPRODUCTION where to_number (to_char (to_date (productionweek, 'yyyymmdd'), 'WW')) > = to_number (to_char (sysdate, "WW"))

Wow, why so complicated?

You work with dates, so:

(a) why the hell you store dates in a column VARCHAR2? (and worse yet, why is 200 bytes of length)? Store dates as the DATE. The optimizer based on CSSTidy will thank you. As well, you know, you won't be wasting space.
(b) compare with the dates, not dates-converted dates - dates-converted-to-number numbers. Why do extra work when you have not to?

Since you're after weeks from Monday, I'd go for the format mask "IW", since it is fixed and will always return the Monday of the current week ("WW" could return Sunday or Monday, depending on what are your NLS settings.) I'd rather have my labour code for those who executes it, regardless of their NLS settings).

So, given the fact that your column is not the DATE data type, it would be more effective for you;

select *
from   ompproduction
where  trunc(to_date(productionweek,'yyyymmdd'), 'iw') >= trunc(sysdate, 'iw');

If you have an index on productionweek that you need help in this query, then I suggest to convert it to a basic index function.

Tags: Database

Similar Questions

  • Store the value less than the current week and the year.

    Hi all

    I have a table called BACK, which structure is like this
    ITEM_NUMBER   YEAR_WEEK   MS
    ...........   .........   ..
    1N58          2012-WK02   01/15/2012
    1N58          2011-WK02   01/15/2011
    current my procedure I store the value in my new table that is less than the current week. But I want to retain the value less than the current week and the current year. Please, help me to get how I can do this.
    PROCEDURE BACKLOG_PROC_LT_CW IS
      BEGIN
     DELETE BACKLOG_LT_CW;
     COMMIT;
          INSERT INTO BACKLOG_LT_CW
            SELECT 
                  DC_UTIL.GEN_YEAR_WEEK(MS) YEAR_WEEK,
                  ITEM_NUMBER,
                  MSD
    
                  FROM BACKLOG
              where to_char(MS, 'IW')<to_char(sysdate, 'IW');
    
      END BACKLOG_PROC_LT_CW;
    Currently, with the above code is to store the value in my table of BACKLOG_LT_CW but if you see the data in the table from the BACK you will find YEAR_WEEk 2012-WK02 falls next year, but again it is store in my table because IW took only. Please help me get the soln

    Thanks in advance

    Concerning

    Are you looking for this?

    ...
    where to_char(MS, 'YYYYIW')
    
  • give meaning to cases where minimum effective_start_date is greater than the current date

    Hi guys, I'm not a developer oracle as such, but I'm trying to get some information from oracle to send to other systems of the company, since we are dealing with oracle HRMS as the master system for employee information.

    In particular, we would like to create people in our training and the security system when they are created in oracle.

    I was told that the oracle per_all_people_f object acts as a slowly changing dimension of type 2, where a person can have several versions, which only is always the current version and the current version can be retrieved using the standard parttern of "date of current between the effective start date and actual end date. So far so good.

    However, I can see there are cases where the minimum 'effective_start_date' is greater than the current date. It is, indeed, equal to their start_date. I guess start_date represents "the first day of work" of the person.

    But this means then there is no "current" information known to people who have not yet really started working for the company again. This seems odd. How can I have someone for whom we have no information "currently correct? I was told that the effective_start_date of the line is automatically set to their "first day of work" date on which the information is entered into the system, IE, the user to enter information doesn't have the ability to say 'this is the current version of the data for that person, who starts at a date in the future. "

    For this reason, I cannot know these new people (who have been entered in oracle, but did not have actually to their first day of work still) training system. But we would obviously get people established in related systems so that they can use all of these systems on their first day of work.

    Have I misunderstood something here? How can there be no correct version for a person at the date and time?

    Hello

    How normally "inform you" the training system on a new person record? If it's a kind of report or an interface, it may be useful changed to examine a number of days in the future, for example + 7

    It is important to understand when you look at an Oracle HRMS instance through enforcement (i.e. the ' front end'), you look at the data on a date date (of the session) - by default, the date is the system date, but it is possible for a user to change this date to be in the future or the past as they see fit. The ability to implement the records in person in the future is a great feature to have, of course, but it must be understood that in this situation, at the date of the day the person's file logically does not exist yet from the point of view of the MFC features. Behind the scenes, however, in the per_all_people_f of the table, the line exist. Similarly, future update of changes to a person (e.g. marital status from Single to married) could be implemented, and the change in status would be visible if the session has been scheduled on a date or after the date of the marriage. As correctly observe you, behind the scenes, the table will hold all historic entries for this person_id with contiguous effective_start_date and effective_end_date beaches.

    Either way, date_start value is not related to as such hiring date; It is actually the value of effective_start_date earlier for the person_id. All changes, regardless of how many or what the effective_start_date is in each case, will always carry this same start_date value. It * may * be identical to the hiring date (certainly the fact that you configure their hire date person records would cause that), but if the person has been created as a postulant effective from 1 September and was then hired has effect from 21 September, column start_date value would be still 1 September. The record of the person would be visible when the current date is on or after this date - the only difference is that they show that an employee until the 21st.

    I hope this helps, but it is possible, that I just confused you more!

    Clive

  • I need to force the width of the columns to values that are smaller than the minimum preset (1 058 mm) indesign.

    Jongware provided two ideas to force the table rows and columns in the heights and widths smaller than the Indesign predefined 1.058 mm.

    For lines: app.selection [0] .properties = {autoGrow:false, height: "0.5 mm"};

    And for columns he sugested: app.selection [0] .width = "0.5 mm;

    The problem is that, while the code for lines works perfectly, for the columns return a error "Unit expected, but received 0.5 mm" I'm under Indesign cs6. Someone has ideas to help fixing such script, or maybe a different approach? Thank you!



    HM, other than the use of InDesign CS5.5 or underneath with scripts?
    Or export IDMS, open and edit (by script of course, it is just a plain text file in disguise), place IDMS and replace the table?

    (IDML as an alternative)

    Laughing out loud

    Uwe

  • The sum of several text boxes that are greater than 1

    Hello

    Relatively new to javascript and need to get a script that calculates the sum of the ten boxes of text with a value higher than 1.

    I have a script for counting, I'm not sure how to do the sum. Script is below.

    I'm sure it's pretty simple, but I'm not versed in this right now.

    var total = 0;

    for (var i = 1; i < = 10; i ++) {}

    If (Number (this.getField("Text"+i).valueAsString) > 1) total ++;

    }

    Total = Event.Value;

    Any help would be appreciated.

    It summarizes a number of fields by simply adding the value of the field to the variable used to accumulate the numerical values of the fields to be summarized...

    var total = 0;

    for (var i = 1; i)<= 10;="" i++)="">

    If (this.getField("Text"_+_i).value > 1) total = total + Number (this.getField("Text"_+_i).value).

    }

    Total = Event.Value;

  • How to print tiles that are smaller than the paper size

    I want to tile print a large image in several sheets of 11 x 17 using print tiling, but I want that the area of the image 10 x 10. In other words, I want to split my image into tiles of 10 x 10 print on paper 11 x 17. I'll shoot the paper after printing. I tried customizing the imageable area in the print settings, but the image 10 x 10 ends by stretched in the sheet 11 x 17. Is there a better way to do it?

    You can configure the work plans of 10 x 10 and have them throughout your work exactly how you want to print them.

  • You can remove some microsoft updates that are older than the recent updates that are being installed

    I need to know if I can remove old updates from microsoft after upgrades

    Thanks for any help I receive

    E-mail address is removed from the privacy *.

    NO, you cannot uninstall updates if the operating system has been updated because it would mean that another edition of Windows is now installed.

    MowGreen
    Expert in Windows IT Pro - consumer safety

    * - 343-* FDNY
    NEVER FORGOTTEN

  • How to reject records that are incompatible with the definition ODI 11 g data store?

    Buenas tardes.

    Como puedo girls los looking than any stupid fulfil the definition of length of atributos as hay in el data do not store? For example, in a process of integration llega a cuyo campo has a length of 50 characters first_name registro, pero base datos solo supports 40 characters. ODI in este falla y being the run y yo Necesito UN than rechace este registro y con continue the run. How I can control this event?

    Of photos muchas gracias.

    Hello

    Ah yes, I forgot about it.

    You can fool ODI by changing the logical length of the column in the data store in the model.

    In this way the I$ table will have a length of more than time and you won't have the problem.

    Kind regards

    JeromeFr

    PS: Your English is above the average on this forum, don't you worry. Most of us is not English-speaking.

  • Using GET_FILE RIDC, I am unable to download files that are greater than 2 GB in size. Help, please

    I am re-publication, as advised by the first time I asked this question.

    https://community.Oracle.com/thread/3674550

    Please let me know if I am wrong anywhere. Its working perfectly for 1.5 GB sized files.

    dataBinder.putLocal ("IdcService", "GET_FILE");

    dataBinder.putLocal ("dDocName", ucmBean.getdDocName ());

    dataBinder.putLocal ("RevisionSelectionMethod", "LatestReleased");

    ServiceResponse myServiceResponse = null;

    myServiceResponse = client.sendRequest (userContext, dataBinder);

    intReportedFileSize = myServiceResponse

    .getHeader("Content-Length");

    InputStream myInputStream = null;

    InputStreamReader myInputStreamReader = null;

    try {}

    myInputStream = myServiceResponse.getResponseStream ();

    String ucmFileName = ucmBean.getdDocName () + "."

    + ucmBean.getFileExt ();

    File = new File ("C:/UCMFiles /" + ucmFileName);

    OutputStream oos = new FileOutputStream (file);

    If the file does not exist, create it and then

    If (! file.exists ()) {}

    try {}

    file.createNewFile ();

    } catch (IOException e) {}

    Generative TODO catch block

    e.printStackTrace ();

    }

    }

    try {}

    myInputStreamReader = new InputStreamReader)

    myInputStream, 'UTF-8');

    OutputStream out = new FileOutputStream (file);

    Byte buf = new byte [1024];

    int len;

    While ((len = myInputStream.read (buf)) > 0) {}

    out. Write (buf, 0, len);

    intRetrievedFileSize += len;

    }

    out. Flush();

    out. Close();

    myInputStream.close ();

    totalSize += intRetrievedFileSize;

    } catch (IOException e) {}

    e.printStackTrace ();

    }

    The 11g RIDC JAR is backward compatible. Thus, I advise to use the last RIDC JAR from here: http://www.oracle.com/technetwork/middleware/webcenter/content/downloads/index.html

    Jonathan

    http://jonathanhult.com

  • Refine a query to display only the entries for the current week

    Hello.

    Anyone know how to change a query to display only those records that have dates of the current week? Records have a start date and an end date, so the query should recognize that the entry may be valid for more than one week?

    Kind regards

    swelch

    Hi Steve,.

    I just created a dataset that contained the periods before, during and after the current week - on the assumption that if any day of a range (start/end) falls within the current week so it is included.

    In my example this is 'today', June 25, 2011, and a week is defined as Sun - Sat. So my week of 'course' is u 19 June 2011 / I June 25, 2011.

    A line any with a start date before or during my 'current' week and an end date that is after or during my "current" week, i.e. no matter what date in its range included in the 'in progress' week will appear.

    See you soon,.
    Rob

  • Using package firmware level higher than the current version of UCSM?

    It's probably been asked before, but I couldn't find an answer.

    Can I download and use a blade firmware that is greater than the UCSM version?  For example, my UCSM is at version 2.2 (3d), but I want to install a package of 2.2(5b) blade firmware.

    Is this supported without first UCSM upgrading and interconnection of fabric?

    Hey, Walt,

    It is not supported so that your blades at a higher level than your infrastructure, so firmware you want to upgrade the UCSM/FI/IOM until you upgrade the blades. Here are some useful documents:

    http://www.Cisco.com/c/en/us/TD/docs/unified_computing/UCS/SW/firmware-m...

    You can use this cross reference your HW and SW to ensure they are compatible with one another:

    http://www.Cisco.com/Web/TechDoc/UCS/interoperability/matrix/matrix.html

    Let us know if you have any other questions.

    HTH,

    Wes

  • How to select and move more than one bookmark at a time? Shift + click selects multiple items that are next to each other in a list, because the element

    How to select and move more than one bookmark at a time?
    Shift + click selects multiple items that are next to each other in a list, because the items open in firefox before that happens.

    Glad it worked for you. Thanks for posting back.

  • Increment Dt start with day greater than the Dt at the end of the year Prev in Pro * C

    Morning people and greetings from Toronto.

    I'm trying to change a Pro * C program. Since ages I touched a Pro * C program but I have made an attempt for her. I would probably need some help andhopefully is the right forum I could nto seem to find any section decicated Pro * C programs.

    Here's what its supposed to do. I'm supposed to check if a Start Date of overlap between the start dates and dates from the end of the previous year, and if so, I'm supposed to assign one day Start Date greater than the Date of the end of the previous year.

    I have a control panel that stores records for start date and end Date for each year. Here's what I have for 2010.

    Start date = 8 May 2010 '; End date = may 12, 2011 'year =' 2010 From now the previous record in the table 1 (where the new record is supposed to be inserted) has a record that looks like this:
    DOC_ID     NAME               YEAR         START_DATE     END_DATE
    ------------------------------------------------------------------------------------------------
    999999     Mary Poppins      2009         03-May-2009      08-May-2010
    Now, based on the control table, the Start Date for 2010 coincides with the Date of the end of 2009. In this case, I would need to move the start date = may 9, 2010 "(Date of end + 1)

    Here is my ProC program in hand
    /* Include Headers */
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <ctype.h>
    #include <math.h>
    ---------------------------
    /* Define constants */
    ---------------------------
    #define  nullterm(string) string.arr[string.len] = '\0';
    /* SQL Host Variables */
    exec sql begin declare section;
    exec sql include sqlca;
    
     varchar   ctrl_start_date[11];
     short     ctrl_start_date_ind;
     varchar   ctrl_end_date[11];
     short     ctrl_end_date_ind;
    
     varchar   end_date[11];
     short     end_date_ind;
    
     int       exist_end_date_flag;
     short     exist_end_date_flag_ind;
    
    exec sql end declare section;
    
    
    /* Function Prototypes */
    
    void check_date_overlap();
    
    
    void main(int argc, char *argv[])
    {
    /* Coding starts here */
    
    void get_ctrl_dates()
    {
     exec sql
      select  to_char(trunc(ctrl_start_date),'YYYY/MM/DD'),
              to_char(trunc(ctrl_end_date),'YYYY/MM/DD')
      into    :ctrl_start_date :ctrl_start_date_ind,
              :ctrl_end_date  :ctrl_end_date_ind
      from    control_tb
      where   current_yyyy = :year_number;
    }
    
       check_date_overlap();
    
       if (strcmp( (char *)run_mode.arr,"N")==0)
       {
        check_date_overlap();
        create_person_rec(); /* This will insert record into person_tb table */
       }
    }
    
    /***********************/
    /* CHECK_DATE_OVERLAP  */ 
    /***********************/
    void check_date_overlap()
    {
    
     exist_end_date_flag = 0; /* assume he does not have a record */
    
     exec sql
      select count(*), end_date + 1
      into   :exist_end_date_flag exist_end_date_flag_ind,
             :end_date :end_date_ind
      from   person_tb
      where  doc_id = :doc_id
      and (( :ctrl_start_date between start_date  and end_date ) or
           ( :ctrl_end_date   between start_date  and end_date ) or
           ( start_date between :ctrl_start_date  and :ctrl_end_date ) or
           ( end_date   between :ctrl_start_date  and :ctrl_end_date ))
      and    year_number = (:year_number - 1)
      group by end_date
      having count(*) = 1;
    
      /*** Error Check Routine goes in here ***/
    
      /* Overlapping of dates; Set the Start Date equal End Date + 1 to avoid overlap */
      if (exist_end_date_flag == 1)
      {
       print_to_err_file("The Start Date is overlapping with a previous period.",0);
      }
    
       nullterm(end_date);
    
    } /* check_date_overlap */
    Here would be my question:

    My question is, should the SQL above be written like this instead?
    /***********************/
    /* CHECK_DATE_OVERLAP  */ 
    /***********************/
    void check_date_overlap()
    {
    
     exist_end_date_flag = 0; /* assume he does not have a record */
    
     exec sql
      select count(*), end_date
      into   :exist_end_date_flag exist_end_date_flag_ind,
             :end_date :end_date_ind
      from   person_tb
      where  doc_id = :doc_id
      and (( :ctrl_start_date between start_date  and end_date ) or
           ( :ctrl_end_date   between start_date  and end_date ) or
           ( start_date between :ctrl_start_date  and :ctrl_end_date ) or
           ( end_date   between :ctrl_start_date  and :ctrl_end_date ))
      and    year_number = (:year_number - 1)
      group by end_date;
    
      /*** Error Check Routine goes in here ***/
    
      /* Overlapping of dates; Set the Start Date equal End Date + 1 to avoid overlap */
      if (exist_end_date_flag == 1)
      {
        /* Is this even correct or would I have to do a strcpy?.
            Also note that I am overwriting ctrl_start_date which
            was fetched earlier in get_ctrl_dates() */
       ctrl_start_date = end_date + 1;
       print_to_err_file("The Start Date is overlapping with a previous period.",0);
      }
    
       nullterm(end_date);
    
    } /* check_date_overlap */
    Published by: Raj404261 on June 10, 2009 11:21

    You can put your code between the {code}

    As
    {code}
    your code...
    ...
    {code}

    SS

  • Problems loading a file in SkyDrive: "sorry, SkyDrive can't download files. Please download the files that are contained in the folder instead.

    Whenever I try to add a "xlsx" to "SkyDrive" document I get the following message:

    Sorry, SkyDrive can't download files. Please download the files that are contained in the folder instead. Neither I am able to drag and drop files in skydrive folder!

    I even tried as well to load it from the Office & do slip from the "Desktop" to the "SkyDrive" - but not of joy!

    Assistance would be greatly appreciated

    > Sorry, that SkyDrive impossible to download files. Please download the files that are contained in the folder instead.

    He tells you to OPEN the file, download the files on skydrive. BUR, NOT the FOLDER itself.

    You can download several files at the same time. How many? I'm not sure. I do not have more than 2 files both myself.

    SkyDrive limited maximum 50 MB each download.

  • Query to retrieve records that have more than one assignment_id

    Hello

    I'm writing a query to extract all records in the table per_all_assignments_f that has more than one different assignment_id for each person_id. Here's the query I wrote, it retrieves the records, even if a person_id assignment_id duplicate, but I need records that have more than one assignement_id without duplicate for each person_id

    Select assignment_id, person_id, assignment_id
    Of per_all_assignments_f
    Having count (assignment_id) > 1
    Person_id group, assignment_id

    Thank you.
    PK

    Maybe something like that?

    select *
    From   per_all_assignments_f f1
    where  exists (select 1
                   from   per_all_assignments_f f2
                   where  f2.person_id = f1.person_id
                   and    f2.assignment_id != f1.assignment_id
                  );
    

    Published by: SomeoneElse on May 7, 2010 14:23

    (you can add a SEPARATE from the outer query if you wish)

Maybe you are looking for

  • How can I change the title of the folder?

    Im trying to organize my notes and consolidate a bit, but I need different titles. I can't change the title even with edit. Also, is it possible to pass information from one folder to another?

  • Is there a way to backup/backup search engine?

    Is there a way to backup/backup search engine, I collect (used in the search bar of the extreme left) as I do so I can restore when I reset or reinstall the favorite browser?

  • Why open a new tab when I click on a page on google?

    When I click on a page in Google after the search it up through there, a new tab opens with the page and the Google tab remains. This does not happen on the start page of Mozilla.

  • Drive wireless HARD Canvio Aerocast 1 TB how to connect?

    Hi guys, when I turn on the hard drive and you are trying to connect it to my phone, it asks for a password and I looked over all the manuals and I don't know where this password is, if someone was able to find their own password somewhere, please te

  • Satellite L - Initial start-up, the time

    Hello I'm not very tech savyy so apologize if this is a stupid question! But I just bought my laptop today and the Quick guide installation explains that the initial start-up would take 2.5 hours and that the computer might restart several times duri