Oracle sql命令在执行函数后未正确结束
例如,我创建了一个表名为“aaa”的表,其中包含四列act_num、clear_balance、available_balance、total_balance,并插入了一些值 功能 deb_amount从银行账户取款。它接受一个帐户 数字和金额作为参数。它使用帐号来 从数据库检索帐户余额,然后计算新余额。如果这 新的平衡小于零,然后函数跳转到错误例程;否则,, 它会更新银行账户Oracle sql命令在执行函数后未正确结束,oracle,plsql,oracle11g,Oracle,Plsql,Oracle11g,例如,我创建了一个表名为“aaa”的表,其中包含四列act_num、clear_balance、available_balance、total_balance,并插入了一些值 功能 deb_amount从银行账户取款。它接受一个帐户 数字和金额作为参数。它使用帐号来 从数据库检索帐户余额,然后计算新余额。如果这 新的平衡小于零,然后函数跳转到错误例程;否则,, 它会更新银行账户 create or replace function deb_amount(p_act_num VARCHAR2, p
create or replace function deb_amount(p_act_num VARCHAR2, p_amount number )
return number as
declare
v_old_amount number;
v_new_amount number;
e_over_drawn exception;
begin
select clear_balance into v_old_amount from aaa where act_num=p_act_num;
v_new_amount:=v_old_amount-p_amount;
if v_old_amount<p_amount then
raise e_over_drawn;
else
update aaa set clear_balance=v_new_amount,available_balance=v_new_amount,total_balance=v_new_amount where act_num=p_act_num;
end if;
commit;
return clear_balance;
exception
when e_over_drawn then
rollback;
end;
创建或替换函数deb_amount(p_act_num VARCHAR2,p_amount number)
返回号码为
声明
v_旧金额编号;
v_新金额编号;
e_超过_的例外情况;
开始
从aaa中选择“将余额清除到旧金额中”,其中act_num=p_act_num;
v_新金额:=v_旧金额-p_金额;
如果v_old_amount看起来您可能正在作为scipt运行多个命令,但尚未正确结束该函数。函数创建后的/
必须单独在一行上,并且在行的开头:
create or replace function deb_amount(p_act_num VARCHAR2,
p_amount number)
return number as
declare
v_old_amount number;
v_new_amount number;
e_over_drawn exception;
begin
select clear_balance into v_old_amount
from aaa where act_num=p_act_num;
v_new_amount:=v_old_amount-p_amount;
if v_old_amount<p_amount then
raise e_over_drawn;
else
update aaa set clear_balance=v_new_amount,
available_balance=v_new_amount,
total_balance=v_new_amount
where act_num=p_act_num;
end if;
commit;
return clear_balance;
exception
when e_over_drawn then
rollback;
end;
/
show errors
select deb_account('1', 1) from dual;
创建或替换函数deb\u amount(p\u act\u num VARCHAR2,
p_金额(数字)
返回号码为
声明
v_旧金额编号;
v_新金额编号;
e_超过_的例外情况;
开始
选择“将余额清除为旧金额”
来自aaa,其中act_num=p_act_num;
v_新金额:=v_旧金额-p_金额;
如果v_old_amount看起来您可能正在作为scipt运行多个命令,但尚未正确结束该函数。函数创建后的/
必须单独在一行上,并且在行的开头:
create or replace function deb_amount(p_act_num VARCHAR2,
p_amount number)
return number as
declare
v_old_amount number;
v_new_amount number;
e_over_drawn exception;
begin
select clear_balance into v_old_amount
from aaa where act_num=p_act_num;
v_new_amount:=v_old_amount-p_amount;
if v_old_amount<p_amount then
raise e_over_drawn;
else
update aaa set clear_balance=v_new_amount,
available_balance=v_new_amount,
total_balance=v_new_amount
where act_num=p_act_num;
end if;
commit;
return clear_balance;
exception
when e_over_drawn then
rollback;
end;
/
show errors
select deb_account('1', 1) from dual;
创建或替换函数deb\u amount(p\u act\u num VARCHAR2,
p_金额(数字)
返回号码为
声明
v_旧金额编号;
v_新金额编号;
e_超过_的例外情况;
开始
选择“将余额清除为旧金额”
来自aaa,其中act_num=p_act_num;
v_新金额:=v_旧金额-p_金额;
如果v_old_amount看起来您可能正在作为scipt运行多个命令,但尚未正确结束该函数。函数创建后的/
必须单独在一行上,并且在行的开头:
create or replace function deb_amount(p_act_num VARCHAR2,
p_amount number)
return number as
declare
v_old_amount number;
v_new_amount number;
e_over_drawn exception;
begin
select clear_balance into v_old_amount
from aaa where act_num=p_act_num;
v_new_amount:=v_old_amount-p_amount;
if v_old_amount<p_amount then
raise e_over_drawn;
else
update aaa set clear_balance=v_new_amount,
available_balance=v_new_amount,
total_balance=v_new_amount
where act_num=p_act_num;
end if;
commit;
return clear_balance;
exception
when e_over_drawn then
rollback;
end;
/
show errors
select deb_account('1', 1) from dual;
创建或替换函数deb\u amount(p\u act\u num VARCHAR2,
p_金额(数字)
返回号码为
声明
v_旧金额编号;
v_新金额编号;
e_超过_的例外情况;
开始
选择“将余额清除为旧金额”
来自aaa,其中act_num=p_act_num;
v_新金额:=v_旧金额-p_金额;
如果v_old_amount看起来您可能正在作为scipt运行多个命令,但尚未正确结束该函数。函数创建后的/
必须单独在一行上,并且在行的开头:
create or replace function deb_amount(p_act_num VARCHAR2,
p_amount number)
return number as
declare
v_old_amount number;
v_new_amount number;
e_over_drawn exception;
begin
select clear_balance into v_old_amount
from aaa where act_num=p_act_num;
v_new_amount:=v_old_amount-p_amount;
if v_old_amount<p_amount then
raise e_over_drawn;
else
update aaa set clear_balance=v_new_amount,
available_balance=v_new_amount,
total_balance=v_new_amount
where act_num=p_act_num;
end if;
commit;
return clear_balance;
exception
when e_over_drawn then
rollback;
end;
/
show errors
select deb_account('1', 1) from dual;
创建或替换函数deb\u amount(p\u act\u num VARCHAR2,
p_金额(数字)
返回号码为
声明
v_旧金额编号;
v_新金额编号;
e_超过_的例外情况;
开始
选择“将余额清除为旧金额”
来自aaa,其中act_num=p_act_num;
v_新金额:=v_旧金额-p_金额;
如果v_old_amount您需要使用dual调用函数。例:
select deb_amount(1,100) from dual;
或者在plsql块中使用变量
declare
l_return number;
begin
l_return:=deb_amount(1,100);
end;
您需要使用dual调用函数。例:
select deb_amount(1,100) from dual;
或者在plsql块中使用变量
declare
l_return number;
begin
l_return:=deb_amount(1,100);
end;
您需要使用dual调用函数。例:
select deb_amount(1,100) from dual;
或者在plsql块中使用变量
declare
l_return number;
begin
l_return:=deb_amount(1,100);
end;
您需要使用dual调用函数。例:
select deb_amount(1,100) from dual;
或者在plsql块中使用变量
declare
l_return number;
begin
l_return:=deb_amount(1,100);
end;
您正在尝试从同一脚本调用函数吗?显示错误时
会说什么?这可能是一个格式问题,但create submitting/
字符应该是其行中的第一个(也是唯一一个)字符;如果你真的如问题所示缩进了,就把缩进去掉。@Alex Poole。是的,我想调用这个函数“select*from deb_amount(1100)”。如果我运行此命令,它会显示错误。“sql命令没有正确结束。”您在问题中说过这一点;不过你还没有回答我的问题。我不知道为什么您现在删除了/
,将其放在行的开头是否有帮助,以及显示错误(或查询用户错误)说明该函数有什么问题?是否尝试从同一脚本调用该函数?显示错误时
会说什么?这可能是一个格式问题,但create submitting/
字符应该是其行中的第一个(也是唯一一个)字符;如果你真的如问题所示缩进了,就把缩进去掉。@Alex Poole。是的,我想调用这个函数“select*from deb_amount(1100)”。如果我运行此命令,它会显示错误。“sql命令没有正确结束。”您在问题中说过这一点;不过你还没有回答我的问题。我不知道为什么您现在删除了/
,将其放在行的开头是否有帮助,以及显示错误(或查询用户错误)说明该函数有什么问题?是否尝试从同一脚本调用该函数?显示错误时
会说什么?这可能是一个格式问题,但create submitting/
字符应该是其行中的第一个(也是唯一一个)字符;如果你真的如问题所示缩进了,就把缩进去掉。@Alex Poole。是的,我想调用这个函数“select*from deb_amount(1100)”。如果我运行此命令,它会显示错误。“sql命令没有正确结束。”您在问题中说过这一点;不过你还没有回答我的问题。我不知道为什么您现在删除了/
,将其放在行的开头是否有帮助,以及显示错误(或查询用户错误)说明该函数有什么问题?是否尝试从同一脚本调用该函数?显示错误时
会说什么?这可能是一个格式问题,但create submitting/
字符应该是其行中的第一个(也是唯一一个)字符;如果您确实如问题所示将其缩进,请删除