0
Oracle /蟾蜍的新手。Oracle聲明變量並在另一個選擇查詢中使用它
我正在定義一個變量並從select中插入它的值。設置其值後,我將其用於另一個選擇語句。但是,這給了我錯誤和INTO子句預計在SELECT
declare maxLineNo number := 0;
BEGIN
select Max(b.Line_No) into maxLineNo FROM Brokerage b WHERE b.External_App_Id = 3720 AND b.Account_Id = '16970' ;
SELECT b.External_App_Id -- this select giving erro
, maxLineNo + 1
, b.Currency
, ''
, CAST(SUM(b.Brokerage_Amt) as VARCHAR2(17))
, ''
, ''
, 1003 -- 1003 for Report summary
, ''
FROM Brokerage b
WHERE b.External_App_Id = 3720
GROUP BY External_App_Id, B.CURRENCY
ORDER BY 2;
DBMS_OUTPUT.PUT_LINE(maxLineNo); -- this is giving value
end;
,'SELECT'僅適用於'INTO'條款 –
所以你有什麼建議?如果關閉該塊,var MaxLineNo將無法在外部使用。 – PawanS
此外,最好爲空值寫'NULL'而不是''。 –