Extracting data from table using the date condition

Hello

I have a table structure and data as below.

create table of production
(
IPC VARCHAR2 (200),
PRODUCTIONDATE VARCHAR2 (200),
QUANTITY VARCHAR2 (2000).
PRODUCTIONCODE VARCHAR2 (2000).
MOULDQUANTITY VARCHAR2 (2000));

Insert into production
values ('1111 ', '20121119', ' 1023', 'AAB77',' 0002');

Insert into production
values ('1111 ', '20121122', ' 1023', 'AAB77',' 0002');

Insert into production
values ('1111 ', '20121126', ' 1023', 'AAB77',' 0002');

Insert into production
values ('1111 ', '20121127', ' 1023', 'AAB77',' 0002');

Insert into production
values ('1111 ', '20121128', ' 1023', 'AAB77',' 0002');

Insert into production
values ('1111 ', '20121201', ' 1023', 'AAB77',' 0002');

Insert into production
values ('1111 ', '20121203', ' 1023', 'AAB77',' 0002');

Insert into production
values ('1111 ', '20121203', ' 1023', 'AAB77',' 0002');

Insert into production
values ('1111 ', '20130103', ' 1023', 'AAB77',' 0002');

Insert into production
values ('1111 ', '20130104', ' 1023', 'AAB77',' 0002');

Insert into production
values ('1111 ', '20130105', ' 1023', 'AAB77',' 0002');


Now, here I want to extract the data with condition as

PRODUCTIONDATE > = the current week Monday

so I would skip only two first rows and will need to get all the lines.

I tried to use it under condition, but it would not give the data for the values of 2013.

TO_NUMBER (to_char (to_date (PRODUCTIONDATE, 'yyyymmdd'), 'IW')) > = to_number (to_char (sysdate, 'IW'))

Any help would be appreciated.

Thank you
Mahesh

Hello

HM wrote:
by the way: it is generally a good idea to store date values in date columns.

One of the many reasons why store date information in VARCHAR2 columns (especially VARCHAR2 (200)) is a bad idea, it's that the data invalid get there, causing errors. Avoid the conversion of columns like that at times, if possible:

SELECT     *
FROM     production
WHERE     productiondate     >= TO_CHAR ( TRUNC (SYSDATE, 'IW')
                          , 'YYYYMMDD'
                       )
;

Tags: Database

