Question

This is about a simple booking/reservation table: key is anId for a timeOfBooking and dateOfBooking.

But when I try to do: insert if-not-exist, update if-exist, about a identifier linked to a time with this code:

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 ; 

I end up with the jdbc layer returning this error :

'varchar' is not a recognized CURSOR option.

Any idea what's wrong?

Was it helpful?

Solution

You should put @ for variable names

declare @anId varchar(18);
declare @aDate datetime;
declare @aTimeStamp datetime;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top