И
You cannot use IF in an SQL statement. You can only use it in a stored procedure or a function.
а в mysql можно как-то сделать условие на коммит?
Size: a a a
И
И
А
А
V
DELIMITER //не работает
CREATE PROCEDURE `proc_IF` (IN param1 INT)
BEGIN
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET @max_dimensinon = 0;
SET @max = 'max';
SELECT @max_dimensinon := MAX(dimension) FROM Cycles;
INSERT INTO Cycles(ID_C, dimension, name) VALUES (6, @max_dimensinon, @max);
IF @max_dimensinon > 3000 then
commit;
else
rollback;
END IF;
END //
IZ
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET @max_dimensinon = 1;
SET @max = 'max';
SELECT @max_dimensinon := MAX(dimension) FROM Cycles;
INSERT INTO Cycles(ID_C, dimension, name) VALUES (6, @max_dimensinon, @max);
IF @max_dimensinon > 3000
rollback
ELSE
commit
А
DELIMITER //не работает
CREATE PROCEDURE `proc_IF` (IN param1 INT)
BEGIN
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET @max_dimensinon = 0;
SET @max = 'max';
SELECT @max_dimensinon := MAX(dimension) FROM Cycles;
INSERT INTO Cycles(ID_C, dimension, name) VALUES (6, @max_dimensinon, @max);
IF @max_dimensinon > 3000 then
commit;
else
rollback;
END IF;
END //
IZ
DELIMITER //не работает
CREATE PROCEDURE `proc_IF` (IN param1 INT)
BEGIN
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET @max_dimensinon = 0;
SET @max = 'max';
SELECT @max_dimensinon := MAX(dimension) FROM Cycles;
INSERT INTO Cycles(ID_C, dimension, name) VALUES (6, @max_dimensinon, @max);
IF @max_dimensinon > 3000 then
commit;
else
rollback;
END IF;
END //
А
V
V
g
g
g
O
KT
WITH CTE
словишь ошибкуKT
> Babelfish for PostgreSQL is an Apache-2.0 open source project that adds a Microsoft SQL Server-compatible end-point to PostgreSQL to enable your PostgreSQL database to understand the SQL Server wire protocol and commonly used SQL Server commands. With Babelfish, applications that were originally built for SQL Server can work directly with PostgreSQL, with little to no code changes, and without changing database drivers.
YS
> Babelfish for PostgreSQL is an Apache-2.0 open source project that adds a Microsoft SQL Server-compatible end-point to PostgreSQL to enable your PostgreSQL database to understand the SQL Server wire protocol and commonly used SQL Server commands. With Babelfish, applications that were originally built for SQL Server can work directly with PostgreSQL, with little to no code changes, and without changing database drivers.
O
ДС
> Babelfish for PostgreSQL is an Apache-2.0 open source project that adds a Microsoft SQL Server-compatible end-point to PostgreSQL to enable your PostgreSQL database to understand the SQL Server wire protocol and commonly used SQL Server commands. With Babelfish, applications that were originally built for SQL Server can work directly with PostgreSQL, with little to no code changes, and without changing database drivers.