如何将此查询转换为也返回相同(字段)表的存储过程:
SELECT R.REGION_NAME,
TP.TERRITORY_NAME,
LSC.LOOKUP_NAME,
CAST (WM_CONCAT (CM.CUST_NAME) AS VARCHAR2 (500)) AS CUST_NAMES,
TP.VIEWER_PROFILE,
TP.CASTING_PREFERENCE,
TP.PROG_TYPE_PREFERENCE,
STN_LIST.STN_NAMES,
STN_LIST.LIC_RIGHTS
FROM TERRITORY_PROFILE_MSTR TP
INNER JOIN
REGION_MSTR R
ON TP.REGION_ID = R.REGION_ID
LEFT OUTER JOIN
LOOKUP_SUB_CATEGORY LSC
ON TP.BROADCAST_STD_CD = LSC.LOOKUP_SUB_CAT_ID
LEFT OUTER JOIN
CUST_MSTR CM
ON CM.TERRITORY_ID = TP.TERRITORY_ID
LEFT OUTER JOIN
(SELECT CAST (WM_CONCAT (SLR.CUST_STN_NAME) AS VARCHAR2 (500))
AS STN_NAMES,
CAST (WM_CONCAT (LRM.LIC_RIGHTS_ID) AS VARCHAR2 (500))
AS LIC_RIGHTS,
SLR.CUST_COMPETITOR_ID AS CUST_ID
FROM STN_LIC_RIGHTS SLR, LIC_RIGHTS_MSTR LRM
WHERE SLR.STN_LIC_ID = LRM.LIC_RIGHTS_ID
GROUP BY SLR.CUST_COMPETITOR_ID) STN_LIST
ON STN_LIST.CUST_ID = CM.CUST_ID
WHERE TP.TERRITORY_ID <> 0
GROUP BY TP.TERRITORY_NAME,
R.REGION_NAME,
LSC.LOOKUP_NAME,
STN_LIST.STN_NAMES,
STN_LIST.LIC_RIGHTS,
TP.VIEWER_PROFILE,
TP.CASTING_PREFERENCE,
TP.PROG_TYPE_PREFERENCE
ORDER BY R.REGION_NAME, TP.TERRITORY_NAME
我想我不需要指定表结构。请注意,查询功能齐全,并且值以我期望的方式正确返回。
谢谢你。
更新:
存储过程必须通过 SQL Server Reporting Services 或 SSRS 在 ASP.NET(C#) 中兼容和可执行。