Replace Date column to Varchar Value [message #610260] |
Tue, 18 March 2014 21:19 |
|
amit_jha05
Messages: 35 Registered: January 2014 Location: India
|
Member |
|
|
hi,
I have a question wherein 1 table is getting data about the jobs ran like start time and end time .
Both start and end time columns datatype are date ,now what i need is suppose the Job is still running so i do not get an entry in start time and end time columns , so in-spite of NULL i want to replace it with 'Running' value.
But as the columns are Date Type i was unable to replace it with 'Running'
Can it be done Please help.
Thanks in Advance.
|
|
|
|
|
|
|
|
|
|
|
|
Re: Replace Date column to Varchar Value [message #610281 is a reply to message #610278] |
Wed, 19 March 2014 01:36 |
|
amit_jha05
Messages: 35 Registered: January 2014 Location: India
|
Member |
|
|
INSERT xyz
VALUES ('EE', 'aa', 'DAILY', '5:30 AM CEST', '11:30 PM EST',
'200000', TRUNC (SYSDATE),
(SELECT DISTINCT (TO_DATE
(TO_CHAR (MAX (x.job_start_ts),
'MM/DD/YYYY HH12:MI:SS AM'
),
'MM/DD/YYYY HH12:MI:SS AM'
)
)job_start_ts
FROM abc,
(SELECT DISTINCT (NVL2(TO_DATE
(TO_CHAR (MAX (y.job_end_ts),
MM/DD/YYYY HH12:MI:SS AM'
),
'MM/DD/YYYY HH12:MI:SS AM'
)
),'Running')job_end_time
FROM abc);
In the 1st select we have the job start time whereas 2nd select it is end time so if the job is running select will not get any data for end_time here i wanted to do NVL so that it gives Running as tried above but query failed with Invalid number of Argument error.
hope this makes thing a bit clearer to you.
|
|
|
|
|
|
Re: Replace Date column to Varchar Value [message #610290 is a reply to message #610287] |
Wed, 19 March 2014 02:49 |
John Watson
Messages: 8929 Registered: January 2010 Location: Global Village
|
Senior Member |
|
|
orclz>
orclz> create table t1(c1 date);
Table created.
orclz> insert into t1 values(sysdate);
1 row created.
orclz> insert into t1 values(null);
1 row created.
orclz> select nvl(to_char(c1),'running') from t1;
NVL(TO_CHAR(C1),'RU
-------------------
2014-03-19 07:48:26
running
orclz>
|
|
|
|
|
|
|
Re: Replace Date column to Varchar Value [message #610387 is a reply to message #610385] |
Wed, 19 March 2014 12:37 |
joy_division
Messages: 4963 Registered: February 2005 Location: East Coast USA
|
Senior Member |
|
|
EdStevens wrote on Wed, 19 March 2014 13:28
Can you debug code you don't see?
Neither can I.
And OP, I don't see any table definitions either. A blind insert that you show is poor and dangerous programming.
|
|
|