Cast to date

Hello

I recently saw this particular query where a varchar is converted to date.

SELECT Date "' 2013-01-01 to double;

The query runs successfully and gives the following result.

DATE OF 2013'

---------

JANUARY 1, 13

I thought that he is a way of casting in SQL that I wasn't aware of... but if that's true, then it should work too

SELECT INTEGER ' 1203 "twice;

SELECT VARCHAR2 112 of double;

SELECT FLOTTER 102 of double;

but all this failed with the error missing expression.

Can someone please explain this to me. I tried Google but cannot find good information anywhere.

I thank you all.

Ruhu

SomeoneElse is correct, it is a way to specify a date literal and the string must be in the format YYYY-MM-DD (and should not be components).  This does not mean it is equivalent to other types of data well (except TIMESTAMP and INTERVAL that are not literals).  If you want to mount other types of data, you must use the appropriate TO_CHAR, TO_NUMBER, TO_DATE etc. functions, or the CAST function.

Tags: Database

Similar Questions

  • table (cast - invalid data type problem

    Hi all

    Baseline scenario:

    --------------------------
    PACKAGE
    --------------------------
    create or replace
    PACKAGE C2_PAYMENT_DOC IS

    Bin_array TYPE TABLE IS NUMBER
    INDEX OF DIRECTORY;

    FUNCTION test_fun (l_doc_id IN integer) RETURN bin_array;
    --------------------------
    PACKAGE_BODY
    --------------------------
    create or replace
    package C2_PAYMENT_DOC as body

    Bin_array test_fun (l_doc_id-IN integer) FUNCTION RETURNS IS
    l_gross bin_array;
    Start
    c2_purchase_invoice.get_inv_gross_amount (l_doc_id, l_gross (1));
    Return l_gross;
    end;
    END;
    --------------------------
    QUERY
    --------------------------
    Select * from Table (Cast (c2_payment_doc.test_fun (1) as bin_array));

    The query result is ORA-00902: invalid data type
    How can I make the valid select statement?
    Thanks in advance,
    Bartek

    You cannot use local collection types in SQL. You must create a bin_array of type like nested SQL table type. In addition, depending on the version you will not cast:

    SQL> CREATE OR REPLACE
      2    TYPE bin_array
      3      AS TABLE OF NUMBER
      4  /
    
    Type created.
    
    SQL>  create or replace
      2   PACKAGE C2_PAYMENT_DOC IS
      3  FUNCTION test_fun(l_doc_id IN integer) RETURN bin_array;
      4  end;
      5  /
    
    Package created.
    
    SQL> create or replace
      2  package body C2_PAYMENT_DOC as
      3
      4  FUNCTION test_fun (l_doc_id IN integer) RETURN bin_array IS
      5  l_gross bin_array := bin_array();
      6  begin
      7      l_gross.extend;
      8      l_gross(1) := l_doc_id;
      9  return l_gross;
     10  end;
     11  END;
     12  /
    
    Package body created.
    
    SQL> select * from Table(Cast(c2_payment_doc.test_fun(1) As bin_array));
    
    COLUMN_VALUE
    ------------
               1
    
    SQL> select * from Table(c2_payment_doc.test_fun(1))
      2  /
    
    COLUMN_VALUE
    ------------
               1
    
    SQL> 
    

    SY.

  • Casting to a type of data

    In order to cast a data in another type, which is the difference between the use of functions like TO_NUMBER TO_CHAR,... and using the CAST function AS? Thank you!

    Cast can be used with collections
    say you want to convert a set of values in a collection that is not possible by to_number or To_char

    for example:

    SELECT CAST(MULTISET(
        SELECT object_name, object_type
        FROM user_objects
        WHERE rownum <10) AS collection_type)
      INTO collection_type
      FROM dual;
    
  • Simulink Inport/Outport data types

    I searched for a while and I am unable to find documentation about what types of data I need to use the inports, outport, settings and in my Simulink models.

    Is there some specific types of data that are, or are not supported?  How VeriStand to determine how to coerce data to send the model?  Also, I was under heard VeriStand uses doubles for everything but then I saw a post that says he uses of I64.

    Any clarification would be much appreciated.

    VeriStand 2013 SP1 (probably upgraded to 2016 in next year if it's relevant)

    MATLAB 2010 b and MATLAB 2012 b (currently)

    > Are there types of specific data that are, or are not supported?

    I don't remember there being any limitation of types beyond what is stated in the considerations help document.

    Considerations relating to the integration of The MathWorks, Inc. Simulink® software models (model Interface T...

    The big hiccup I remember wasn't mainly with types of configurations and data bus.

    IIRC, you can choose any numeric type desired in Simulink. The structure of the model interface that uses VeriStand will handle any type and convert it to double so that it can be consumed by the VeriStand engine.

    > How VeriStand to determine how to coerce data to send the model?

    I think the way it works is that when VeriStand interacts with the Simulink model, it gets a list and information (pointer, data type) of inports, remote villages and settings. Thus, it can capture data from the model (because it has the pointer), and it can cast its data type (because he knows the type) duplicate. If you look at the example model model interface on line 212 it might help to make things more clear on how this could work.

    C:\VeriStand\2016\ModelInterface\custom\examples\template.c

    Double USER_GetValueByDataType (void * ptr, int32_t subindex, int32_t type)
    {
    switch (type)
    {
    case 0:
    {
    / * double * /.
    (double) return (((double *) ptr) [subindex]);
    }
    case 1:
    {
    / * only * /.
    (double) return (((float *) ptr) [subindex]);
    }
    }

    / * return NaN, ok for vxworks and pharlap * /.
    uint32_t nan [2] = {0xFFFFFFFF, 0xFFFFFFFF};
    return *(double*) nan;
    }

    I'm guessing that the full implementation of which uses VeriStand is much more complex, but I think that the idea is the same.

    > Also, I was under heard VeriStand uses doubles for everything but then I saw a post that says he uses of I64.

    VeriStand engine uses indeed of all double rooms.

    You happen to remember this post and you can share the link? I'd be curious to see where this is said and in what context.

  • Data of Downcasting DMA from U8 to U16

    Hello world

    I have a situation that I hope someone can shed some light on. Currently I have a FPGA design that collect data highspeed made some treatment on it and spits the results on DMA to read out and record the host TDMS files. Currently I read 4MB worth of data the DMA I16 every 25-30 ms, the current design is able to keep up with the flow of data very well. My next task is to allow the FPGA to collect the same type of data, with the same treatment, only provide data at the I8 format, which means one of the following design decisions:

    1 - keep the FPGA code/FW and cast of I8 data on the host side.

    The disadvantage of the first option is the high data rate. I did a stable mark with a couple of different methods to do the I16 to I8 cast (number of Split, I8 cast and Typecast). Needless to say that the Typecast was too slow for my operations on average about 35-40 ms to mount the 4 MB with a value of information I16 to I8. The number of split and I8 mount both came with an average time of about 15ms, but with a maximum time of 23 Ms. these time were obtained with a system with a load very little, which is not the case on the final design.

    2. develop/compile a new FPGA VI that does the same exact except convert data into I8 on the FPGA and send on a defined DMA with the data type I8.

    The drawback here is that he had to maintane two versions of the FPGA code as well as two versions of the driver code, it's like the DMA used to transfer the data changed I16 to I8 data type that prevents me from using a dynamic refrence when using with the FPGA.  I also use all available DMA channels on board so I can't declare the I16 and I8 DMAs and read one on the driver's side.

    My question is, is there an inexpensive way to make the cast operation on the host side? It has been mentioned that LV FPGA use U64 to transfer the data internally and only casting for the necessary type of data at the end, is it possible to take advantage of this operation to get it to cast a data type different from the driver's side, if this is true? If not is there a fourth method of doing the casting which is cheaper? other ideas are welcome.

    Sorry for the long post.

    Update your FPGA to be configurable either Pack I16s or I8 in its flow DMA, in this way, you have an FPGA to maintain and you have a flow reduced by the configured I8 FPGAs (i.e. half of the DMA values must be sent).  Send your DMA values to always be a multiple of I16, so you can easily Pack and unpack once they get in the TDMS files.  The side host always receives the same element (e.g., I16) DMA and doesn't really care that in some cases, it contains two I8s.

  • Dial the node library with cluster table feature using the pointer of table data

    Hi all.

    I am writing a wrapper of LabVIEW for an existing DLL function.

    The service was, as one of its parameters, an array of structures.  The structure is very simple, containing two integers.  I use the call library function node to access.

    In Labview, I created an array of clusters, when the cluster has two integers of 32 bits as members.  So far so good.

    Now, I have to pass this in the node library function call.  I use here in trouble.

    I used the LAVA so the topic in the knowledge base as my main sources of information, although I read a lot of topics in the forum on the subject too.

    I don't understand I could write a new function that takes as a parameter a struct with the size as the first member and an array as the second, and I might just do this and do call the regular service, but I was hoping to do more simply.

    The file function C LabVIEW generates for me the COLD Lake when I choose "To adapt to the Type" and "Data in the table pointer", the prototype he expects is:

    int32_t myFunc (handful of uint32_t, uint16_t channel,
    int32_t FIFOnumber, Sub data [], int32_t numWords, int32_t * actualLoaded,.
    int32_t * actualStartIndex);

    And the prototype of the function in my DLL is

    int myFunc borland_dll (DWORD channel, channel of Sina,)
    FIFOnumber int, struct mStruct * data, int, int numWords * actualLoaded, int * actualStartIndex);

    It sounds like a match for me, but it doesn't work (I get garbage in the data).  The topic referenced above LAVA, I realized it would work.  This isn't.

    If I have to cast the data to the pointer-to-pointer I get when I generate c code in my wiring to a CIN struct and by generating, then I seem to get what I expect. But it seems to work when I choose "pointers to handles" too, and I'm expecting data table pointer to give a different result.

    Is it possible to get it works directly, or I have to create a wrapper?  (I am currently using LabVIEW 2011, but we have customers using 2009 and 2012, if not other versions as well).

    Thank you.

    Batya


  • How to get 4 months of sales data

    Hello guys

    I have the Sales table

    Time by the month sales management

    201501 10 100

    201502 10 20

    201503 10 90

    201504 10 90

    Acually I found this formula Time.Date < = cast (current_date- date) and Time.Date > = TIMESTAMPADD (SQL_TSI_MONTH,-3, TIMESTAMPADD (SQL_TSI_DAY, DAYOFMONTH ( CURRENT_DATE) *-(1) + 1, CURRENT_DATE))

    My question: is it for using the DATE, in fact, my time dimension is working hour per month? Current_date can be replaced by @{pvMonth} {2015-05}.

    You cannot directly replace CURRENT_DATE (a date object) with @{pvMonth} {2015-05} because it is just a piece of text, not a date. So you must first create your varchar date and then you can use in date/time formulas.

  • Create a join between a column of type DATE and DATETIME RPD

    Hello

    In my DR. I have a fact table with a DATE column, which also contains a component "hour". The physical layer shows this as a DATETIME column that to this DAY, I've changed since I'm only interested in the part of the date.

    When I join it an alias of my Date dimension, the generated sql physics is similar to:

    DIM_DATE. DATE = FACT_A.FINISH_DATE

    What I really want is:

    DIM_DATE. DATE = TRUNC (FACT_A.FINISH_DATE)


    How can I achieve this at the level of the RPD? Yes, I can add a new column to the table of DW with truncated value, but I want to know why even though I chose the DATE as the type of data to the RPD, the created join does not have a trunk.


    Thank you


    Manish

    The physical layer shows this as a DATETIME column that to DATE, I have changed since I was only interested in the part of date.

    N ° bad idea. The physical layer of the RPD should show what the physical source. So if it isn't a DATE, don't pretend OBIEE is it. For the exact reason that you now - tap you are pregnant OBIEE to write some SQL magic to cast the data type, without even say things which is the original type. OBIEE will not interrogate the metadata in order to check the data types in the source, it will rely on what you tell it in the physical layer.

    How can I achieve this at the level of the RPD?

    You could use an inline view in the physical layer and make your trunc here I guess. Better, as you've already identified, is to store the date as a date if this is going to be a key column to reach.

    I want to know why even though I chose the DATE as the type of data to the RPD, the created join is not a trunk.

    See above. OBIEE does not know it is a DATETIME value, then why would he do a TRUNK?

  • Type erasure and relationship of cast.

    By shaving part of the erasure of the type of the document java tutorial (effects of Type erasure) and methods of bridge, I saw the code example below.

    public class {Node < T >

    public T data;

    public Node (data T) {this.data = data ;}

    {} public void setData (data T)

    System.out.println ("node. SetData");

    This.Data = data;

    }

    }

    SerializableAttribute public class extends < all > node MyNode {}

    public MyNode(Integer data) {super (data) ;}}

    {} public void setData (full data)

    System.out.println ("MyNode.SetData");

    super.setData (data);

    }

    }

    And follows the code below:

    MN MyNode = new MyNode (5);

    Node n = minutes; A gross type - compiler generates a warning uncontrolled

    n.setData ("Hello");

    Integer x = mn.data; Causes a ClassCastException thrown.

    The problem is that in the document tutorial he said, after the erase process of type above code like this changes.

    MN MyNode = new MyNode (5);

    Node n = min (monnoeud); A gross type - compiler generates a warning uncontrolled

    n.setData ("Hello");

    Integer x = (String) mn.data; Causes a ClassCastException thrown.

    Suddenly two typecast appears. I do not understand it. These two typecast appear in line 2 and line 4 does not appear in the class if file I open them with javap - c.

    If you open the class with javap file there is no type of plasters as above, except a single type conversion is present who tries to cast mn.data object type for the integer variable x.

    Also the class MyNode is not even a generic. Could someone please tell me why these (monnoeud) and casts (String) comes after the type erasure process, or the reason why it appears at all.

    89f7ed33-8461-44f6-9be0-ab8e08aa24c3 wrote:

    The problem is in the tutorial document it says that after the erase process of type above code like this changes.

    MN MyNode = new MyNode (5);

    Node n = min (monnoeud); A gross type - compiler generates a warning uncontrolled

    n.setData ("Hello");

    Integer x = (String) mn.data; Causes a ClassCastException thrown.

    Code changes is the equivalent that you might have written in your source code for the compiler that creates the same byte code.

    The casts of types are there to explain what object you get from the right side, so the ITI becoms apparent why this code throws a class cast exception Finally.

    89f7ed33-8461-44f6-9be0-ab8e08aa24c3 wrote:

    Also the class MyNode is not even a generic.

    But she inherits from the generic class Node and fixing his entire generic type.

    Good bye

    DPT

  • Cannot set a Date value / digital (single chain) in VORowImpl in jdeveloper/OPS

    I have the following lines in my AMimpl

    public void reject() {}

    JonOafTestViewImpl vo = getJonOafTestView1();

    Line JonOafTestViewRowImpl = (JonOafTestViewRowImpl) vo.first ();

    row.setPatientName ("Jon");

    row.setPatientNumber (1);

    getTransaction () .commit ();

    }

    Why row.setPatientName ("Jon") has no errors, while row.setPatientNumber (1) a mistake (red line on setPatientNumber)?

    This means I can put only a String value?

    The JonOafTestViewRowImpl code is below:

    public void setPatientName (String value) {}
    setAttributeInternal (PATIENTNAME, value);
    }

    {} public void setPatientNumber (numeric value)
    setAttributeInternal (PATIENTNUMBER, value);
    }

    Can someone please explain to me what is the reason behind this and what is the right approach.

    Thank you.

    Jon

    Hello

    Import under pkg.

    Import oracle.jbo.domain.Number;

    for the date you first cast the date onoracle.jbo.domain.Date and pass to the setAttrbibute method.

    BR, 906099

  • date display format

    Hello


    How to display the 01/01/2013 as jan-13

    01/02/2013 as feb-13

    This format is not available under the column properties. Can someone tell me the solution?

    MONTHNAME ("Date". "Date of shipment") | " CAST ('-' as char). SUBSTRING (CAST (YEAR ('Date'.) "Date of shipment") (as char)(, 3, 4) worked for me... "

  • Between the problem of dates

    Hello world

    We try to get a SQL sentence for our data model, and we have 2 parameters of date as "MM-dd-yyyy".

    When we put them inside our SQL query, we saw that it needed the date as "MM-dd-yyyy HH24:mi:ss", and the HH24 Gets the value of a ' 11:00 ", so if I have a record in 11:10, or one in 10:50, it is filtered differently for the same day, depending on whether we use it in the parameter 'Start Date' or in the parameter 'End Date'.". "

    The filter in our query is like:

    'TIME' BETWEEN (: STARTDATE) AND (: ENDDATE)

    Can someone explain to me how this works exactly? because I need to get all day in the filter and is not only the half hours.

    Thank you.

    Simple thing is cast to date and use, simply go by date without taking account of the time.

  • int to date conversion

    Hi all

    I have a requirement where I need to use a date column, but the date in the data base is in three separate columns day, month and year that are int. How can I get the column date out of these three and use it on the answers.

    Thank you
    Karthik.

    Pull all three columns, concatenate them in the format that your obiee server would recognize. You can get this format in NLS_DATE_FORMAT. which is the conversion to a string with the help of interpreters. Your o/p should be something like YYYY-MM-DD (based on the format of your server). Then this conversion from cast to date. You should be able to use the column that would be in the date data type.

    I hope this helps!

  • DataTemplate not display data, but showing the right amount of lines

    I just started to use Datatemplates to convert our answers on Publisher reports. Basically, I use the PASS-THROUGH method BI Server.
    Copy the SQL from the SQL field advanced in BI answers.
    Place the new SQL in DataTemplate
    Construction DataStructure

    It seems to a sufficient quantity of lines, but no data is displayed. I checked the data multiple times for misspellings and other simple items but I'm not. It seems to make a connection very well, but it does not show and value in data elements. It returns 6 empty lines.

    Attached XML example:
    < name of dataTemplate = "FiveDayCo" defaultPackage = "" than one dataSourceRef = "OracleRPD" > "
    Properties of <>
    < property name = "include_parameters" value = "true" / >
    < property name = "include_null_Element" value = "true" / >
    < property name = "include_rowsettag" value = "false" / >
    < property name = "scalable_mode" value = "off" / >
    < property name = "db_fetch_size" value = "300" / >
    < / properties >
    < Settings / >
    < lexicals / >
    < dataQuery >
    < sqlStatement = "COOR" name > <! [CDATA [SELECT "-match". "% response time of 5 day correspondence" "saw_0, 90% ' saw_1," "-correspondence".]] "% Response time of 5 day match"-90 saw_2,""-match details "". "" Type of correspondence' saw_3 OF finance WHERE ("-match details". "") (Match type' IN ('Customer Service', 'Systematics', 'Not available', 'Privacy')) AND ("Business Unit". ("' Business unit ID" = 6.00) AND ("'-record details" "." ") Record type' = 'Core') AND ("-matches details". "") (Correspondence of State' <>'closed') AND (("-primaire terminé Date prévue".)) "" Primary year expected "= cast (YEAR (date '' 2010-07-01) as char (4))) AND (" "-Date completed expected primary" "." ")" Primary planned calendar month "= MONTH (date ' 2010-07-01'))) [ORDER BY saw_1, saw_3]] > < / sqlStatement >"
    < / dataQuery >
    < dataStructure >
    < group name = "Coorespondence" source = "COOR" >
    < element name = "FiveDayCoorespondenceTime" source = function "saw_0" = "" / >
    < element name = "ValeurIPC" source = function "saw_1" = "" / >
    < element name = "Variance" source = function "saw_2" = "" / >
    < element name = "CoorespondenceType" source = function "saw_3" = "" / >
    < / Group >
    < / dataStructure >
    < / dataTemplate >

    A few things to check. The sql by itself returns the data?

    Also, you need the following: ? If a package is not used/needed, remove the reference.

    The following tag should suffice.

    Your datastructure code must be: (for the name of the element using the value (instead of source =) and I removed the syntax of the function since you don't specify any function like sum, average)








    For a reliable data model reference, check the following: http://blogs.oracle.com/xmlpublisher/2009/06/data_template_progression.html

    Hope that helps!

  • Troubleshooting not enough memory error

    I get an error of memory and while there are tons of posts about this on the forums, I had a few more questions. First of all, I have two cRIOs and think that the error would have been thrown by one of them. Is it still possible if? I'm trying to narrow down what exe, the error may be in. Secondly, is there an order of actions they take when they get these errors to help out them?

    Found the REAL problem! I was not reading my header correctly, this resulted in type casting the bad data bytes. Every now and then I would be casting of data type byte that when type cast from a string to an I32 caused a number about 17 million. I guess that the TCP read trying to malloc memory (or new if its c ++ ) and has been unable to do. That's why I got the low-memory error. When I started to read my TCP bytes correctly, the error disappeared.

Maybe you are looking for