我正在尝试创建postgres脚本但是我遇到了从表行的max()函数insead返回值的麻烦。
这是剧本的重要部分:
unsigned int key = time(nullptr);
for (; key > 0; --key)
{
srand(key);
if (rand() == target1 and rand() == target2) {
std::cout << "key is 0x" << std::hex << key << std::endl;
break;
}
}
if (key == 0) {
std::cout << "key not found" << std::endl;
}
我收到此错误:无效的类型名称“max(bag_index)INTO index FROM booking_bags 出价“ 第6行:SELECT max(bag_index)INTO index FROM bo ...
任何人都知道如何将值从max函数转换为声明的变量?
答案 0 :(得分:0)
DECLARE @index SMALLINT;
SELECT @index = max(bag_index) FROM booking_bags
WHERE bid = NEW.bid AND
pid = NEW.pid AND
fid = NEW.fid AND
ordered_bag_id = NEW.ordered_bad_id;