「リレーション/プロシージャ/ビューのコンテキストが多すぎます。最大許容数は 255 です」 - エラーを生成する大きな firebird sql クエリがあります。
私はそれを見ましたが、それを減らす方法がわからないので、上記のエラーは発生しなくなりました。
クエリは、その年の週ごとのカウントを返します。何もない場合、その週の 0 が返されます。1 年の 52/53 週すべてが正しいカウントまたは 0 で含まれている必要があります。
使用するリレーション/プロシージャ/ビューが 255 未満の場合、クエリは正常に機能しますが、52/53 週間すべてで同じ結果が得られるようにクエリを減らす方法を見つける必要があります。
Select "Week"||''||"Year" as "Week", "Courses"
From (
select ' 02 Jan ' as "Week", (select count(Distinct crs.ID)from comp_Invoice IV
inner join Course CRS on IV.COD_COURSE=CRS.id
where extract(week from BOOKING_DATE) = 1
and BOOKING_DATE between :StartDate and :EndDate
and crs.c_type = 'OS'
and crs.name not like '%Cancel%'
and crs.name not like 'CERT'
and crs.name not like '%cancel%'
and crs.name not like '%CANCELl%'
and crs.name not like '%CANCELL%'
and crs.version not like 'CONSTRUC%'
and crs.version Like :CoursesTitle ) as "Courses",
extract(year from IV.BOOKING_DATE) as "Year",
01 as "Sorter"
from comp_Invoice IV
inner join Course CRS on IV.COD_COURSE=CRS.id
where
BOOKING_DATE between :StartDate and :EndDate
and crs.c_type = 'OS'
and crs.name not like '%Cancel%'
and crs.name not like 'CERT'
and crs.name not like '%cancel%'
and crs.name not like '%CANCELl%'
and crs.name not like '%CANCELL%'
and crs.version not like 'CONSTRUC%'
and crs.version Like :CoursesTitle
group by 3
UNION
select ' 09 Jan ' as "Week", (select count(Distinct crs.ID)from comp_Invoice IV
inner join Course CRS on IV.COD_COURSE=CRS.id
where extract(week from BOOKING_DATE) = 2
and BOOKING_DATE between :StartDate and :EndDate
and crs.c_type = 'OS'
and crs.name not like '%Cancel%'
and crs.name not like 'CERT'
and crs.name not like '%cancel%'
and crs.name not like '%CANCELl%'
and crs.name not like '%CANCELL%'
and crs.version not like 'CONSTRUC%'
and crs.version Like :CoursesTitle ) as "Courses",
extract(year from IV.BOOKING_DATE) as "Year",
02 as "Sorter"
from comp_Invoice IV
inner join Course CRS on IV.COD_COURSE=CRS.id
where
BOOKING_DATE between :StartDate and :EndDate
and crs.c_type = 'OS'
and crs.name not like '%Cancel%'
and crs.name not like 'CERT'
and crs.name not like '%cancel%'
and crs.name not like '%CANCELl%'
and crs.name not like '%CANCELL%'
and crs.version not like 'CONSTRUC%'
and crs.version Like :CoursesTitle
group by 3
UNION
select ' 16 Jan ' as "Week", (select count(Distinct crs.ID)from comp_Invoice IV
inner join Course CRS on IV.COD_COURSE=CRS.id
where extract(week from BOOKING_DATE) = 3
and BOOKING_DATE between :StartDate and :EndDate
and crs.c_type = 'OS'
and crs.name not like '%Cancel%'
and crs.name not like 'CERT'
and crs.name not like '%cancel%'
and crs.name not like '%CANCELl%'
and crs.name not like '%CANCELL%'
and crs.version not like 'CONSTRUC%'
and crs.version Like :CoursesTitle ) as "Courses",
extract(year from IV.BOOKING_DATE) as "Year",
03 as "Sorter"
from comp_Invoice IV
inner join Course CRS on IV.COD_COURSE=CRS.id
where
BOOKING_DATE between :StartDate and :EndDate
and crs.c_type = 'OS'
and crs.name not like '%Cancel%'
and crs.name not like 'CERT'
and crs.name not like '%cancel%'
and crs.name not like '%CANCELl%'
and crs.name not like '%CANCELL%'
and crs.version not like 'CONSTRUC%'
and crs.version Like :CoursesTitle
group by 3
--** Same code and union is repeated 52 times one per week of the year**--
)
Group by 1,2,3,4
Order By 3,4 ASC
クエリを減らして同じ結果を得る方法について誰かが明るいアイデアを持っている場合は、投稿してください。よろしくお願いします。