gpt4 book ai didi

mysql - SQL存储过程未知错误

转载 作者:行者123 更新时间:2023-11-29 07:58:18 25 4
gpt4 key购买 nike

我正在编写一个将在 Access 中调用的 SQL 存储过程。我的 sp 将传递四个数据字段(BatchID、InstrumentName、FileName、QueueId)。然后它将向表(tblinstrumentInterfaceLog)中插入一条记录。这是迄今为止我的代码:

CREATE PROCEDURE upInsertToInstrumentInterfaceLog @BatchID int, @InstrumentName nvarchar(60), @FileName nvarchar(60), @QueueID int 
INSERT INTO tblInstrumentinterfaceLog (batchId,Instrumentname,"Filename",QueueID,DateOfBatch,folder)
VALUES (@batchid,@InstrumentName,@FileName,@QueueID,@getdate(),'New')
GO

我相信我的格式正确,但出现两个错误:

Msg 156, Level 15, State 1, Procedure upInsertToInstrumentInterfaceLog, Line 2
Incorrect syntax near the keyword 'INSERT'.

Msg 137, Level 15, State 2, Procedure upInsertToInstrumentInterfaceLog, Line 3
Must declare the scalar variable "@QueueID".

为了确保可能不存在数据类型问题,我查看了 tblInstrumentInterfaceLog 的架构,这似乎与我初始化每个接口(interface)的方式相匹配。

enter image description here

有人可以告诉我他们是否发现此存储过程存在问题

最佳答案

在参数声明之后需要一个 AS,并且 @getdate() 命令只是 getdate()

CREATE PROCEDURE upInsertToInstrumentInterfaceLog 
@BatchID int, @InstrumentName nvarchar(60), @FileName nvarchar(60), @QueueID int

AS
BEGIN

INSERT INTO tblInstrumentinterfaceLog (batchId,Instrumentname,"Filename",QueueID,DateOfBatch,folder)
VALUES (@batchid,@InstrumentName,@FileName,@QueueID,
getdate(),'New')

END

GO

关于mysql - SQL存储过程未知错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24535743/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com