Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql JDBC insert/update命令中有什么错误_Sql_Sql Server_Jdbc_Jtds - Fatal编程技术网

Sql JDBC insert/update命令中有什么错误

Sql JDBC insert/update命令中有什么错误,sql,sql-server,jdbc,jtds,Sql,Sql Server,Jdbc,Jtds,这是关于一个简单的预订/预订表:键是预订时间和预订日期的anId 但当我尝试执行以下操作时:如果不存在,则插入,如果存在,则更新,关于使用以下代码链接到时间的标识符: declare anId varchar[18]; declare aDate; declare aTimeStamp; set @anId =?; set @aDate=?; set @aTimeStamp=?; if (exists (select * from Booking as t where t.AnId = @an

这是关于一个简单的预订/预订表:键是预订时间和预订日期的anId

但当我尝试执行以下操作时:如果不存在,则插入,如果存在,则更新,关于使用以下代码链接到时间的标识符:

declare anId varchar[18];
declare aDate;
declare aTimeStamp;
set @anId =?;
set @aDate=?;
set @aTimeStamp=?;
if (exists (select * from Booking as t  where t.AnId = @anId ))
begin update Booking set Date = @aDate and Time = @aTimeStamp  where AnId= @anId end
else begin insert into Booking (AnId, Date, Time) values(@anId , @aDate, @aTimeStamp) end ; 
最后,jdbc层返回以下错误:

'varchar' is not a recognized CURSOR option.

你知道怎么回事吗?

你应该把@作为变量名

declare @anId varchar(18);
declare @aDate datetime;
declare @aTimeStamp datetime;

我想还必须提供型号?正确的Rory!我快速复制并粘贴:)