SSRS 2016 Oracle Date Casting Fails - oracle

After upgrading from SSRS 2012 to 2016, we've had to rewrite all of our reports because of an issue with SSRS giving ORA-01830: date format picture ends before converting entire input string.
The code that causes the issue is below:
WHERE (
trunc(date_processed) BETWEEN NVL(:start_date,:subscription_start_date) AND NVL(:end_date,:subscription_end_date)
)
Start/End_date are both null at the beginning of the report execution. subscription_start/end_date is NEVER null and is always set. To make things even more frustrating, the following works fine:
WHERE (
trunc(date_processed) BETWEEN NVL(:start_date ,'01-JAN-1848') AND NVL(:end_date,'31-DEC-2039')
and trunc(date_processed) BETWEEN :subscription_start_date and :subscription_end_date
)
The issue, however, is that now the :start_date parameter can not override the subscription date parameter when it is set by the user.
This did not occur on previous versions. This is happening to ALL reports we have which isn't a few.

Setting the variable parameters in SSRS to text and using TO_DATE resolved similar situations for me using SSRS with an Oracle source.
WHERE ( trunc(date_processed) BETWEEN NVL(TO_DATE(:start_date,'mm/dd/yyyy'),TO_DATE(:subscription_‌start_date,'mm/dd/yy‌​yy')) AND NVL(TO_DATE(:end_date,'mm/dd/yyyy'),TO_DATE(:subscription_en‌​d_date, 'mm/dd/yyyy') )

We were able to get around this issue by using an expression to format the date parameters on the output Dataset Parameter Properties with the following formulas.
=Format(Parameters!BeginDate.Value, "dd/MMM/yyyy")
=Format(Parameters!EndDate.Value, "dd/MMM/yyyy")

Related

Oracle SQL Developer Debugger Date Parameter is always NULL

I am using SQL Developer Version 21.4.1.349.
I am using the interactive debugger with a procedure that accepts a Date parameter.
When the debugger launches, it presents a dialog so that I can provide a value for the parameter.
But, I don't know how to provide the date value. I have tried the following:
providing a date string in the format of my NLS setting.
providing to_date('12/27/2022 10:20:00','mm/dd/yyyy hh24:mi:ss')
Neither test worked. The date parameter is just set to NULL.
Is there a specific way a Date parameter should be provided when using the debugger?
Thanks

Change Output Result date/time format of Oracle Query with Visual Studio Code

I am using Visual Studio Code ( Version 1.59.0 ) with Oracle Developer Tools for VS Code as Extension and i want to change the output results .
Currently , with Oracle SQL Developer ( Version 20.4.1.407 ) I have the following results for dates :
Format 1
Format 2
Where, at my VS Code, the output for the same query return as :
Format 1
Format 2
My system format date does not equals to the output ( and that is ok, not a problem here , but also, not a solution ).
So, what i need to do or go to have an option to change the output result format for the date and time ? =)
Thank you all =)
Before you issue the query (in the same session) issue ALTER SESSION SET nls_date_format='your_date_format_here'
https://docs.oracle.com/en/database/oracle/oracle-database/19/refrn/NLS_DATE_FORMAT.html#GUID-FC23EEEE-AA9F-4B3C-8CBB-888C9C0CA27F
https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/Format-Models.html#GUID-EAB212CF-C525-4ED8-9D3F-C76D08EEBC7A
At some point we plan to add a feature to automatically execute commands like this with each session that is established (eg via a login.sql file or similar), but for now you will need to do it yourself or use a login trigger (if you are reading this post in the future, check for the login.sql feature first).

Oracle Date to_char Returns Different Results

