Reg: Case Stmt

Hi Experts,

I implemented a stmt case to load data from a table to another table (the two tables are same pattern only).

My source as table spec

Select * from EMP

Sal jdate empid EmpName
Emp1 100 1000 2012
Emp1 101 5000 2012

even my table target spec also even called as emp1:


my code is



Insert into EMP1
(
EMPNAME,
EMPID,
SAL,
JDATE

)

Select
EMPNAME,
EMPID,
SAL,
JDATE

DE)


Select
EMPNAME,
EMPID,
SAL,
EMPNAME CASE
WHEN 'EMP' THEN TO_DATE (C4_JDATE, 'YYYY')
WHEN 'EMP1' THEN TO_DATE(C4_JDATE,'dd-mon-yyyy')
WHEN 'EMP2' THEN TO_DATE(C4_JDATE,'mm/dd/yyyy')
end JDATE
from EMP
where (1 = 1)



This query above works fine, but when the time to display the basic data in emp1 as of data

JDate as: July 01, 2012

data remaining is fine.


Have that I need to change the date format of database to jdate disaplay as 2012 (yyyy)...

Please suggest me where I need to change...


Thank you
H







)

Oracle date formats needs to be in a year, month, day, and hour of the elements. If update us or insert a value into a date column that does not have some of these Oracle components using the default values.

Thus, if provide us everything a year that oracle will generate a date which is midnight the first day of the current month. It's what you do, and is why you currently values JDATE July 1, 2012. If you run your code on Wednesday you will find the JDATEs will be August 1, 2012.

Cheers, APC

Tags: Database

