2
是否有空格或其他非打印字符可以插入到不會被刪除並導致NULL的varchar2列中?在Oracle 11g中的varchar2中存在的空格字符在SSRS 2008中顯示
我只想在列中插入一個空白,以便它在SSRS 2008報告中不顯示任何內容。該列是PK的一部分,因此它不能爲NULL。當然,使用''
不起作用,因爲它在Oracle中被視爲NULL,並且' '
不起作用,因爲它的varchar2和trimmed爲NULL。
那麼是否存在一個我可以插入的字面值,它將在SSRS中顯示爲無,但也可以插入Oracle 11g中的不可爲空的varchar2列?
想了一會兒,我猜想像一個製表符可以完成這項工作。但我期待您的建議。
UPDATE
哎呦。猜猜修剪行爲是從哪裏來的?我自己的RTRIM!對於那個很抱歉。我們只是說我被甲骨文的缺乏經驗所誤導,而我對此的失望導致我決定錯誤發生在產品而不是我的查詢中。但是,嘿,這不完全是一個簡單的查詢。
INSERT INTO WeeklyInvoice (GUID, Mo, VendorName, CostCenter, WkNum, Amt)
SELECT
ExecID,
Mo,
VendorName,
CostCenter,
WkNum,
Amt
FROM (
WITH CostCenters AS (
SELECT REGEXP_SUBSTR(CostCenterList, '[^,]+', 1, LEVEL) CostCenter
FROM DUAL
CONNECT BY LEVEL <= Length(CostCenterList) - Length(Replace(CostCenterList, ',', '')) + 1
), Invoices AS (
SELECT
TRUNC(I.Invoice_Dte, 'MM') Mo,
(TRUNC(I.Invoice_Dte, 'W') - TRUNC(I.Invoice_Dte, 'MM'))/7 + 1 WkNum,
I.Vendor,
V.Vendor_VName,
RTrim(D.Dis_Acct_Unit) CostCenter,
D.To_Base_Amt
FROM
CostCenters CC
CROSS JOIN prod.IcCompany C
INNER JOIN prod.ApDistrib D
ON C.Company = D.Company
AND D.Dis_Acct_Unit = CC.CostCenter
INNER JOIN prod.ApInvoice I
ON D.Invoice = I.Invoice
AND D.Vendor = I.Vendor
AND D.Suffix = I.Suffix
AND D.Company = I.Company
INNER JOIN prod.ApVenMast V ON I.Vendor = V.Vendor
WHERE
D.Cancel_Seq = 0
AND I.Cancel_Seq = 0
AND I.Invoice_Dte >= ADD_MONTHS(FromDate, -2)
AND I.Invoice_Dte < ToDate
), Months AS (
SELECT ADD_MONTHS(FromDate, LEVEL - 1) Mo
FROM DUAL
CONNECT BY LEVEL <= MONTHS_BETWEEN(ToDate, ADD_MONTHS(FromDate, -2))
), Names AS (
SELECT DISTINCT
I.Mo,
I.Vendor,
I.Vendor_VName,
I.CostCenter
FROM Invoices I
UNION ALL
SELECT M.Mo, '0', 'No Paid Invoices', ' '
FROM Months M
WHERE
NOT EXISTS (
SELECT I.*
FROM Invoices I
WHERE I.Mo = M.Mo
)
), Weeks AS (
SELECT LEVEL WkNum FROM DUAL CONNECT BY LEVEL <= 5
)
SELECT
N.Mo,
N.Vendor_VName VendorName,
N.CostCenter,
W.WkNum,
Sum(I.To_Base_Amt) Amt
FROM
Names N
INNER JOIN Weeks W
ON W.WkNum < 5
OR EXTRACT (MONTH FROM (N.Mo + 28)) = EXTRACT (MONTH FROM N.Mo)
LEFT JOIN Invoices I
ON N.CostCenter = I.CostCenter
AND N.Vendor = I.Vendor
AND N.Mo = I.Mo
AND W.WkNum = I.WkNum
GROUP BY
N.Mo,
N.Vendor_VName,
N.CostCenter,
W.WkNum
) X;
由於該列是一個PK並且不能爲空,您爲什麼要插入一個空格呢?數據模型不正確,或者只是報告問題可以在報告中處理。 – 2011-01-11 20:37:23
由於報表使用矩陣(即它支持數據),因此當整個數據時間段爲空時,報表根本不顯示任何內容。這是不可取的。相反,我需要爲每週列設置一行,以便在所有4或5周內顯示該期間的「無支付的發票」。因此,我是UNION ALL在沒有發票的情況下選擇一個「種子行」來使用。在該種子行中,沒有賬戶單位。所以在這種情況下它是正確的空白,而不是空白。該表不適用於持久性存儲,但僅作爲報表的臨時表。 – ErikE 2011-01-12 01:35:39