I have a database on my local development machine and there is a database on our test server. Basically, the tables on my dev machine were copied over from the test machine.
However, I have found a difference in how the same date is treated by the to_char function. On my development machine if I run the following query:
select test_date, to_char(test_date, 'YYYY-MM-DD')
from test.table
where id = 'C0007784'
I get the following results:
31-DEC-99 1999-12-31
On the test server running the same query against the same schema and data I get the following:
31-DEC-99 1899-12-31
Could this difference in behaviour of to_char be due to a setting being different in the two Oracle instances?
If I run SELECT value FROM v$nls_parameters WHERE parameter ='NLS_DATE_FORMAT'; I get DD-MON-RR for both instances.
So you exported the contents of the table to a csv file using DD-MON-YY format. YY obviously causes ambiguity. I guess that when you were importing the file, 99 was interpreted as 1999 instead of 1899. I don't know the exact mechanism which is used by database to guess the full year, but anyway Oracle strongly recommends YYYY in date format:
Note: Oracle recommends that you use the 4-digit year element (YYYY)
instead of the shorter year elements for these reasons: The 4-digit
year element eliminates ambiguity.
The shorter year elements may affect query optimization because the
year is not known at query compile time and can only be determined at
run time.

Oracle query not working properly in SSIS

I am facing a strange problem , when I connecting Oracle from SSIS and running below query it is not applying filter criteria
SELECT * FROM Table_Schema.Table_Name where trunc(Date_Column) >='01-APR-14'
but this is giving me data older than 01 April also. But when I am running same query in Oracle it is working absolutely fine.
What is wrong here?
Have you tried applying a format mask to the date you are passing in - you should always do this by default. You could substitute your date for sysdate (or getdate() in sqlserver) and see if it performs correctly. Also try removing the trunc.

Crystal Reports Issue turning a string into a number

I'm having one of those throw the computer out the window days.
I am working on a problem involving Crystal Reports (Version 10) and an Oracle Database (11g).
I am taking a view from the database that returns a string (varcahr2(50)) which is actually a number, when a basic SELECT * query is run on this view I get the number back in the format 000000000000100.00.
When this view is then used in Crystal Reports I can view the field data, but I can't sum the data as it is not a number.
I began, by attempting to using ToNumber on the field, to which Crystal's response was that the string was not numeric text. Ok fair enough, I went back to the view and ran TO_NUMBER, when this was then used in crystal it did not return any results. I also attempted to run TO_CHAR on the view so that I could hopefully import the field as text and then perform a ToNumber, yet the same as with the TO_NUMBER no records were displayed.
I've started new reports, I've started new views. No avail.
This seems to have something to do with how I am retrieving the data for the view.
In simplistic terms I'm pulling data from a table looking at two fields a Foreign Key and a Value field.
SELECT PRIMARY_KEY,
NVL(MAX(DECODE(FOREIGN_KEY, FOREIGN_KEY_OF_VALUE_I_NEED, VALUE_FIELD)), 0)
FROM MY_TABLE
GROUP BY PRIMARY_KEY
When I attempted to put modify the result using TO_NUMBER or TO_CHAR I have used it around the VALUE_FIELD itself and the entire expression, wither way works when the run in a SQL statement. However any TO_NUMBER or TO_CHAR modification to the statement returns no results in Crystal Reports when the view is used.
This whole problem smacks of something that is a tick box or equivalent that I have overlooked.
Any suggestions of how to solve this issue or where I could go to look for an answer would be greatly appreciated.
I ran this query in SQL Developer:
SELECT xxx, to_number(xxx) yyy
FROM (
SELECT '000000000000100.00' XXX FROM DUAL
)
Which resulted in:
XXX YYY
000000000000100.00 100
If your field is truly numeric, you could create a SQL Expression field to do the conversion:
-- {%NUMBER_FIELD}
TO_NUMBER(TABLE.VALUE_FIELD)
This turned out to be an issue with how Crystal Reports deals with queries from a database. All I needed to do was contain my SQL statement within another Select Statement and on this instance of the column apply the TO_NUMBER so that Crystal Reports would recognize the column values as numbers.
Hopefully this helps someone out, as this was a terrible waste of an afternoon.

Resources