gpt4 book ai didi

mysql - 使用 MySQL 几何函数时出现 SQL 错误

转载 作者:行者123 更新时间:2023-11-29 00:34:58 24 4
gpt4 key购买 nike

ALTER PROCEDURE dbo.StoredProcedure1    
AS
DECLARE @Seedid int, @data1 float, @data2 float, @g geometry

DECLARE member_cursor CURSOR FOR
SELECT id from test1 ;

OPEN member_cursor;

FETCH NEXT FROM member_cursor
INTO @Seedid ;
WHILE @@FETCH_STATUS = 0
BEGIN
select @data1 =data1 from test where id=@Seedid
select @data2 =data2 from test where id=@Seedid
update test1
set data4 = geometry::STGeomFromText('POINT (@data1 @data2)', 0)
where id=@Seedid;
-- This is executed as long as the previous fetch succeeds.
FETCH NEXT FROM member_cursor
INTO @Seedid ;
END
RETURN
CLOSE member_cursor;
DEALLOCATE member_cursor;

我收到以下错误:

The statement has been terminated.
A .NET Framework error occurred during execution of user-defined routine or aggregate "geometry":
System.FormatException: 24141: A number is expected at position 13 of the input. The input has @data1.

最佳答案

经过一番努力,我终于找到了解决这个问题的方法。如果其他人再次遇到此类问题,请发布解决方案。在 Geometry 中,当我传递 @data1@data2 时,它的那些变量只是 @data1 而不是它的 float 值。所以,我们可以做的是:

select @data1 =data1 from test1 where id=@Seedid  
select @data2 =data2 from test1 where id=@Seedid
Set @POINTSTR = 'POINT(' + CAST(@data1 AS varchar(32)) + ' ' + CAST(@data2 AS varchar(32)) + ')';
update test1 set data4 = geometry::STGeomFromText(@POINTSTR, 4326) where id=@Seedid;

关于mysql - 使用 MySQL 几何函数时出现 SQL 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14783401/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com