Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to join one dynamic date table with my own table

LuffyMar 12 2021 — edited Mar 12 2021

Hi every one,
My structure table named A is shown as below
image.pngNow I want to write report shows student_number, morning, lunch, evening from 01/3 to 30/6 for each day.
My method is
Create a dynamic date table from start_date and end date from table A with sql code:
select A.student_number, A.morning, A.lunch, A.evening,
(to_DATE(r.start_date,'dd/mm/RRRR') - 1) + LEVEL dtl,
to_number(TO_char(to_date((to_date(r.start_date,'dd/mm/rrrr') - 1) + LEVEL), 'DD')) dates,
to_number(TO_char(to_date((to_date(r.start_date,'dd/mm/rrrr') - 1) + LEVEL), 'MM')) monthss
FROM A r
CONNECT BY LEVEL <= to_DATE(r.end_date,'dd/mm/RRRR') - (to_DATE(r.start_date,'dd/mm/RRRR') - 1)
But it get error when running to end_date day , it stills continue for end_date day (I dont't know how to fix that).
And run that sql statement is very low.
Anyone have a better idea? Thank you for your time and in advance.

This post has been answered by Luffy on Mar 12 2021
Jump to Answer

Comments

Alex Keh-Oracle

I tried your C# app with a table using a DATE column and TIMESTAMP column. In both cases with either ODP.NET Core 2.19.80 or 2.19.70, I didn't hit an error. I used DB 19c. Which DB version did you use?

4252326

I found out that there must be at least one record in the table. For example:

Table Design:

Name
Type
Size
IDNumber0
DateDATE7
TimeTIMESTAMP0
Time2INTERVAL DAY TO SECOND0

Table Data:

ID
DateTimeTime2
1(Null)(Null)(Null)

Then replace the [column] in the sql below:

var sql = $"select(CASE WHEN 1 = 0 THEN a.\"[column]\" ELSE NULL END) as C0 from \"YOUR TABLE NAME\" a ";

 

[Date]: reproduced

[Time]: can't reproduce

[Time2]: reproduced

DB version: 11/12/18/19c

Alex Keh-Oracle

I added the interval column and added one row of data, but still can't reproduce the problem with the 2.19.80 version against the data or interval column. Do you want to send us your trace? Just add these two lines and run your app.

OracleConfiguration.TraceFileLocation = @"D:\traces";

OracleConfiguration.TraceLevel = 7;

You can send the trace file to dotnet_us (at) oracle.com.

4252326

Thank you. The email has been sent. I hope it's useful to you.

Alex Keh-Oracle

This bug appears to be the same as Bug 26123054.

4252326

Will this problem be fixed recently?

Alex Keh-Oracle

The bug hasn't been fixed yet. We're still evaluating the root cause.

Alex Keh-Oracle
Answer

The bug has been fixed in our main code line. My expectation is that the fix will be in the ODP.NET Core 19.10 release.

Marked as Answer by 4252326 · Sep 27 2020
1 - 8

Post Details

Added on Mar 12 2021
4 comments
531 views