我的输出有问题Portfolio_description为空,但我认为这并不重要我不知道语法是什么并传递两个输入参数P_Portfolio_number和P_Stock_Code
begin
select Investor_Number,portfolio_description
into V_Investor_Number,V_portfolio_DES
from portfolio
where P_Portfolio_number=Portfolio_Number;
select First_Name,Last_Name
into V_firstname,V_Lastname
from investor
where Investor_Number=V_Investor_Number;
select Stock_name
into V_stock_name
from stock
where stock_code = P_Stock_Code;
select count(stock_code)
into V_count
from transaction
where P_Stock_Code = stock_code and
P_Portfolio_number=Portfolio_Number;
if V_count = 0 then
V_output := V_output || V_firstname||' '|| V_Lastname ||'does not exist ' || V_stock_name;
ELSIF
that one work with the output
某种程度上下面的一个不起作用
begin
select Investor_Number,portfolio_description
into V_Investor_Number,V_portfolio_DES
from portfolio
where P_Portfolio_number=Portfolio_Number;
select First_Name,Last_Name
into V_firstname,V_Lastname
from investor
where Investor_Number=V_Investor_Number;
select Stock_name
into V_stock_name
from stock
where stock_code = P_Stock_Code;
select count(stock_code)
into V_count
from transaction
where P_Stock_Code = stock_code and
P_Portfolio_number=Portfolio_Number;
if V_count = 0 then
V_output := V_output || V_firstname||' '|| V_Lastname ||'does not exist ' || V_stock_name||'in the '||V_portfolio_DES;
ELSIF
当我在末尾添加V_portfolio_DES时会引发其他异常
将引发其他例外
我假设您使用的是WHEN OTHERS
。通常这是一个大错误。如果处理不当,请勿将其升高。您宁愿让Oracle显示正在发生的事情。使用您的“异常”,您什么也没做,只能成功地隐藏了错误原因。
无论如何:-当您将V_PORTFOLIO_DES
添加到V_OUTPUT
变量时,我的幸运猜测是V_OUTPUT
被声明为VARCHAR2
,但是
太小。例如:如果是
declare v_output varchar2(20);
并且第一段代码可以正常工作,因为变量的长度小于20
个字符,但是-连接v_portfolio_des
后,长度超过20
并得到了错误。因此,请放大变量的大小。