I need help. is there a setting to allow the display of timestamps in tables?
the database is part of my job however a senior analyst of mine queried the same code and his managed to show the timestamps next to the date, mine doesnt. he told me there is a setting and asked me to search on my own.
I am using Version 4.1.2.20 of Oracle SQL Developer Build MAIN-20.64
Here is the table
Some GUI have their own settings for things like timestamp formats, and they ignore your NLS settings. (I find that quite annoying. Toad does that, among others.)
SQL Developer is good: it has such settings (you can hunt them down and use them), but you can also change them with standard SQL statements. What you need is something like
alter session set nls_timestamp_format = 'yyyy-mm-dd hh24:mi:ss.ff6';
(assuming you need six decimal places for the second, and the format model is the one you need). Use whatever format you require; but only fools (including, alas, Oracle itself!) use two-digit numbers for the year.
Something to pay attention to though: what is the data type of column created_dt? If it is date, for example, you will need to change nls_date_format (which doesn't take decimals for seconds); if it's timestamp with time zone then you will need to give a format including time zone elements, and you will need to change nls_timezone_tz_format.
You can also find these settings (and change them directly there - the valid formats are the same) in SQL Developer under
>> Tools >> Preferences >> Database >> NLS
Related
We have an ApEx data entry site that is translated into both Mexican Spanish and Canadian French. One of the critical columns on most data tables is the date associated with the data. As such, there are date picker fields for each time this value is needed.
The translations automatically display the month code based on the current language (a date picked in January on the Spanish site will display 'Ene' for enero). Before the date is recorded to the DB, the application format mask 'DD-MON-RR' is applied; this understands the current language and records the value on the DB in English.
The issue is that the month of December (diciembre) is showing the abbreviation of 'Dec' rather than 'Dic'. As a result, error ORA-01843 (not a valid month) is generated and the data is not saved. However, if the entry is manually changed to ##-Dic-##, the value is recorded correctly without error.
This makes it appear that the automatically-generated month abbreviation for this language is incorrect. Is this a known error with a solution?
I don't know anything about globalization, my Apex applications are in Croatian only. However, as a workaround, perhaps you could switch to another date format mask, such as DD.MM.YYYY; doing so, you wouldn't depend on language differences.
I'm trying to create a report that can switch between English and (Canadian) French number formatting (1,234.56 vs 1 234,56) but am having some troubles.
Before I get into what I have tried I'd like to say that in the past we have always converted the French number to a character, and than made the appropriate string modifications there, but this obviously isn't the best solution and I'm trying to find something better going forward.
The first thing I tried doing was adding the following line to the BEFORE REPORT trigger in the Oracle Report itself:
srw.do_sql ('alter session set nls_numeric_characters = '', ''');
I have my number fields set up with the format mask "(NNNGNNNGNN0D00)" so I would assume the G's and D would use the session's NLS_NUMERIC_CHARACTERS setting but they don't seem to.
To see if the setting was actually changing I created the following query in the report and displayed it's output:
select value from nls_session_parameters
where parameter = 'NLS_NUMERIC_CHARACTERS';
Sure enough the output changed from '.,' to ', ' using my alter session command.
After researching some more online I read that the change really needs to be made in the Oracle Report Server configuration as per this documentation - http://docs.oracle.com/cd/B14099_19/bi.1012/b14048/pbr_conf.htm#i1013352
I contacted the team responsible for our Oracle Application Server and had them try inserting the configurations we need to set up English and French number formatting and they added in the following:
<environment id="EN">
<envVariable name="NLS_LANG" value="AMERICAN_AMERICA.WE8ISO8859P1"/>
</environment>
<environment id="FR">
<envVariable name="NLS_LANG" value="FRENCH_CANADA.WE8ISO8859P1"/>
<envVabiable name="NLS_NUMERIC_CHARACTERS" value="', '"/>
</environment>
The report server was restarted and I entered in the URL to request the report, along with the ENVID=FR parameter, but still no luck. The report runs but the number formatting is still using the ,'s and .'s for grouping and decimal separation.
Does anyone know what we're missing or what else we could try?
I had the same issue and did to_char() where that NLS format needs to apply.
I'm in the process of migrating our Data Warehouse from Oracle to SQL Server 2012.
One piece of code I use a hundred times a day in Oracle is changing the date format for a query by using something like:
To_Char(entry_date,'WMMYY') = 30612
The above allows me to grab the date (default format = DD-MON-YY eg 01-JAN-12) and change the format for the week specified (the third week of June in the above example) by simply listing the week desired.
In my mind the above is very simple and easy to use. I can change it to whatever format I want (MMYY, MMYYYY) etc. without any issues. So far I cannot figure out an easy way to do this in SQL Server 2012 and it's really starting to bother me. It's datetime2 in SQL Server.
I'm finding stuff for CAST(), CONVERT(), DATEPART() but from what I've seen there is all kinds of wacky coding and number codes (like 101, 102, I don't understand why this is) required which just seems extraneous and over complicated to me.
Have I just not found what I'm looking for yet or is this just the way it is with SQL Server? I just want to be able to do something simple like grab all the data that was entered in during the month of june or the second week of october without having to add 200 extra characters of code.
It's a switch. You are using SQL Server 2012, so look into FORMAT() function. http://technet.microsoft.com/en-us/library/hh213505%28SQL.110%29.aspx I'm not, so unfortunately I can't test anything out for you - but there are some date formatting improvements.
For those of us who aren't - , there are things you can do that will be great - once you get used to them. This isn't specific to SQL Server - but Week of Month varies from organization to organization - so you'd have to define that to get a good example for 3rd week of month, etc. Also, when using DATEPART with week or day arguments, what gets returned is determined by the setting for the first day of the week (1 -7 - ##DATEFIRST). The numeric styles for CONVERT (again check out FORMAT() if you're on 2012) are definitely not as intuitive - but you'll probably be using the same styles over and over, and you'll have them memorized quickly. If you are set on 'WMMYY' or just use something over and over that doesn't have a satisfactory built in solution- create a UDF.
data that was entered in during the month of june
DATEPART(mm,#date) = 6
current month
month(getDate())
Or this week
DATEPART(ww,GetDate())
I'm having trouble with the number formatting in Apex 3.2.1. NLS_TERRITORY is set to GERMANY, NLS_LANGUAGE to GERMAN. However, the default number formatting is wrong and I would like to fix/change it. I'm wondering why there is an application date format setting but no application number format setting. That would have been really helpful right now. So my question is: how can I set a new number format which will be applied everywhere in my application? Is it possible? If not, what would be the least painful way to to apply the new format mask. I'm mainly concerned with interactive reports. Additionally, if it were possible to change the default format mask for the territory in some configuration file, that would also be an option. Thanks for your input in advance.
Edit:
My problem with the default format is that numbers like 0.34 are being displayed as ",34", but the correct output would be "0,34".
Okay, purely the display then. I don't think there is an easy way to do this for all your fields, but specifying a format mask on those fields, by using for example FM999G999G990D000.
That would be annoying for a lot of fields across the application though, i agree. It is even more annoying when only by specifying a format mask, items are recognised as being number fields. Maybe making a plugin, which is identical to a number field, but with a default format mask may do the trick.
Or query the apex views to find items, then update them (though you will need access to the 'internal' tables of apex, the wwv_* things).
select application_name, page_id, page_name, item_name, display_as, display_as_code, format_mask from apex_application_page_items where page_id = 6
Which you could then transform into an update...
I've nothing else to offer, so far i've always specified the format mask during development...
Does hibernate have any mapping for this oracle data type:(10G)
TIMESTAMP(6) WITH TIME ZONE
I am getting:
No Dialect mapping for JDBC type: -101
My manager does not want to do the: registerHibernateType(-101, Hibernate.getText().getname())
He thinks it is too much.:)
What alternative can I have?
The answer you provide to yourself is more like a workaround than a proper solution. For the sake of the visitors looking for an answer, I'll provide my view on this:
1) Database date-based fields should be always set to UTC, never with a specific timezone. Date calculation with timezone information is an unneeded complexity. Remember that timezones usually changes twice a year for a lot of countries in the world ("daylight saving time"). There's a reason why only a few RDMBS' supports this, and there's a reason why Hibernate developers refuse to support this data-type. The patch for Hibernate is simple enough (one line of code), the implications aren't.
2) Converting your "timestamp with timezone" to a String will only cause problems later. Once you retrieve it as String, you'll need to convert it again to a Date/Calendar object, an unneeded overhead. Not to mention the risks associated with this operation.
3) If you need to know in which timezone is some user, just store the String representing the timezone offset (like "Europe/Prague"). You can use this in Java to build a Calendar with date/time and timezone, as it'll take care of DST for you.
For now, I solved the problem by:
`select TO_CHAR(TRUNC(field)) from table` //field is the one having type= timestamp with timezone
This ensures that when the query returns, the field has datatype 'String'