我在执行中看到这个错误我在SQL Server中编写它并希望将其转换为mysql
1您的SQL语法有错误;检查手册 对应于您的MySQL服务器版本,以便使用正确的语法 'db_cursor FETCH NEXT FROM db_cursor INTO CityName,CountryName附近 WHILE @@ FETC'在第11行C:\ Users \ Dt4IT \ Desktop \ SQL.sql 2 1
delimiter #
Create Procedure ss()
begin
DECLARE CityName VARCHAR(100); -- filename for backup
DECLARE CountryName VARCHAR(100);
DECLARE db_cursor CURSOR FOR
SELECT CityName,(Select Country from d_country where CountryID = d_country.CountryID)
FROM d_cities;
OPEN db_cursor
FETCH NEXT FROM db_cursor INTO CityName,CountryName
WHILE @@FETCH_STATUS = 0
BEGIN
Insert into ip_relations
Select city_name,country_name,ip_from,ip_to from ip2location_db11 where
city_name = CityName and country_name = CountryName
FETCH NEXT FROM db_cursor INTO CityName,CountryName
END
CLOSE db_cursor
DEALLOCATE db_cursor
end#
delimiter ;
答案 0 :(得分:0)
您应该使用@
作为这些局部变量的前缀:
DECLARE @CityName VARCHAR(100), @CountryName VARCHAR(100);
...
FETCH NEXT FROM db_cursor INTO @CityName,@CountryName
...