y*****g 发帖数: 677 | 1 You may need wrap your statements in a block of function/procedure like this:
delimiter $$
drop procedure if exists a;
create procedure a ()
begin
set @pretime = null;
if (@pretime is null) then
set @pretime := time(0);
end if;
select @pretime;
end $$
delimiter ; |
|
y*****g 发帖数: 677 | 2 You may need wrap your statements in a block of function/procedure like this:
delimiter $$
drop procedure if exists a;
create procedure a ()
begin
set @pretime = null;
if (@pretime is null) then
set @pretime := time(0);
end if;
select @pretime;
end $$
delimiter ; |
|
f**********t 发帖数: 1001 | 3 int needRooms(vector> &meetings) {
struct Cmp {
bool operator()(const tuple &x, const tuple &y) {
return get<0>(x) < get<0>(y);
}
};
vector> vt;
for (auto meeting : meetings) {
vt.push_back(make_tuple(get<0>(meeting), true));
vt.push_back(make_tuple(get<1>(meeting), false));
}
sort(vt.begin(), vt.end(), Cmp());
int res = 0;
int pretime = -1;
int start = 0;
int end = 0;
int rooms = 0;
for (auto t ... 阅读全帖 |
|
d********t 发帖数: 9628 | 4 if (select @pretime is null) then
set @pretime := time(0);
end if;
总说我syntax error. |
|
d********t 发帖数: 9628 | 5 if (select @pretime is null) then
set @pretime := time(0);
end if;
总说我syntax error. |
|
d***e 发帖数: 793 | 6 我试了yunmeng的reply,好像不work。
我觉得问题好像在于user defined variable can't be used as a value and
assigned value in the same statement。if statement is one statement after
all
这样就没问题了:
SELECT IFNULL(@PRETIME, TIME(0)); |
|
d***e 发帖数: 793 | 7 我试了yunmeng的reply,好像不work。
我觉得问题好像在于user defined variable can't be used as a value and
assigned value in the same statement。if statement is one statement after
all
这样就没问题了:
SELECT IFNULL(@PRETIME, TIME(0)); |
|