Similar Questions

  • Get the 500 error trying to create a table using the REST API

    Hello

    I tried to create a table using the REST API for Business Intelligence Cloud, but I got 500 Internal Server Error for a while now.

    Here are the details that I use to create a table.

    Capture.JPG

    and the json to create the schema that I use is

    [{'Nullable': [false], 'defaultValue': 'dataType' [null],: ['VARCHAR'], 'precision': [0], 'length': [18], 'columnName': ["ROWID"]}]

    , {'Nullable': [true], 'defaultValue': 'dataType' [null],: ['VARCHAR'], 'precision': [0], 'length': [18], 'columnName': ['RELATIONID']},

    {'Nullable': [true], 'defaultValue': 'dataType' [null],: ['VARCHAR'], 'precision': [0], 'length': [18], 'columnName': ['ID']}

    , {'Nullable': [true], 'defaultValue': 'dataType' [null],: ['TIMESTAMP'], 'precision': [0], 'length': [0], 'columnName': ['RESPONDEDDATE']},

    {'Nullable': [true], 'defaultValue': 'dataType' [null],: ['VARCHAR'], 'precision': [0], 'length': [255], 'columnName': ['RESPONSE']},

    {'Nullable': [false], 'defaultValue': 'dataType' [null],: ['TIMESTAMP'], 'precision': [0], 'length': [0], 'columnName': ['SYS_CREATEDDATE']},

    {'Nullable': [false], 'defaultValue': 'dataType' [null],: ['VARCHAR'], 'precision': [0], 'length': [18], 'columnName': ['SYS_CREATEDBYID']},

    {'Nullable': [false], 'defaultValue': 'dataType' [null],: ['TIMESTAMP'], 'precision': [0], 'length': [0], 'columnName': ['SYS_LASTMODIFIEDDATE']},

    {'Nullable': [false], 'defaultValue': 'dataType' [null],: ['VARCHAR'], 'precision': [0], 'length': [18], 'columnName': ['SYS_LASTMODIFIEDBYID']},

    {'Nullable': [false], 'defaultValue': 'dataType' [null],: ['TIMESTAMP'], 'precision': [0], 'length': [0], 'columnName': ['SYS_SYSTEMMODSTAMP']},

    {'Nullable': [false], 'defaultValue': 'dataType' [null],: ['VARCHAR'], 'precision': [0], 'length': [10], 'columnName': ['SYS_ISDELETED']},

    [{'Nullable': [true], 'defaultValue': 'dataType' [null],: ['VARCHAR'], 'precision': [0], 'length': [50], 'columnName': ['TYPE']}]

    I tried this using postman and code, but I always get the following response error:

    Error 500 - Internal server error

    Of RFC 2068 Hypertext Transfer Protocol - HTTP/1.1:

    10.5.1 500 internal Server Error

    The server encountered an unexpected condition which prevented him from meeting the demand.

    I am able to 'get' existing table schemas, delete the tables, but I'm not able to make put them and post operations. Can someone help me to identify the problem, if there is no fault in my approach.

    Thank you

    Romaric

    I managed to create a table successfully using the API - the only thing I see in your JSON which is different from mine is that you have square brackets around your values JSON where I have not. Here is my CURL request and extract my JSON file (named createtable.txt in the same directory as my CURL executable):

    curl u [email protected]: password UPDATED h x ' X-ID-TENANT-NAME: tenantname ' h ' Content-Type: application/json '-binary data @createtable.txt https://businessintell-tenantname.analytics.us2.oraclecloud.com/dataload/v1/tables/TABLE_TO_CREATE k

    [

    {

    'columnName': 'ID',

    'dataType': 'DECIMAL ',.

    'Length': 20,.

    "accuracy": 0.

    'Nullable': false

    },

    {

    'columnName': 'NAME',

    'dataType': 'VARCHAR ',.

    'Length': 20,.

    "accuracy": 0.

    'Nullable': true

    },

    {

    "columnName': 'STATUS."

    'dataType': 'VARCHAR ',.

    'Length': 20,.

    "accuracy": 0.

    'Nullable': true

    },

    {

    "columnName': 'CREATED_DATE."

    'dataType': 'TIMESTAMP '.

    'Length': 20,.

    "accuracy": 0.

    'Nullable': true

    },

    {

    'columnName': 'UPDATED_DATE ',.

    'dataType': 'TIMESTAMP '.

    'Length': 20,.

    "accuracy": 0.

    'Nullable': true

    }

    ]

  • Extract metadata check constraint using the JDBC driver

    Hello

    How to extract metadata check constraint using the JDBC driver?

    I know that by using the package dbms_metadata is possible, but the results of the get_ddl function are limited by the permissions of the user account, log on to oracle customer. So, how others pure Java implemented customer oracle can get the metadata of check constraints by using the same user account used to run the dbms_metadata.get_ddl function when this function cannot obtain metadata restrictions for approval when throwing an exception saying that the cheque does not exist?

    For example, in Aqua Data Studio and further implemented in pure Java metadata check constraints are extracted and showed in the Table Properties, but when I use the same user account in a java program using JDBC to execute dbms_metadata.get_ddl, an exception is throwed with a message that the constraint does not exist.

    So I guess that these pure-Java Oracle customers use Oracle JDBC driver to extract the metadata of check constraint (ddl or the status of the audit). If anyone knows how to use the Oracle JDBC driver to do this, please help me!

    SELECT *
    FROM all_constraints
    WHERE constraint_type = 'C';
    

    will give you all the validation constraints

  • Update a table using the clause

    Hello

    I want to update a table using the selected values.

    Cases in the sample:


    create table as empsalary)

    Select 1 as empid, 0 in the wages of all the double union

    Select option 2, the double 0);

    Data update are as follows

    with saldata as

    (

    Select 1 as empid, 5000 as wages, 500 as double pf

    Union of all the

    Select option 2, 10000,1000 like double pf

    )

    Select empid, salary saldata

    I tried the following query but does not work

    updated set of empsalary table (empid, salary) =

    (

    Select * from)

    with saldata as

    (

    Select 1 as empid, salary, 500 5000 as pf Union double all the

    Select option 2, 10000,1000 like double pf

    )

    Select empid, salary saldata

    ) sl

    where sl.empid = empsalary.empid

    )

    I use oracle 10g.

    Help, please.

    Krishna Devi wrote:

    Hello

    I want to update a table using the selected values.

    Cases in the sample:

    create table as empsalary)

    Select 1 as empid, 0 in the wages of all the double union

    Select option 2, the double 0);

    Data update are as follows

    with saldata as

    (

    Select 1 as empid, 5000 as wages, 500 as double pf

    Union of all the

    Select option 2, 10000,1000 like double pf

    )

    Select empid, salary saldata

    I tried the following query but does not work

    updated set of empsalary table (empid, salary) =

    (

    Select * from)

    with saldata as

    (

    Select 1 as empid, salary, 500 5000 as pf Union double all the

    Select option 2, 10000,1000 like double pf

    )

    Select empid, salary saldata

    ) sl

    where sl.empid = empsalary.empid

    )

    I use oracle 10g.

    Help, please.

    Thanks for posting creates table and test data.

    The error message would have helped because it's pretty obvious that this is the problem:

    Update table empsalary

    *

    ERROR on line 1:

    ORA-00903: invalid table name

    Just remove the word "table".

  • Is API available in Acrobat for extracting text from images using c#

    Is API available in Acrobat for extracting text from images using c#

    Thank you for your response. Acrobat is not appropriate for this task, because it is technically suitable or licensed for the server.

    Adobe have a PDF library which allows extraction of text for C/C++, but it does not OCR. There are OCR of the LiveCycle PDF Generator Server product, but I don't think that does OCR on a PDF file.

    Sorry not to have better news.

  • Creating external Tables using the EXECUTE IMMEDIATE in PL/SQL

    Hi guys,.

    I am trying to create an external Table using the EXECUTE IMMEDIATE in a procedure and I managed to compile and no errors were generated. But when I try to run it from sql using the exec command I get the following error:

    ------------------------------------------------------------------------
    ERROR on line 5:
    ORA-00911: invalid character
    ORA-06512: at "GEO. TEST_DDL', line 4
    ORA-06512: at line 5

    -------------------------------------------------------------------------

    I tried to check the whole statement to create the external table, but I can't find where is the error. Surprisingly, if I simply run the command table create external on sqlplus it works, but not a procedure.

    If anyone can help with ideas or experience?

    Geoffrey Kossami

    The error means that there is an identifier somewhere that starts with a nonalphanumeric. This is a typical mistake of editing. A procedure compiles correctly is not of course because the underlying dynamic sql running is OK. Which of course only be resolved when you try to run it.

    There is certainly a problem with the text you provide to be run as a piece of dynamic sql code. You should try to watch it with dbms_output and run this code in sqlplus. But your problem is with the code you run as dynamic PL/SQL, it is not itself compilable.

    Jack

  • use restart from scratch using the option "ALT F10" and lose everything. Help, please!

    Whenever I try to connect my laptop, a screen invites me to do a repair of launch set-up. It goes through the motions for ten minutes and the screen turns white. The only way I can get at all is to restart all from scratch using the option "ALT F10" and lose everything. Any advice I would really appreciate.

    Hello

    1. Since when are you facing this problem?
    2. You did any recent changes?
    3. What version of Windows is installed on the computer?

    I suggest that you go into recovery options and try to perform system restore and see if it helps:
    http://Windows.Microsoft.com/en-us/Windows7/what-are-the-system-recovery-options-in-Windows-7
    http://Windows.Microsoft.com/en-us/Windows-Vista/what-are-the-system-recovery-options-in-Windows-Vista

    Otherwise, I suggest you to give us more information, so that we can better help you.

    It will be useful.

  • Smart card reader does not correctly connect once the virtual machine is restored from sleep using the vmrum controls

    Smart card reader does not correctly connect once the virtual machine is restored from sleep using the vmrum controls

    Scenario is,

    1. smart card reader is connected to the VM with card inserted in

    2 initiate a prompt suspension of the VM toolbar

    3. now to resume the virtual machine by using vmrun command into the host machine

    WS t vmrun start xxx.vmx

    Now, the recovery of VM but the smart card reader that was previously connected does not work properly in VM that is to say, sometimes after CV chip card reader driver is uninstalling and a few other times, chip connected to the drive is not available on a virtual computer

    My requirement is after power, smart card reader can stay connected to the virtual computer with the already installed driver and the smart card.

    Kindly help with this problem.

    Host operating system: Victoire 2012 R2

    The VM OS: win 10 x 64

    Thank you!!

    Dear all,

    I had a work around for this problem. By adding "usb.autoConnect.device0 ="0xVID:0xPID"" this statement to the VMX file, solves this problem, that is, whenever the VM is wake-up by clicking on the link CV or using vmrun commands, it connects the unit in question automatically and it is charging correctly with his driver. Obtaining smart card detected after sleep\hibernate with no problems.

    VID & PID is respective ID of the device that can be seen in the properties of the Device Manager "Device Instance path".

    For more information about this, visit VMware KB: automatic connection of USB devices to the virtual machine power on

    ~ Surendra

  • Inserting data in several related tables using the database

    Hello world
    I'm working on a BPM application using Oracle BPM 11.1.1.5.0 and JDeveloper 11.1.1.5.0.

    In my database, I have two tables, loan and guarantee that are related by a field named employeeID (PK on loan) and FK in warranty.
    Each line can have several lines of guarantee.

    At this point, I'm doing an entry form for the user to insert data in the two tables.

    I did successfully before with a single table that has no relations.

    The way I'm doing here is, after the creation of the database successfully adapter, a type of LoanCollection is created in the types module, which can be used to create business objects and data objects of.

    The problem is when I create an object of type loanCollection process data and then create a UI generated automatically on that basis, only the fields in the primary table (the Table of loan) appear in the form.
    On the other hand, if I create a business object based on the LoanSchema, the form for all of the two tables is created automatically (the loan as a form, the guarantee in a table), but then, when I try to access it in the section processing service mission which calls the database adapter, I have no access to such.
    In fact, the only type which can be used in the service task is the process based on the loanCollection data object.

    To summorize, I have to use the type of business for my UI object to include all the fields in both tables, so I have to use the data object from the collection process in the transformation of service task dialog box.
    And I can't find a way to map to another.

    Can someone help me with this please?
    Thank you very much

    Try to follow these steps.

    1. create a new module in your catalogue our BPM project management section
    2. in this new module create 3 Business Objects - (LoanBusinessObject, GuaranteeBusinessObject and GuaranteeArrayBusinessObject)
    3. Add the attributes appropriate to the LoanBusinessObject and the GuaranteeBusinessObject so that they mimic your database tables, then to the GuaranteeArrayBusinessObject add an array of type attribute GuraranteeBusinessObject
    4. now you need to create two process data objects, type loanProcessObject LoanBusinessObject and type guaranteesProcessObject GuaranteeArrayBusinessObject
    5. as inputs to your human task adds the loanProcessObject and guaranteesProcessObject, these should now be available in your data controls and can be used to auto generate the form
    6. in your dbadapter you'll then use XSL Transformation and use for each so that it will write the data to the ready table and all the line items of warranty for the warranty table.

  • Build the value of 100 mb of data in the table using the loop

    DB version: 11.2

    How can I create about 100 MB of test data in a table using minum number of records.
    If I use the below for loop. It takes 100,000 records to fill only 2 MB.
    SQL> create table a2 (mynum1 number, mynum2 number);
    
    Table created.
    
    begin
    for i in 1..100000 loop
        insert into a2 values(i,i*2);
    end loop;
    end;
    
    
    select segment_name, bytes/1024/1024 MB from dba_segments where segment_name = 'A2' AND owner='SCOTT'
    
    
    SEGMENT  BYTES/1024/1024
    -------- ---------------
    A2                     2

    Hello

    Is that what you are looking for?

    SQL> CREATE TABLE tbl1(c1 CHAR(1024));  -- ~1KB per row
    
    Table created.
    
    Elapsed: 00:00:00.00
    SQL> INSERT /*+ APPEND */ INTO tbl1 SELECT 'X' FROM dual CONNECT BY LEVEL < 100000; -- 100K rows * 1KB = 100MB + some additional overhead
    
    99999 rows created.
    
    Elapsed: 00:00:13.02
    SQL> SELECT bytes/1024/1024 MB FROM user_segments WHERE segment_name = 'TBL1';
    
            MB
    ----------
        113.75
    

    Lukasz

  • expdp + query option to export from several tables with the same condition

    Hello

    We want to export a subset of data only from databases to another. Both on AIX.

    Source/testdatabase 11.2.0.3 (non partitioned tables)
    Target productiion 11.2.0.3 database (separate tables)

    Tables of same names of columns but diffrenet structures a partitioning index and traget so only want to import content

    Each source datbaase hascolumn seq number table and want only to extract the last months of data.


    TABLES:table1,table2...
    DUMPFILE=dump_dir
    CONTENT=data_only
    QUERY= table1:"WHERE seq_num >100 "
    want to use expdp but not sure how to make sure that all tables have the seq_num WHERE > 100 condition, if let table1: go out and have just
    QUERY = "WHERE seq_num > 100"this condition would apply to all tables that we want."


    I'm assuming that can also use impdp CONTENT = data_only?

    Any ideas/thoughts?

    Thank you

    QUERY = "WHERE seq_num > 100"this condition would apply to all tables that we want."

    Yes, it will work for all tables, but ensure that all exported table must include this column.

    QUERY
    Default: no
    Goal
    Allows you to filter the data that is exported by specifying a clause of a SQL SELECT statement, which is applied to all tables in the work of export or a specific table.

    The query_clause is usually a WHERE clause for the selection of refined lines, but could be any SQL clause. For example, an ORDER BY clause can be used to accelerate a migration from a table in a heap in a table held in index. * If a [schema]. table_name is not provided, the query is applied to (and must be valid for) all tables in the export job.*

    http://docs.Oracle.com/CD/B19306_01/server.102/b14215/dp_export.htm

  • Excerpt from my table using the loop For

    Hello

    I have this loop to create a 2D array. The result is on the table below. I want that this 2D table should be fully completed and compiled, then it will be sent out of the loop.

    I don't want to extract the value of table 2D is a loop. This is the problem that I am facing.

    My ultimate goal is to extract the individual number of the final table of the 2D table line and be an entry for other functions.

    Please help me. Thank you

    PX

    Hi PX.

    Here's a solution without using screw express

  • Conditional binding fails with fracture from scratch using the fluent API

    I have two properties that I want to connect to a progress bar. Properties represent essentially a max value of County (the denominator) and current value of the Shire (numerator). I want to set up a connection using the fluent API that works roughly as follows:
    IntegerProperty numerator = new SimpleIntegerProperty(0);
    IntegerProperty denominator = new SimpleIntegerProperty(0);
    
    progressBar.progressProperty().bind(
        Bindings.when(denominator.isEqualTo(0))
            .then(0)
            .otherwise(numerator.divide(denominator)));
    The numerator and denominator properties represent two properties in my object that changes according to certain criteria in the application, and I want the progress bar to be bound by these changes. The problem is sometimes, and by default, the value of the denominator is 0. My logic tells me that the clause otherwise() does not run, because the when() condition must be true and so run the then() clause. When I run the above code, I get an ArithmeticException (/ by zero).

    Question - is this the correct behavior of the code underlying link? I don't understand why the otherwise() clause is being evaluated in this case.
    Can I suggest an improvement to short-circuit the logic to avoid such a situation?

    My solution is to create a custom as follows DoubleBinding:
    IntegerProperty numerator = new SimpleIntegerProperty(0);
    IntegerProperty denominator = new SimpleIntegerProperty(0);
    
    DoubleBinding db = new DoubleBinding() {
        { super.bind(numerator, denominator); }
     
        @Override
        protected double computeValue() {
            if(denominator.getValue() == 0) {
                return 0.0;
            }
            return numerator.doubleValue() / denominator.doubleValue();
        }
    };
            
    progressBar.progressProperty().bind(db);
    I would much rather the fluent API (much less code to write and much more elegant), but I'm glad that the custom binding is not too difficult to write and understand.

    Thanks for all comments or impressions.

    I have not tested, but for a workaround, you can try

    progressBar.progressProperty().bind(
        Bindings.when(denominator.isEqualTo(0))
            .then(0)
            .otherwise(numerator.divide(denominator.doubleValue())));
    

    This will force (should) the division must be calculated using double rather than the integers (ints); x / 0,0 will assess double. NaN in java, without throwing an exception. Note that this calculation will give slightly different results in other cases, such as the division of integers you used before will still result in an int (by truncation); considering that it will give a double precision division. In most cases, the latter will actually be what you want.

  • Loading SQL tables using the rules file

    Hi Experts,

    I have a doubt. In our project, we have a maxl command that imports the essbase data cube using tables sql below.

    import data from database VodaPln.wrkforce

    log in as 'devhyp' identified by 'password' using the rules_file «WFDataLoad.rul» Server

    My doubt is here in this maxl, we define the schema and password name ('devhyp' identified by 'password'( ), but we do not give the name of the table. So, how will the maxl understand what table to extract the data. Please let me know in case I'm missing something and need to check out somewhere else.

    Thanks and greetings

    The actual SQL statement is in the State of charge, IT will set the columns, tables where the conditions and joins. The first parameter is the name of user who may or may not be the schema name. This information is containd in the State of charge, but also an ODBC or CLI connection

  • "missing the SELECT keyword" error during an insert into the temporary table using the blob value

    I'm trying to insert into an oracle temp table using select that retrieves data from a blob field but I get the error: "lack the SELECT keyword.

    How we store temporary in oracle result when we make this type of operation (extraction of data in fields and try to load them into a separate table on the fly.?)

    with cte as)

    Select user_id, utl_raw.cast_to_varchar2 (dbms_lob.substr (PREFERENCES)) as USER my_blob

    )

    create table new_table as

    SELECT user_id,EXTRACTvalue(xmltype(e.my_blob),'/preferences/locale') regional settings

    E ETC

    ----------------------------------------------------------------------------------

    BLOB data - value - which is

    <? XML version = "1.0" encoding = "ISO-8859-1" ?>

    - < Preferences >

    < time zone > America/New_York < / > zone

    < displayscheduleinusertimezone > Y < / displayscheduleinusertimezone >

    < local > Spanish < /locale >

    < DateFormat > JJ/mm/aaaa < / DateFormat >

    < timeFormat > hh: mm aaa < / timeFormat >

    < longformat > Long_01 < / longformat >

    < doubleformat > Double_01 < / doubleformat >

    < percentformat > Percentage_01 < / percentformat >

    < currencyformat > Currency_01 < / currencyformat >

    < / Preferences >

    A WITH clause that must immediately precede the SELECT keyword:

    SQL > create table t:

    2 with the o as (select double dummy)

    3 select * West longitude;

    Table created.

Maybe you are looking for

  • Tecra A11 - 113 - white screen and the cursor of the mouse during the boot

    Hello My Toshiba Tecra A11-113 with win 7 32 bit boots with a mouse cursor and the visible white screen.I tried to start under different boot options. Mode, safemode, last repair job configurationand msdos command only... all these startup options gi

  • HP 15-do51ea: Power DVD stopped working

    I used to watch the DVD movie on my laptop. I had problems with the help of Internet Explore. I reinstalled windows 10. DVD movie has stopped working since then. What should I do?

  • My sound has stopped playing and I can't understand why!

    I can absolutely NO sound on my PC. All connections and cables seem to be correct! Everything started at the time I had the shop, but they say they are innocent!

  • CONNECT E-MAIL TO VISTA

    I just changed from XP to VIST.  I have always used Outlook Express.  Now, I get no e-mail at all.  How to connect a program under VISTA so I can get my email address? Help: Lonesome Polecat II

  • printing, stopped by error message intermittently

    More recently, the impression of the process stops and an error pops up.  "to avoid damage to the close button.  do not use taken to stop. "I've made no attempt to stop and did not part any printer.  I have check all cables and taken - everything is