Similar Questions

  • REG: CASE WHEN IN WHERE WOULD ADOPT

    Hi friends, this is my query SELECT DISTINCT FILE_DIRECTION FROM RA_PROCESS_ID_MAP WHERE FILE_DIRECTION = (CASE WHEN "TAP" = "TAP" and (FILE_DIRECTION = 'A' AND FILE_DIRECTION = 'TI'), THEN WHEN 'NRTRDE"THEN FILE_DIRECTION =" NEITHER "WHEN 'SWITCH' AND FILE_DIRECTION = 'SO' END) = 1; its me given expression error... Please help.

    If this is what he wants, then it is probably more clear to remove the CASE statement total:

    Select distinct file_direction

    of ra_process_id_map

    where (: b1 = 'TAP' and file_direction in ('TO', 'TI'))

    or (: b1 = "NRTRDE' and file_direction = 'NOR')

    or (: b1 = 'SWITCH' and file_direction = 'IF')

    I think the just CASE statement confuses the issues and has clearly confused the heck out of the op.

  • Reg: CASE vs. IF ELSE

    All,

    In the Sub function, I used IF and on the OTHER, the same is also possible in CASE. Could tell me which is more better to use and what might be the global differences. And any other suggestions please also welcome.

    / * Formatted on 2013/07/25 10:23 (trainer more v4.8.8) * /.
    FUNCTION check_pickupdate (p_date VARCHAR2)
    RETURN VARCHAR2
    IS
    v_ok VARCHAR2 (10);
    BEGIN
    IF TO_DATE (p_date, "dd/mm/yyyy") < TRUNC (SYSDATE) + 3
    THEN
    -dbms_output.put_line (' you can only book a count "| to_char (trunc (sysdate) + 3, 'day') |) ", please see the table below"); "."
    v_ok: = 'NO ';
    ON THE OTHER
    BEGIN
    IF To_char (SYSDATE, 'DY') = 'MON' - BOX WHEN
    THEN
    IF TO_CHAR (SYSDATE, "hh24") < '13'
    AND TO_DATE (p_date, ' dd/mm/yyyy') > = TRUNC (SYSDATE) + 3
    THEN
    v_ok: = "OK";
    ELSIF TO_CHAR (SYSDATE, "hh24") > "13"
    AND TO_DATE (p_date, ' dd/mm/yyyy') > = TRUNC (SYSDATE) + 4
    THEN
    v_ok: = "OK";
    ON THE OTHER
    v_ok: = 'NO ';
    END IF;
    -code
    -for all other weeks too
    -code
    ELSIF TO_CHAR (SYSDATE, 'DY') = 'SAM '.
    AND TO_DATE (p_date, ' dd/mm/yyyy') > = TRUNC (SYSDATE) + 5
    THEN
    v_ok: = "OK";
    ON THE OTHER
    IF TO_CHAR (SYSDATE, "hh24") > "13"
    AND TO_DATE (p_date, ' dd/mm/yyyy') > = TRUNC (SYSDATE) + 4
    THEN
    v_ok: = "OK";
    ON THE OTHER
    v_ok: = 'NO ';
    END IF;
    END IF; --FIN CAS ;
    END;
    END IF;

    RETURN v_ok;
    END;

    Thank you

    IF the instruction is supported only in PL/SQL in contrast CASE statement is supported by SQL and PL/SQL. Not to mention that his choice about. See this

    declare

    l_val integer: = 1;

    Start

    case l_val

    When 1 then

    dbms_output.put_line('1');

    When 2 then

    dbms_output.put_line('2');

    on the other

    dbms_output.put_line('3');

    end case;

    If l_val = 1 then

    dbms_output.put_line('1');

    elsif l_val = 2 then

    dbms_output.put_line('2');

    on the other

    dbms_output.put_line('3');

    end if;

    end;

    Both give the same result but it's just what you prefer and what you find, it's more elegant.

    This question also came a lot of time here

  • Update col value based on an another tbl - update, case stmt, subquery

    I need to
    (1) adds a column col1 existing table tbl1;
    (2) the value of col1 will be updated to the value of column col2 from table tbl2.
    (3) if the tbl2 returns the number of records or no records, the value of col1 will default to 0. otherwise, it will be the unique value of col2 of tbl2

    I'm stuck.

    Thank you.

    Hello

    new2Oracle wrote:
    I need to
    (1) adds a column col1 existing table tbl1;

    Use ALTER TABLE.

    (2) the value of col1 will be updated to the value of column col2 from table tbl2.
    (3) if the tbl2 returns the number of records or no records, the value of col1 will default to 0. otherwise, it will be the unique value of col2 of tbl2

    Use an expression BOX to test if there is a line matching or not and return a value on this basis.
    For example:

    UPDATE  tbl1     t1
    SET     col1     = (
                SELECT  CASE
                        WHEN  COUNT (*) = 1
                        THEN  MIN (col2)
                        ELSE  0
                      END
                FROM       tbl2
                WHERE       common_column_1     = t1.common_column_1
                AND       common_column_2     = t1.common_column_2
                )
    ;
    

    Because the subquery uses an aggregate function (COUNTY), the returned value must be as an aggregate (such as MIN) or a constant (such as 0). In cases where there is only 1 row, we could use MAX, AVG or SUM instead of MIN to get the value of this one line.

  • Reg: select stmt to get the day of the week in the last 20 years

    Hello

    I need to write a select statement or procedure that can give a performance of only one day given in the past 20years 20years and contracts at end of the current week in the calendar.


    Thanks in advance

    Published by: user648380 on January 14, 2010 12:06 AM
    SELECT add_months(trunc(SYSDATE, 'IW'), -12 * 20) + (LEVEL * 7) monday
      FROM dual
    CONNECT BY LEVEL < (add_months(trunc(SYSDATE, 'IW'), 12 * 20) - add_months(trunc(SYSDATE, 'IW'), -12 * 20)) / 7
    

    Published by: fsitja on January 14, 2010 12:55 AM fixed... accident of copy/paste

  • need to create a stmt case in SPR

    Hello

    Using obiee 10g,.
    I'm trying to create a SPR collar logic, using a case stmt.

    It's like
    sum (case when a! = 0, then another end b).

    and the problem is a and b columns I get 2 different tables.

    I can't do it in my report as do sum will give erroneous results at level so must be done at the level of the RPD only.

    So first I created a logical neck and expression edit I tried this stmt case but since diff taking 2 table since gives me error no mapping physical collar.
    Then I tried as with existing collar like source-case stmt is not ok no problem, but when I put the SUM his me gives error as using the obsolete?

    Is there a way I can do this in RPD?

    Thank you

    Hello

    In your RPD:

    (1) add TLM (source measurement logic mulptile) as below the screen short.then are you add column to table mulitple you are business condition

    See my screen,
    http://ImageShare.Web.ID/images/n7jxv3qkx87w62xy1kz.jpg

    (2) make a double column of a., b. and apply sum to this double column and
    (3) case now set you are in double column

    as below
    (1) provable:
    -case when table1.column_a! = 0 then other end table2.measure table1.measure

    (2) provable
    -case when 'GPC_DataMart '. "" "" GPC_DataMart '. "" """dbo"."" "" "IW_POSITION '." " Product_Type"NoT IN ('Bond', 'Links',"Redeemable bonds")
    then "GPC_DataMart". "" "" GPC_DataMart '. "" """dbo"."" "" "IW_POSITION '." " ' Nominal_AMT' another' GPC_DataMart '. "" "" GPC_DataMart '. "" """dbo"."" "" "MX_SPOT '." " END OF NON_DISC_SPOT ".

    Thank you

    Deva

  • stmt case

    Hello

    I have three tables
    orders(orderid)
    editorders(orderid ,editflag)
    vvorders(orderid)
    I write 2 case stmts

    1 if change flag = 23 editorders table for a job that is present in the orders table, and then see the other the order_id show the works of blank.this fine column with below stmt
    select o.order_id,
    CASE WHEN eo.editflag=23 THEN o.order_id ELSE NULL END AS editorder
    from orders o,editorder eo where o.order_id=eo.order_id
    2. now if editflag = 23 and if the present order in vvorders then I need to show empty if I show the ordered.if the command id is not present arrested edit then also shows white
    select o.order_id,
    CASE WHEN eo.editflag=23 THEN o.order_id ELSE NULL END AS editorder,
    CASE WHEN eo.editflag=23 and  o.order_id  =  vo.order_id    THEN null ELSEo.order_id  END As vvorder
    from orders o,editorder eo,vvorder vo where o.order_id=eo.order_id(+) and o.order_id=vv.order_id(+)
    but the problem is that I get a line in the column vvorder when editflag is not 23 and also away from the table vvorders
    what I'm doing wrong here

    Hello

    What does "order_id is not present" mean in terms of your data?
    If eo.orederid is NULL, then you could do soemthing like this:

    ,     CASE
             WHEN  eo.editflag     = 23
             AND   o.order_id     =  vo.order_id     THEN  NULL
             WHEN  eo.orderid     IS NULL          THEN  NULL
                                           ELSE  o.order_id
         END               AS vvorder
    

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all tables and also post the results desired from these data.
    Explain, using specific examples, how you get these results from these data.

  • error thrown as a "Union of incompatible types.

    -case when MONTH (etxnmistopbr.month_year) < 10 THEN CONCAT ('0 ', cast (MONTH (etxnmistopbr.month_year) as char)) else (etxnmistopbr.month_year) month end.


    It throws the error "[nQSError: 10058] a general error has occurred." [nQSError: 22027] Union of incompatible types. (HY000) »

    can you help me please what is the problem?

    In your case statement desired char type when the condition is true other wise number type.
    Use the function concat out side of the case stmt or else go up this month (etxnmistopbr.month_year) as char.

    Pls mark as correct

  • Stmt case answers column fx syntax error

    Hello

    I want to update the 'Project name' column that is of type VARCHAR to "Undefined" If the "Project_date" column has a value of January 1, 1900 12:00 "." I use the stmt case following answers column Fx of 'Project name' but do syntax error.

    BOX WHEN "hand-made". "" Project_date "= January 1, 1900 12:00 ' THEN 'Undefined' ELSEWHERE 'hand made '. "' Project name ' END

    Thanks for your time and your help.

    Hi Ssk,

    It should work. Please make sure once again that the underside of things in your query:

    (1) 1st January 1900 12:00 - value exists in the column
    (2) and remove all spaces between the column name and values.

    Without spaces:

    BOX WHEN "hand-made". "Project_date" = January 1, 1900 12:00 ' THEN 'Undefined' ELSEWHERE 'hand made' "." " The project name"END;

    I would like to know if that works for you or not.

    Thank you
    -Laurence.

  • What is the difference in the case of stmt

    Hello
    I get the same result with the following case
    SQL> select (case when empno=7566 then 100 else empno end)
      2  from emp;
    
    (CASEWHENEMPNO=7566THEN100ELSEEMPNOEND)
    ---------------------------------------
                                       7369
                                       7521
                                        100
                                       7654
                                       7698
    
    
    SQL> select (case empno when 7566 then 100 else empno end)
      2  from emp;
    
    (CASEEMPNOWHEN7566THEN100ELSEEMPNOEND)
    --------------------------------------
                                      7369
                                      7521
                                       100
                                      7654
                                      7698
    Apart from this we have no difference between the 2 above cases

    Thank you

    There is no difference in your two case statements. They represent the same logic, and that's why you get the same result.

    There are two ways to use the case as statements evidenced as well.

    "CASE deptno when 10 then...". "is used when we want to match the exact value by using the equality operator. It's the same as 'BOX when deptno = 10 then... ". »

    "CASE when deptno > 10 then...". "is used when the operator is none other than the equality operator"="like" >,<, like,bewteen="" etc"="">

    I thing you got the point.

    Concerning

    Published by: MYRIAM on November 4, 2008 21:44

  • How to include stmt cases in a group by clause

    Hi I have a question,

    How can I include a case statement in the group by clause?

    For example:

    Select
    (case when x.ctry is null then y.ctry to another x.ctry end) as chief operating officer.
    sum (x.in_amt)
    Of
    tbl1 x,
    TBL2 y
    where
    x.ID = y.id
    Group
    (case when x.ctry is null then y.ctry to another x.ctry end)

    Assume, I had millions of records in the tables, then my guess is, the above query could take huge time.

    Any other way to do it?

    CD / wrote:
    To delete the expression in the GROUP BY clause. I'm advocating no improvement in performance, I don't have?

    No, you didn't. And your advice can remove in fact the expression in the GROUP BY clause. But I am still confused as to why this would be an end in itself.

    Kind regards
    Rob.

  • Case of reg-story view

    I have two columns A, B as two guests.

    I'm passing the values of A, B at the sight of the narration.

    I have selected f has a value must switch to the view of the narrative

    I f B is selected value B should switch to the view of the narrative

    FYI: the user will not select both at the same time.

    Thank you
    NK

    If you use presentation variables then just call them using the @{nomvar} in narrative mode
    like @{A} @.
    According to the value that the view show.

    If you use no presentation variables then
    Use columns A and B in the report
    and call them narrative using their positions as mode @1@2
    where 1 the a position on the left in the criteria

    Published by: VIEREN Srini April 1, 2013 11:31

  • my PC Backup, Reg Clean Pro &amp; Research protect all piggyback on my Installer Firefox 26, for which I had to replace my Norton caveat regarding security issues.

    my PC Backup, Reg Clean Pro & Research protect ALL grafted onto my Installer Firefox 26, for which I had to replace my Norton caveat regarding security issues.

    Based on your research, I also substitute a Norton Security warning.

    I have windows 7 and complete Norton Security

    You downloaded firefox from the official site. Sometimes the software gets supplied with malware or adware, as in your case.
    In some cases, I recommend uninstalling (your software also mentioned), FF data directory deleting and then reinstalling FF of mozilla.org

  • ActiveX - Reg - led event reminder

    Hello

    I'm building a control for a Laser machine which based its controls in the ActiveX control technology. I had a program in c# that works, but I have because I wanted to change the settings and then connect it to another program Labview, I "translate".

    I start with a very simple operation:

    1. 'Start' ActiveX Server

    2. "load" a design for the laser.

    3. program of the "end".

    and then based on event (using the reg event reminder):

    If the "QueryStart" laser signal is activated by a switch, then "run" program.

    If the laser "starts", then light a led

    If laser 'ends', then light a led.

    I have problems to light a led by using the ref (LaserStartedLed) VI. I'm using as a model the Labview example: CWKnob to see a number from the button. But in this case, they use the numbers from the button, in my case are just Boolean, and I try to get data from common event.

    Can you help me with other ideas and corrections?

    Thanks in advance,


  • Of-Rube my code please Reg Expression maybe?

    Hi all!

    I will avoid solutions based text, but after looking at my code, I thought I can get a chance to learn a better way to do it.

    Problem:

    In LV 8.6 there is a problem when an individual 'node' in a VRML file result LV to crash if I try to open a file containing this node.

    Solution:

    Wirte code to check the file and remove the cruelest bad 'node' of trying to open it.

    IF this code works, but screams "This could we better using Reg expression?"

    I think the picture tells the story.

    NOTE: The case of non-visalbe just do the wires.

    THEN, share your thoughts please.

    Ben

    Even better than my original.  This is the beginning of the selection followed until the first byeverything '} ' (and line break).

    Kudos to ben64 for the tip.

Maybe you are looking for