我正在使用存儲過程。MySQl存儲過程傳遞帶參數名稱和值的參數
create procedure uspCommonMasterInsertUpdateSingleItem
(
p_id int,
p_name varchar(50),
p_head int,
p_desc varchar(500),
p_ct_nm varchar(50)
)
begin
declare p_returnvalue int;
declare p_ct_cd int ;
set p_ct_cd = (select ct_cd from com_typ where ct_nm = p_ct_nm);
if (p_id is null) then
insert into com_mst(
ct_cd,
cm_nm,
cm_hed,
cm_dsg
)
values
(
p_ct_cd,
p_name,
p_head,
p_desc
) ;
select p_returnvalue = LAST_INSERT_ID();
else
update com_mst set
ct_cd=p_ct_cd,
cm_nm=p_name,
cm_hed =p_head,
cm_dsg = p_dsg
where cm_cd = p_id ;
select p_returnvalue = p_id;
end if ;
end
,當我執行這個
call uspCommonMasterInsertUpdateSingleItem (p_name := 'kk',p_head := '1',p_desc := 'des',p_ct_nm := 'Department')
它顯示錯誤
ERROR 1064(42000):你在你的SQL語法錯誤;檢查與您的MySQL服務器版本相對應的手冊,以找到正確的語法,以便在':='k'
k',p_head:='1',p_desc:='des',p_ct_nm:='Department')'處使用線1
嘗試僅傳遞參數,而不是在執行時分配它們。 – Pravellika
ID帕拉姆不是過去,你打電話從p_name – StanislavL