473,396 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Issue while inserting through DECODE function

Expand|Select|Wrap|Line Numbers
  1. SQL>desc tab_dup;
  2.  
  3.  Name                                      Null?    Type
  4.  ----------------------------------------- -------- ----------------------------
  5.  CODE                                      NOT NULL VARCHAR2(6)
  6.  BYJE                                               DATE
  7.  
  8. SQL>  insert into tab_dup (CODE, BYJE) values('ABC',TO_DATE('20120111070154', 'YYYYMMDDHH24MISS'));
  9.  
  10. 1 row created.
  11.  
  12. SQL>  select to_char(BYJE,'YYYYMMDDHH24MISS') FROM tab_dup WHERE CODE='ABC';
  13.  
  14. TO_CHAR(BYJE)
  15. --------------
  16. 20120111070154
  17.  
  18.  
  19. SQL> delete from tab_dup where CODE='ABC';
  20.  
  21. 1 row deleted.
  22.  
  23. SQL> commit;
  24.  
  25. Commit complete.
  26.  
  27. SQL> insert into tab_dup (CODE, BYJE) values('ABC',DECODE(TO_DATE('20120111070154', 'YYYYMMDDHH24MISS'),'19800101000000', NULL, TO_DATE('20120111070154', 'YYYYMMDDHH24MISS')));
  28.  
  29. 1 row created.
  30.  
  31. SQL>  select to_char(BYJE,'YYYYMMDDHH24MISS') FROM tab_dup WHERE CODE='ABC';
  32.  
  33. TO_CHAR(BYJE)
  34. --------------
  35. 20120111000000
  36.  
When inserted at line number 27, using decode function; it is not storing hour minute second & thus they are coming as 000000. I have to use decode because the value from the parent table may be null & in that case this will help but the truncation should not happen because of decode & thus it should work same way when inserted through line 8.

Please provide the necessary changes to decode function or any other alternative.
Jan 18 '12 #1
2 1681
PsychoCoder
465 Expert Mod 256MB
First and foremost what database is this, that would greatly help in finding a solution.
Jan 18 '12 #2
Oracle.
connect by below string to the ip through putty :
SQLPLUS userid/password
Jan 18 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Walt | last post by:
Hi, I want to write a query that returns Y or N depending on whether the current time is within a specified window i.e. EVENT_TABLE ---------- event_id number PK event_start date...
2
by: Mark Hoffman | last post by:
I'm a newbie at Oracle..Be gentle! I have a table that stores information (WMI data) about computers on our network. The table looks like: ComputerID ItemID Class Property Value
2
by: Amin Schoeib | last post by:
Hi, Like I see there is no equivalent to the Oracle decode Function In Postgres.Is there maybe somebody who wrote decode as a Function? Schoeib 4Tek Gesellschaft für angewandte...
1
by: MP | last post by:
I have the following command. SELECT A.STORE_NAME, A.STORE_NUM, A.ZIP_CODE, B.EMPLOYEE_ID, B.GENDER, B.EMP_LEVEL, C.ITEM_CODE, DECODE(B.ITEM_CODE,1, 'CHICK_BURGERS') ITEM_DESCR,...
1
by: Deven Oza | last post by:
Hello everyone Please help me for the following query I want to solve the query Using the (DECODE) function, I want to write a program segment that will successfully decode all the CIS courses...
16
by: Medhatithi | last post by:
Hi, I am facing a strange problem with decode function in oracle. My table name is status_hist. Below is the query I am hitting on this table: select...
4
by: jessy | last post by:
i was asked in an interview to use the decode function to print High if salary was greater than 2500 and low if it was less than 2000... but i dont know how to use relational operators in decode ??!!...
1
by: Sonalisa48 | last post by:
Syntax for using a decode function to check a string size. sample query: (select text from Noteline where EnteringofHeading = 'BillingAddress1' and notenumber= (select note from OrderHeader where...
3
by: Stuart B | last post by:
I'm having problems with the following error when trying to use the DECODE function:- ORA-00939: Too many arguments for function Does anyone know what the upper limit is for the number of...
2
by: johroc | last post by:
Hi everyone, I'm trying to use decode using % to obtain a specific output when the field contains a specific chain of characters, but it gives me the same output for all the lines regardless of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.