2012-05-21 64 views
0

这是关于一个简单的预订/预订表:关键是anId用于timeOfBooking和dateOfBooking。我的JDBC插入/更新命令有什么问题

但是当我尝试这样做:插入如果 - 不存在,更新,如果同时存在,有关链接到的时间与此代码标识:

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. 

任何想法有什么不对?

回答

2

你应该把@变量名

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

类型也必须提供,我认为? –

+0

正确Rory!我快速复制并粘贴:) –

+1

尝试'varchar(18)',方括号是错的 –