как правильно? выдаёт не верное завершение запроса
REQUEST.REQUEST_NAME,
REQUEST.REQUEST_NUMBER,
REQUEST.ID,
REQUEST.DATE_CREATE,
REQUEST.DATE_CLOSE,
CHANGE_LIST.OLD_RECORD,
CHANGE_LIST.NEW_RECORD,
CHANGE_LIST.ID
FROM REQUEST,
REQUEST_CAD_FOLDER,
CAD_FOLDER,
CHANGE_LIST
WHERE CAD_FOLDER.CAD_NUMBER = :cad_num
AND REQUEST_CAD_FOLDER.REQUEST_ID = REQUEST.ID
AND REQUEST_CAD_FOLDER.CAD_FOLDER_ID = CAD_FOLDER.ID
AND CHANGE_LIST.REQUEST_ID = REQUEST.ID
UNION
SELECT
CO.CAD_NUM AS cad_number,
SREZ.ID AS SREZ_ID,
CO.ID AS CAD_NUMBER_ID,
SREZ.EDOC_INFO_ID AS EDOCINFO_ID,
SREZ.REQUEST_ID as rid
FROM
((zkoks.reg srez left outer join
zkoks.obj co on srez.obj_id = co.ID)
left outer join request.request_new_obj rn on CO.CAD_NUM = RN.CAD_NUMBER )
left outer join request.request r on RN.REQUEST_ID = R.ID
WHERE R.REQUEST_NUMBER = :req_num
),
FindByCadNumber as
(
SELECT
CO.CAD_NUM AS cad_number,
SREZ.ID AS SREZ_ID,
CO.ID AS CAD_NUMBER_ID,
SREZ.EDOC_INFO_ID AS EDOCINFO_ID,
SREZ.REQUEST_ID as rid
FROM
zkoks.obj co join
zkoks.reg srez on srez.obj_id = co.ID
WHERE CO.CAD_NUM =:cad_num
)
SELECT * FROM FindByRequest
WHERE not(:cad_numORreq_num is null)
RequestIDs
on CadNumIDs.rid = RequestIDs.rid
Число открывающих скобок не соответствует числу закрывающих.
Код:
SELECT
CAD_FOLDER.CAD_NUMBER, //1
REQUEST.REQUEST_NAME, //2
REQUEST.REQUEST_NUMBER, //3
REQUEST.ID, //4
REQUEST.DATE_CREATE, //5
REQUEST.DATE_CLOSE, //6
CHANGE_LIST.OLD_RECORD, //7
CHANGE_LIST.NEW_RECORD, //8
CHANGE_LIST.ID //9
FROM
REQUEST,
REQUEST_CAD_FOLDER,
CAD_FOLDER,
CHANGE_LIST
WHERE CAD_FOLDER.CAD_NUMBER = :cad_num
AND REQUEST_CAD_FOLDER.REQUEST_ID = REQUEST.ID
AND REQUEST_CAD_FOLDER.CAD_FOLDER_ID = CAD_FOLDER.ID
AND CHANGE_LIST.REQUEST_ID = REQUEST.ID
UNION
SELECT
CO.CAD_NUM AS cad_number, //1
SREZ.ID AS SREZ_ID, //2
CO.ID AS CAD_NUMBER_ID, //3
SREZ.EDOC_INFO_ID AS EDOCINFO_ID, //4
SREZ.REQUEST_ID AS rid //5
FROM ...
CAD_FOLDER.CAD_NUMBER, //1
REQUEST.REQUEST_NAME, //2
REQUEST.REQUEST_NUMBER, //3
REQUEST.ID, //4
REQUEST.DATE_CREATE, //5
REQUEST.DATE_CLOSE, //6
CHANGE_LIST.OLD_RECORD, //7
CHANGE_LIST.NEW_RECORD, //8
CHANGE_LIST.ID //9
FROM
REQUEST,
REQUEST_CAD_FOLDER,
CAD_FOLDER,
CHANGE_LIST
WHERE CAD_FOLDER.CAD_NUMBER = :cad_num
AND REQUEST_CAD_FOLDER.REQUEST_ID = REQUEST.ID
AND REQUEST_CAD_FOLDER.CAD_FOLDER_ID = CAD_FOLDER.ID
AND CHANGE_LIST.REQUEST_ID = REQUEST.ID
UNION
SELECT
CO.CAD_NUM AS cad_number, //1
SREZ.ID AS SREZ_ID, //2
CO.ID AS CAD_NUMBER_ID, //3
SREZ.EDOC_INFO_ID AS EDOCINFO_ID, //4
SREZ.REQUEST_ID AS rid //5
FROM ...