我正在尝试调用返回int值的Sql Server Store过程,不作为输出参数。我使用以下语句尝试了Oracle Sql Developer工具:
EXECUTE my_procedure 'TTT', '<a>abcd</a>';
EXEC my_procedure 'TTT', '<a>abcd</a>';
它出现以下错误:
Error report:
Incorrect syntax near the keyword 'BEGIN'.
我试过 How to call a mysql stored procedure, with arguments, from command line?
它出现以下错误:
Error report:
Unknown Command
以下是我的商店程序:
CREATE PROCEDURE my_procedure @advisor de , @adv_xml xml
AS
begin
declare
@psrg_idi idi,
@adv_cd cd,
@CurrDate cdt
set @adv_cd = (select adv_cd from dbo.ADVICE_LK where upper(rtrim(adv_de)) = upper(@advisor))
set @psrg_idi = 0
set @CurrDate = getdate()
BEGIN TRY
exec my_proc_2 @CurrDate,@psrg_idi output
insert into ADVICE (psrg_idi,adv_cd,psra_original_xml)
values
(@psrg_idi,@adv_cd,@adv_xml)
select
@psrg_idi as psrg_idi
END TRY
BEGIN CATCH
DECLARE @ErrorMessage NVARCHAR(4000);
DECLARE @ErrorSeverity INT;
DECLARE @ErrorState INT;
SELECT
@ErrorMessage = ERROR_MESSAGE(),
@ErrorSeverity = ERROR_SEVERITY(),
@ErrorState = ERROR_STATE();
RAISERROR (@ErrorMessage, -- Message text.
@ErrorSeverity, -- Severity.
@ErrorState -- State.
);
return -1
END CATCH
end
请用有效的陈述回答,执行这样的程序......
答案 0 :(得分:0)
开始时语法不正确,当您将参数传递给存储过程时,此错误被解释。当存储过程找不到这些参数的占位符时,它将引发此类错误。 所以将占位符添加到您传递给您的参数是存储过程。
另外,因为它是具有自己的语法,数据类型的sql server存储过程,所以它希望遵循这些语法。在声明部分中,您已经定义了数据类型为idi的变量。 没有这样的数据类型叫idi.so继承人修改后的code.i只放了参数。对于声明部分你必须把sql server识别的数据类型。将你的存储过程语法改为sql server识别的。 我已经注释掉exec my_proc_2 @ CurrDate,@ psrg_idi output.please检查你如何调用具有输出参数的sql server存储过程。
CREATE PROCEDURE my_procedure @advisor de , @adv_xml xml
@placeholder1 varchar(20),
@placeholder2 xml
AS
begin
declare
@psrg_idi as varchar(20),
@adv_cd as varchar(20),
@CurrDate as date
set @adv_cd = (select adv_cd from dbo.ADVICE_LK where upper(rtrim(adv_de)) = upper(@advisor))
set @psrg_idi = 0
set @CurrDate = getdate()
BEGIN TRY
--exec my_proc_2 @CurrDate,@psrg_idi output
insert into ADVICE (psrg_idi,adv_cd,psra_original_xml)
values
(@psrg_idi,@adv_cd,@adv_xml)
select
@psrg_idi as psrg_idi
END TRY
BEGIN CATCH
DECLARE @ErrorMessage NVARCHAR(4000);
DECLARE @ErrorSeverity INT;
DECLARE @ErrorState INT;
SELECT
@ErrorMessage = ERROR_MESSAGE(),
@ErrorSeverity = ERROR_SEVERITY(),
@ErrorState = ERROR_STATE();
RAISERROR (@ErrorMessage, -- Message text.
@ErrorSeverity, -- Severity.
@ErrorState -- State.
);
return -1
END CATCH
end