explain to_char
Hello Experts,
I have a question about the to_char function. I've read the documentation, but some type of confusion is persistent in my mind. I hope someone can shed some light on this
I have a confusion on 9 - width digital and 0 - shows the formats of zero on the left
Select to_char (1890.5, ' $0G000D00 ') of double - returns $1 890,55 (may be stupid but means 0 here?)
Similarly select to_char (1890.5, ' $99G999D00 ') of double - returns $1 890,55
can we explain clearly how the conversion happens here?
Hello
1061748 wrote:
I'm sorry for the fault of typo I meant
Select to_char (1890.55, ' $0G000D00 ') of double - returns $1 890,55
If I understand it, 0 in the format mask is said to have 0 in the first position, then why is not below... in this case how will be different with the format with 9
SQL > select to_char (1890.5, ' $0G000D00 ') of double
TO_CHAR(1890.5,'$0G000D00')
---------------------------
$1 890,50
1 selected line.
This says display 4 digits before the comma, and if less than 4 digits are needed, then display 4 digits in any case, with the principals of '0'.
In this case, the 4 digits are required to display in 1890, so no leading '0' have been added.
'0' and '9' formats differ only how they pad: be it with '0' (in the case of the '0' format) or spaces (in the case of '9'). If no fill is necessary, then they return the same string. See the example of filling Blushadow when it is necessary and explanation in response #1.
Tags: Database
Similar Questions
-
Hi all
I little bit on (), TO_DATE (), () TO_NUMBER TO_CHAR confusion.
Can you please explain when to use which works with examples.
Thank you and best regards,
-
explain DBMS_APPLICATION_INFO
Hi all
In the package in the Begin block
BEGIN
DBMS_APPLICATION_INFO. SET_MODULE ( module_name = > 'PKG', )
action_name = > 'proc1-opening slider');
FOR... LOOP
BEGIN
DBMS_APPLICATION_INFO. SET_ACTION (' proc1 :'||) To_char (v_count) | "done");
v_count: = v_count + 1;
END;
END LOOP;
END;
can you please explain about it?
Thank you
N ° action is a description of real processing step.
For example the module is called billing and action is Application of discount.
Put an arbitrary number as action is ridiculous - it has no meaning.
If you know the number of cycles treatment there is (e.g. lines how many process), you can create a long operation - who to see and interpret correctly monitoring/admin tools.
-
To_char - NUMBER (5) - beginning and ending zeros
I'm reviewing the code and came across: RPAD (LPAD (TO_CHAR (col), 9, '0'), 11, '0') where the neck is NUMBER (5, 0) NOT NULL default 0 value.
FWIW (in QA): SELECT LENGTH (col), SIGN (col), COUNT (*) C to tab GROUP BY LENGTH (col), SIGN (col) ORDER BY 1.2;
22196 0 1
1 1 5746
2 1 53553
3 1 410260
4-1 16
4 1 23198
5-1-25
The output sample I does not contain any negative numbers. Apparently, it is excluded from the query with a different logic (although not directly) or these data are only test cases.
The intention seems to be to add up to 8 zeros and 2 zeros. A function pad seems redundant as TO_CHAR itself can do the job, although it does not appear that TO_CHAR can add two zeros in the same call start and end. Given that the latter is only two zeros, I just say concatenate is better: TO_CHAR (col, 'FM000000009'). '00'. technically, this is not the same as the current expression, that when the number is negative, the sign is placed in the middle of the string! I guess that it is not expected that the case should not. Maybe I can 'fix' and leave a comment explaining the original behavior.
Is it possible to add the preceding and zeros with a function of leak?
Post edited by: Brian Tkatch Put the bracket in the right place. Oops!
Hello
Sorry, it is not clear what you want.
Whenver you have questions, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) and also post the results desired from these data.
Explain, using specific examples, how you get these results from these data.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum: https://forums.oracle.com/message/9362002
Why do you need a single function? Why not something like
To_char (col, '000000000') | '00'
?
If you must do so within a single function:
To_char (col, '000000000V99') - V99 adds 2 0 leak
The comment is necessary, because someone who has to maintain the code (including you in a few months) knows what V99 done and will lose time looking at a maximum.
-
Strange TO_DATE/TO_CHAR
Hi all
I am facing a problem with To_char function for the date object.
I am trying to execute the following SQL code:
Select do_date, XXX, to_char (xxx))
Select
TO_DATE)
case substr (do_date, 1, 14)
When '2016' then do_date
of another substr (do_date, 1, 14)
end
, 'YYYYMMDDhh24miss '.
)
XXX, wns_attack_meminfo_work do_date
);
The result is
DO_DATE XXX TO_CHAR (XXX)
-------------- ------------------------------- ------------
20150731181234 31 JULY 15 000-00-00
20150731181234 31 JULY 15 000-00-00
20150731181234 31 JULY 15 000-00-00
20150731181234 31 JULY 15 000-00-00
Any body knows why, when XXX has a valid value, TO_CHAR (XXX) returns an incorrect value?
I run the query against ORACLE 10 g 10.2.0.1.0, 32-bit, Windows server 2003.
When I try to run the same query against an another DB (CENTOS5.5_64, 10.2.0.4.0, 64-bit) the result is ok.
I not only have to solve this problem, but also need to explain to the client why we have this problem.
Any help is highly appreciated.
Thanks in advance,
Tuan
Simple guideline - if there is no other difference between the two databases and it works on 10.2.0.4 but not on 10.2.0.1 then there is a very good chance that you look at a bug that is corrected.
In your case, the result is something that "cannot possibly" appears, this suggests a bug even more strongly; and then you can't help but notice that your SQL * Plus shows XXX as a readable date, she made an implicit conversion of some sort and you expect your Explicit to_char() (server side) to work as well.
You dump (XXX) is very informative. Type 7 is what you get by immersion of a date of database column, type 8, that's what you get by dumping (e.g. SYSDATE) when it is used as a variable. This suggests an error in the internal code that produces a gap between two stages of execution of SQL.
Speculation is not necessary, though - I just did a quick search on Metalink (MOS) in the "Bug" database for 'to_date' "" 000-00-00 and found the following: Bug 5174854 : RETURNS TO_CHAR ON A DATE VALUE "000-00-00 '.
Reported in 10.2.0.1, 10.2.0.2 fixed
Concerning
Jonathan Lewis
-
Please explain this part of the code
CREATE OR REPLACE PROCEDURE IS abc123
-Statements
v_T_MAP_record T_MAP_map % ROWTYPE;
TYPE t_element_cursor IS REF CURSOR;
v_T_MAP_cursor t_element_cursor;
number of v_T_MAP_count;
BEGIN
DBMS_OUTPUT. ENABLE (1000000);
v_T_MAP_cursor: = get_T_MAPs (1308); -This will get the record of the cursor
-Open the cursor
EXTRACTION v_T_MAP_cursor
IN v_T_MAP_record;
V_T_MAP_cursor % FOUND LOOP
dbms_output.put_line ('uc.use_case_id: ' | v_T_MAP_record.use_case_id);
v_T_MAP_count: = v_T_MAP_count + 1;
EXTRACTION v_T_MAP_cursor
IN v_T_MAP_record;
END LOOP;
-Close the cursor
CLOSE V_T_MAP_cursor;
EXCEPTION
While OTHERS THEN
dbms_output.put_line ('Error' |) TO_CHAR (SQLCODE) | ': ' || SQLERRM);
END;
I do not understand why we are having 2 game instruction Fetch IN v_T_MAP_record's first before the while loop v_T_MAP_cursor and the other inside the v_T_MAP_cursor. Please explain. If I remove the second instruction fetch inside the loop, it gives me a buffer overflow error.It's what he does...
CREATE OR REPLACE PROCEDURE abc123 IS --Variable declarations v_T_MAP_record T_MAP_map%ROWTYPE; TYPE t_element_cursor IS REF CURSOR; v_T_MAP_cursor t_element_cursor; v_T_MAP_count number; BEGIN DBMS_OUTPUT.ENABLE(1000000); -- THIS ISN'T REALLY NEEDED -- This opens the ref cursor, it doesn't fetch anything (assuming get_T_MAPs doesn't fetch itself) v_T_MAP_cursor := get_T_MAPs(1308); -- This fetches the first record from the cursor FETCH v_T_MAP_cursor INTO v_T_MAP_record; -- If a record is found we enter a loop WHILE v_T_MAP_cursor%FOUND LOOP -- output the current record details dbms_output.put_line('uc.use_case_id: '||v_T_MAP_record.use_case_id); v_T_MAP_count := v_T_MAP_count + 1; -- fetch the next record FETCH v_T_MAP_cursor INTO v_T_MAP_record; -- loop back to the start of the while loop END LOOP; --Close the cursor CLOSE v_T_MAP_cursor; -- Pointless stupid exception handler EXCEPTION when OTHERS THEN dbms_output.put_line('Error ' || TO_CHAR(SQLCODE) || ': ' || SQLERRM); END;
Although this would be a better style:
CREATE OR REPLACE PROCEDURE abc123 IS --Variable declarations v_T_MAP_record T_MAP_map%ROWTYPE; TYPE t_element_cursor IS REF CURSOR; v_T_MAP_cursor t_element_cursor; v_T_MAP_count number; BEGIN -- This opens the ref cursor, it doesn't fetch anything (assuming get_T_MAPs doesn't fetch itself) v_T_MAP_cursor := get_T_MAPs(1308); LOOP -- This fetches the first/next record from the cursor FETCH v_T_MAP_cursor INTO v_T_MAP_record; EXIT WHEN v_T_MAP_cursor%NOTFOUND; dbms_output.put_line('uc.use_case_id: '||v_T_MAP_record.use_case_id); v_T_MAP_count := v_T_MAP_count + 1; END LOOP; --Close the cursor CLOSE v_T_MAP_cursor; END;
However, I would also change things to use the SYS_REFCURSOR as the need to define your own type from the REF CURSOR was placed back in 9i with the new type built in SYS_REFCURSOR.
There are probably many other things I would like examine why I'm using ref Cursor in the first place and why I try to write data using dbms_output etc., but hey, we all have start somewhere.Published by: BluShadow on 28-Sep-2012 14:28
-
Hello
on 9i
How can we find explain the plan already used for a query?
Thank you.Yes, in 9i there is no sql_id. SQL_ID did not appear in the dictionary of data up to 10g.
Try with:
SELECT DECODE (id, 0, ",)
LPAD (' ', 2 *(level-1)). level: '. ' || position) | » '|| operation |
DECODE (id, 0, ",' Option: '). options of |
DECODE (id, 0, ", the name of the object: '). DECODE (id, 0, ", NVL (object_name, 'None')) |
DECODE (id, 0, ",' item number: '). Decode (ID, 0, ", NVL (to_char(Object#), 'None')) |
DECODE (id, 0,' cost = ' | position)
SQL_Query_plan
V $ sql_plan
CONNECT BY prior id = parent_id
AND address = upper('&&SQLADDRESS')
START WITH id = 0 AND address = upper('&&SQLADDRESS');Currently, I have not all 9i db, so I can't tell you exactly, but I think you're going to tell me something like above, i.e. of the same my previous link. In the above query simply paste the address sql you want to know az7r9swp (without the quotes) as you do.
Concerning
Girish Sharma -
TO_DATE and to_char
Hello
Can someone explain to me why
Select to_date (to_char (to_date('17.05.0012','dd.mm.yyyy'), 'dd'), 'dd.mm.rr') of double
gives * 17.05.0012 * (what I think wrongly), but
Select to_date (to_char (to_date('17.05.0012','dd.mm.yyyy'), ' dd.mm.yy' ")" | ") "dd.mm.rr") of the double
gives * 17.05.2012 *.
Thank you!Ok thank you! Seems it is explained more or less (only I can't do a patch, it is not my private Oracle).
I asked a different colleague with Oracle to test and she got good results for 10.1 and 10.2.
Well, it's not the biggest bug of my life! I'll close the question and thanks for the help! -
Using to_char in order to extract "WW".
Hello
The other day asked me to write a sql statement that retrieves the number of weeks per year...with sample as
The above query returns the data correctly... but when I try:
(select yr
from
(select 1999+level yr
from dual
connect by rownum<level+1
)
)
select yr, to_char(to_date('30/12'||yr,'dd/mm/rrrr'),'WW') dt
from sample
(the difference is written in "BOLD", I get the same number of weeks for each year - which is obviously not correct)with sample as
Can someone describe why is this difference...?
(select YR
from
(select 1999+level YR
from DUAL
connect by rownum<level+1
)
)
select YR, TO_CHAR(TO_DATE('*31*/12'||YR,'dd/mm/rrrr'),'WW') DT
from sample
Note: I use db 10g v.2
Thank you
SIMHi, Sim,
sgalaxy wrote:
Hello
The other day asked me to write a sql statement that retrieves the number of weeks per year...A the applicant explains exactly what that means.
with sample as (select yrfrom(select 1999+level yrfrom dual connect by rownum
The above query returns the data correctly...
Is this really good? It seems to say that all ordinary years (i.e., the years with only 28 days in February) have 52 weeks, and all this leap years (years where there is a 29 February) have 53 weeks.
but when I try:
(the difference is written in "BOLD", I get the same number of weeks for each year - which is obviously not correct)Why not? Every year (at least in the Gregorian calendar) have the same number of months. Why every year cannot have the same number of weeks?
with sample as (select YRfrom(select 1999+level YRfrom DUAL connect by rownum
Can someone describe why is this difference...?
To study in detail what Peter said:
WW '01' is always January 1 to January 7.
WW '02' is always on January 8 to January 14.
WW '03' is always on 15 January until 21 January.
...
WW '08' is always from February 19 to February 25.
WW '09' is February 26 March 4 in common years, but in leap years, it is February 26 to March 3.
WW '10' is March 5 March 11 in common years, but in leap years, it is from March 4 to March 10.
...
WW '52' is December 24, but on 30 December in common years, but in leap years, it is December 23 to December 29.
WW '53' is December 31, (only 1 day) in common, but in leap years, it is December 30 and December 31.
It is therefore 31 December always in week '53'. December 30 is in week 52 ' in common years, but in leap years, it is in week 53'. Looking at the week which includes December 30, you get '52' to 3 over 4 years and 53' like clockwork every 4th year (except at the turn of the century most).According to the definition of "WW" for a week, calendar years always have all 52 weeks (seen 7 days each), plus 1 week defective (having only 1 or 2 days).
A different definition of a 'week' (and year) is the definition of ISO, where all weeks begin on Monday, and all the weeks have 7 days. The ISO year starts the Monday closest to January 1. Using these definitions, most years consist of 52 weeks, but every 5 or 6 years a year ago with 53 weeks.
The display of the query after the last day of several weeks of ISO and watch what week they are in (which is the total number of weeks this year from ISO).SELECT TO_CHAR ( TRUNC ( ADD_MONTHS ( DATE '2000-07-01' , 12 * LEVEL ) , 'IYYY' ) - 1 , 'DD-Mon-YYYY IYYY IW' ) AS iso_info FROM dual CONNECT BY LEVEL <= 25 ;
When I try to understand nested expressions, like the preceding, I find this helps them to read from the inside (i.e., the more deeply nested point) and then work outward.
ADD_MONTHS (DATE "2000-07-01', 12 * LEVEL") is 1 July of some year, which is in the middle of the ISO year.
TRUNC (ADD_MONTHS (DATE "2000-07-01', 12 * LEVEL"), "IYYY") is the first day of a year of ISO.
TRUNC (ADD_MONTHS (DATE "2000-07-01', 12 * LEVEL"), 'IYYY')-1 is the last day of a year of ISO.
The result of the above query is:ISO_INFO ------------------------ 31-Dec-2000 2000 52 30-Dec-2001 2001 52 29-Dec-2002 2002 52 28-Dec-2003 2003 52 02-Jan-2005 2004 53 01-Jan-2006 2005 52 31-Dec-2006 2006 52 30-Dec-2007 2007 52 28-Dec-2008 2008 52 03-Jan-2010 2009 53 02-Jan-2011 2010 52 01-Jan-2012 2011 52 30-Dec-2012 2012 52 29-Dec-2013 2013 52 28-Dec-2014 2014 52 03-Jan-2016 2015 53 01-Jan-2017 2016 52 31-Dec-2017 2017 52 30-Dec-2018 2018 52 29-Dec-2019 2019 52 03-Jan-2021 2020 53 02-Jan-2022 2021 52 01-Jan-2023 2022 52 31-Dec-2023 2023 52 29-Dec-2024 2024 52
There are many other ways to define the 'week' and 'year '.
For example, we could say that all weeks begin on Sunday and I have 7 days a year start the Sunday closest to January 1.
Another example: one could say that all weeks begin on Sunday and I have 7 days and a year beginning the first Sunday after December 31.
In any case, there's how many weeks in a year depends on what your definition of 'week' and 'year '. If you hear the word 'year' out of context, there is a good chance that the speaker refers to the period that begins on 1 January and ends on 31 December. If you hear "week" out of context, there is much less certainty what the speaker means. -
Could someone explain to me the meaning of:
To_char(hire_date-1,'d')
The question is:
Create a query that displays the emp surname, hire_date and the day began. The label for the Date column.
Sort the results by the day of the week from Monday.
Soln:
Select last_name, hire_date, TO_CHAR (hire_date, 'DAY') DAY
employees
order by TO_CHAR (hire_date-1, 'd');
How does the order of?Hello
Try to view the expression did you place your order BY and see:
select last_name , hire_date , TO_CHAR (hire_date, 'DAY') AS DAY , TO_CHAR (hire_date - 1, 'd') AS order_by_exp -- For testing only from employees order by TO_CHAR (hire_date - 1, 'd');
To_char ("dt," d ") returns '1' if dt is a Sunday,"2"If dt is a Monday,...,"7"If dt is a Saturday (depending on your settings for NLS_TERRITORY).
If you would be perfect for ORDER BY Sunday come first, but you want the first come Monday (1 day later). So if you subtract 1 day from dt and use
To_char (dt - 1, '), then you'll have an expression that returns the value '1' if dt is a Monday (and therefore, dt-1 is a Sunday), "2" If dt is a Tuesday (and dt-1 is a Monday),..., "7" If dt is a Sunday (dt-1 Saturday) and (depending on your settings for NLS_TERRITORY). -
Hi guys,.
Help needed here; I use the following code to create a report in Oracle APEX 3.0:
Select 'EBA_BT_PROBLEM '. "" ID "as the"BUG ID. "
'EBA_BT_PROBLEM '. "" Subject of "as"TOPIC ",.
'EBA_BT_URGENCY '. "" URGENCY_NAME "as a"PRIORITY. "
'EBA_BT_USER '. "" New_login_name "as" ASSIGNED to "
'EBA_BT_PROBLEM '. "' SUBMITTED_BY_ID ' as ' PRESENTED BY '.
of "EBA_BT_PROBLEM" INNER JOIN "EBA_BT_USER" ON "EBA_BT_PROBLEM". "" ASSIGNED_TO_ID "="EBA_BT_USER. " "" IDENTITY CARD ".
"JOIN THE"EBA_BT_URGENCY"ON"EBA_BT_PROBLEM" URGENCY_ID"="EBA_BT_URGENCY. " "" IDENTITY CARD ".
"JOIN THE"EBA_BT_STATUS"ON"EBA_BT_PROBLEM" BATCH.
= "EBA_BT_STATUS". "" IDENTITY CARD ".
"JOIN THE"EBA_BT_PRODUCT"ON"EBA_BT_PROBLEM" PRODUCT_ID.
= "EBA_BT_PRODUCT". "" IDENTITY CARD ".
"JOIN THE"EBA_BT_CATEGORY"ON"EBA_BT_PROBLEM" STUFF. "
= "EBA_BT_CATEGORY". "" IDENTITY CARD ".
where
TO_CHAR ("EBA_BT_PROBLEM". "Batch") = NVL (: P64_STATUS, to_char ("EBA_BT_PROBLEM".) " BATCH'))
It returns all the fields and the data I'm after, is the only issue I'm having with my 'where '. I have a drop down selection called P64_STATUS, box that lets choose me among several options that will give me in turn to report different results. He does this ok, but when it is set to the value 'null' or a default, I want to just give me all the possible lines to select it; Instead he gives me nothing.
So essentially, I need to correct the code in my where clause, I think especially here:
NVL (: P64_STATUS, to_char (* 'EBA_BT_PROBLEM'.)) (("" BATCH "*))
in order to give me what I'm after
I tried to explain what I'm after as best I can, any help would be much appreciated. Thank you!In APEX NULL values, or often "null %. Then you might want to check for this in your selection.
See also: http://www.inside-oracle-apex.com/display-null-yes-and-null-problem/
where (to_char("EBA_BT_PROBLEM"."STATUS_ID") = :P64_STATUS or :P64_STATUS is null or :P64_STATUS = '%null%')
You can also assign the value null to the selection list something like -1. Then the number conversion should work
where EBA_BT_PROBLEM.STATUS_ID = decode(:P64_STATUS, '-1', EBA_BT_PROBLEM.STATUS_ID, null, EBA_BT_PROBLEM.STATUS_ID, to_number(:P64_STATUS) )
Published by: Sven w. on April 27, 2011 17:29
Published by: Sven w. on April 27, 2011 17:31
-
using to_char ('date', IW) in a different way
Hello all;
I have the sample data below
and basically, I have the following sql to be changedcreate table table_one ( v_id varchar2(60), close_date date ); insert into table_one (v_id, close_date) values ('A', to_date('1/1/2010 4:47:09 PM', 'MM/DD/YYYY HH:MI:SS:AM')); insert into table_one (v_id, close_date) values ('A', to_date('1/2/2010 2:47:09 PM', 'MM/DD/YYYY HH:MI:SS:AM')); insert into table_one (v_id, close_date) values ('A', to_date('1/3/2010 1:47:19 PM', 'MM/DD/YYYY HH:MI:SS:AM')); insert into table_one (v_id, close_date) values ('D', to_date('1/4/2010 5:47:09 PM', 'MM/DD/YYYY HH:MI:SS:AM')); insert into table_one (v_id, close_date) values ('D', to_date('1/5/2010 4:47:09 PM', 'MM/DD/YYYY HH:MI:SS:AM')); insert into table_one (v_id, close_date) values ('D', to_date('1/6/2010 5:17:09 PM', 'MM/DD/YYYY HH:MI:SS:AM')); insert into table_one (v_id, close_date) values ('D', to_date('1/7/2010 5:17:09 PM', 'MM/DD/YYYY HH:MI:SS:AM')); insert into table_one (v_id, close_date) values ('D', to_date('1/8/2010 5:17:09 PM', 'MM/DD/YYYY HH:MI:SS:AM')); insert into table_one (v_id, close_date) values ('D', to_date('1/9/2010 5:17:09 PM', 'MM/DD/YYYY HH:MI:SS:AM')); insert into table_one (v_id, close_date) values ('D', to_date('1/10/2010 5:17:09 PM', 'MM/DD/YYYY HH:MI:SS:AM')); insert into table_one (v_id, close_date) values ('L', to_date('1/11/2010 5:17:09 PM', 'MM/DD/YYYY HH:MI:SS:AM')); insert into table_one (v_id, close_date) values ('L', to_date('1/12/2010 5:17:09 PM', 'MM/DD/YYYY HH:MI:SS:AM')); insert into table_one (v_id, close_date) values ('L', to_date('1/13/2010 5:17:09 PM', 'MM/DD/YYYY HH:MI:SS:AM')); insert into table_one (v_id, close_date) values ('L', to_date('1/14/2010 5:17:09 PM', 'MM/DD/YYYY HH:MI:SS:AM'));
select y.v_id, to_char(y.close_date, 'IW') as d_date from table_one y group by to_char(y.close_date, 'IW'), y.v_id;
However, although that's what I want insteadthis query gives me this output below V_ID D_DATE D 01 L 02 A 53
This is based on the ISO week. Thank you.V_ID D_DATE D 1/4/2010 - 1/10/2010 L 1/11/2010 - 1/17/2010 A 1/1/2010 - 1/3/2010
Any help is appreciatedHello
Thanks for posting the CREATE TABLE and INSERT statements; It is very useful.
It would be even more useful if you explain how you get the results you want from this sample data.
Rather than display the week number of the group, it seems that you want to display the first and last date of the group. Is this fair?If so:
SELECT y.v_id , TO_CHAR ( MIN (y.close_date) , 'fmMM/DD/YYYY' ) || ' - ' || TO_CHAR ( MAX (y.close_date) , 'fmMM/DD/YYYY' ) AS d_date FROM table_one y GROUP BY TO_CHAR (y.close_date, 'IW') , y.v_id;
-
How to create indexes based for TO_CHAR function
I need to create an index of feature based for the to_char.when function I tried, I got an error, "only pure function can be indexed".which the error really means, help me in the creation of the index in order to reduce my query cost.It works fine on my database. version 9iR2
create index IDX_TO_CHAR on emp(to_char(hiredate,'YYYY-MM-DD HH24:MI:SS')); explain plan for select hiredate from emp where to_char(hiredate,'YYYY-MM-DD HH24:MI:SS')='1981-05-01 00:00:00'; --------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| --------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 8 | 2 (50)| | 1 | TABLE ACCESS BY INDEX ROWID| EMP | 1 | 8 | 2 (50)| |* 2 | INDEX RANGE SCAN | IDX_TO_CHAR | 1 | | 2 (50)| --------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - access(TO_CHAR("EMP"."HIREDATE",'YYYY-MM-DD HH24:MI:SS')='1981-05-01 00 :00:00')
Your not seem to be a setting issue, then why not give us your sql and execution plan and so on.
There may be other ways to solve your sql as the creation of a function based index? -
Hello
Can someone this query?
Select last_name, hire_date, to_char(hire_date,'Day') day, to_char(hire_date-1,'d')
employees
order of to_char (hire_date-1, 'day');
AR,OK, maybe I explaining well...
You are displaying hiredate, but you order by hiredate - 1
As explained above, when you use the format mask 'day', he will order as 'Friday', 'Monday', 'Saturday', 'Sunday', 'Thursday', 'Tuesday', 'Wednesday' (for date of hire - 1) so when you view hiredate you will see in the order 'Saturday', 'Tuesday', 'Sunday', 'Monday', 'Friday', 'Wednesday', 'Thursday '.
The date format mask would be "on the other hand returns a number 1-7 for the day of the week, 1 being Sunday, so he removes 1 date of hiring and to convert a number from 1 to 7, so values when hiredate-1 is a Sunday will sort all first know where hiredate is a Monday and then will sort in the day of the order of the week from there."
Hope this clears up things.
-
To_char (number) gives error ORA-01481
Hi all
can someone help me with this delicate error?
Select double to_char(1234.56,'$99,999.99'); -> works
Select double to_char(1234.56,'$99G999D99'); -> works
Select double to_char(1234.56,'$99,999D99'); -> Error ORA-01481
Select double to_char(1234.56,'$99D999.99'); -> Error ORA-01481
Why?
In the reference SQL 11 g there are no written that. and should not be mixed with D and G...
Can someone explain to me why this happens?
Thank youMix of period and comma with D and G can lead to an inconsistent format model.
Actually G and D can be translated into comma or period comma depending on your NLS settings (and this may change at every moment and every session by session).
If Oracle cannot check if your template format is correct or not and triggers the error.Max
Maybe you are looking for
-
can I get rid of 36? He installed an update and now firefox does not at all
Firefox 36 is seriously broken He updated on my computer and now does not work. I tried all the suggestions and no help... don't come back to IE
-
HP Jet 7 Tablet 5709: 7 HP flow will not reset recover
I went to reset the tablet to factory deleting all my files, etc. The Tablet has a 32 GB card in addition to the main unit. During the recovery process, a message appeared that the reset was able to complete. A Cancel button was presented to that I p
-
Toshiba accessibility TACSPROP (Fn keys) does not work on my Satellite A100
Laptop A100-097 I am facing a problem with the extraordinary on my keyboard * FN keys * managed by program "* TACSPROP.exe*" which is located in *C:\Programmi\Toshiba\Utilities\.*This program does not start automatically at startup and if I manually
-
What are the valid software causes of failure "Genuine software" test
Running Vista pre installed on the HP laptop. Have happened 'goes; idation' many times and now does not
-
Hello I have two U3415w connected to a Lenovo docking station. The docking station has two Displayports and one HDMI. Display #1 is connected via HDMI from the dock to the monitor, display #2 is connected via a HDMI cable to DisplayPort adapter then