Добрый день всем. Совсем не вижу, где я число некорректно написал... Помогите найти ошибку в sql скрипте, пожалуйста. P.S.: ошибку выдает без указания неправильной строки или еще чего. Если кто то спросит.
select distinct
'childal',
child.id,
child.municid,
dateend,
(select ADOPTACCESSPACKAGE.getrealchildfio(child.id, child.municid, 1)from dual) as ФИО,
(select ADOPTACCESSPACKAGE.GETREALCHILDBIRTHDAY(child.id, child.municid, 1)from dual) as Дата_рождения,
coalesce(
(select t.ustr
from (select q.ustr, q.datebegin, q.childid, q.municid
from (select childid, municid, 'Опека' as ustr, dateend, datebegin
from guardian
where datebegin is not null and (dateend is null or dateend is not null and to_date(dateend,'dd.mm.yyyy')>sysdate)
union select childid, municid, 'Предварительная опека' as ustr, dateend, datebegin
from prevguardian
where datebegin is not null and (dateend is null or dateend is not null and to_date(dateend,'dd.mm.yyyy')>sysdate)
union select childid, municid, 'Приёмная семья' as ustr, dateend, datebegin
from foster
where datebegin is not null and (dateend is null or dateend is not null and to_date(dateend,'dd.mm.yyyy')>sysdate)
union select childid, municid, 'Усыновление' as ustr, dateend, datebegin
from adopt
where datebegin is not null and (dateend is null or dateend is not null and to_date(dateend,'dd.mm.yyyy')>sysdate)
union select childid, municid, 'Патронат' as ustr, dateend, datebegin
from patronat
where datebegin is not null and (dateend is null or dateend is not null and to_date(dateend,'dd.mm.yyyy')>sysdate)
union select childid, municid, 'Учреждения для детей-сирот и детей оставшихся б/п' as ustr, dateend, datebegin
from internat
where datebegin is not null and (dateend is null or dateend is not null and to_date(dateend,'dd.mm.yyyy')>sysdate)
union select childid, municid, 'Учреждения временного содержания' as ustr, dateend, datebegin
from temporaryhouse
where datebegin is not null and (dateend is null or dateend is not null and to_date(dateend,'dd.mm.yyyy')>sysdate)
union select childid, municid, 'Патронаж' as ustr, dateend, datebegin
from patronag
where datebegin is not null and (dateend is null or dateend is not null and to_date(dateend,'dd.mm.yyyy')>sysdate)
)q
order by to_date(q.datebegin,'dd.mm.yyyy')desc
)t
inner join child
on t.childid = child.id
where rownum <= 1 and t.municid = child.municid),
'Нет действующего устройства'
) as Устройство,
(select UTILSFUNCTIONPACKAGE.getnameregion(child.municid, 0)from dual) As Район
from child
inner join (
(
select childid, municid, dateend
from (select mu.childid, mu.municid, mu.datebegin, mu.dateend
from (select childid, municid, datebegin, dateend
from guardian
where datebegin is not null
union select childid, municid, datebegin, dateend
from prevguardian where datebegin is not null
union select childid, municid, datebegin, dateend
from foster
where datebegin is not null
union select childid, municid, datebegin, dateend
from adopt
where datebegin is not null
union select childid, municid, datebegin, dateend
from patronat
where datebegin is not null
union select childid, municid, datebegin, dateend
from internat
where datebegin is not null
union select childid, municid, datebegin, dateend
from temporaryhouse
where datebegin is not null
union select childid, municid, datebegin, dateend
from patronag
where datebegin is not null
) mu, child
where child.municid = mu.childid and
mu.municid = child.municid and
mu.datebegin is not null and
to_date(mu.datebegin, 'dd.mm.yyyy') = to_date('02.08.2017','dd.mm.yyyy')
)
)
)z
on z.childid = child.id and
z.municid = child.municid
inner join people
on people.id = child.peopleid and
people.municid = child.municid
where child.param <> 1 and
child.municid in ('{BA986261-AC49-4F7B-AC0D-8B4A6AFD9364}', '{FE00E848-55B3-4E7F-8E15-8DB24F132A45}')
order by 5 asc;
to_date
. То есть с точки зрения синтаксиса запрос скорее всего написан правильно и ошибка выскакивает при его выполнении.child.param <> 1
если после param в БД символьное и в какой от записи попавшей под выборку в этом поле лежит не число. не видя структуры ваших таблц и данных что то конкретное посоветовать невозможно