![](/img/trans.png)
[英]Why I obtain this error when I create a table on MariaDB? “Could not getColumn for MyMariaDB: Unknown system variable 'OPTION'”
[英]Why I obtain this error when I try to create this funcion (that use point data type) on a MariaDB database?
我不太喜歡數據庫,在實現本教程時有以下疑問: https : //mariadb.org/jquery-and-gis-distance-in-mariadb/
所以基本上我的疑問是涉及到創建一個函數來計算MariaDB的數據庫上的兩個點之間的距離,這樣SQL statment:
CREATE FUNCTION earth_circle_distance(point1 point, point2 point) RETURNS double
DETERMINISTIC
begin
declare lon1, lon2 double;
declare lat1, lat2 double;
declare td double;
declare d_lat double;
declare d_lon double;
declare a, c, R double;
set lon1 = X(GeomFromText(AsText(point1)));
set lon2 = X(GeomFromText(AsText(point2)));
set lat1 = Y(GeomFromText(AsText(point1)));
set lat2 = Y(GeomFromText(AsText(point2)));
set d_lat = radians(lat2 - lat1);
set d_lon = radians(lon2 - lon1);
set lat1 = radians(lat1);
set lat2 = radians(lat2);
set R = 6372.8; -- in kilometers
set a = sin(d_lat / 2.0) * sin(d_lat / 2.0) + sin(d_lon / 2.0) * sin(d_lon / 2.0) * cos(lat1) * cos(lat2);
set c = 2 * asin(sqrt(a));
return R * c;
end
我的問題是,執行前一個語句會得到以下錯誤消息:
Error
----------------------------------------------------
Static analysis:
2 errors were found during analysis.
1. Unrecognized data type. (near "point" at position 45)
2. Unrecognized data type. (near "point" at position 59)
SQL query:
CREATE FUNCTION earth_circle_distance(point1 point, point2 point) RETURNS double DETERMINISTIC begin declare lon1, lon2 double
MySQL said:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 4
用2個紅色標記標記的PhpMyAdmin符號在上一條語句的第一行上顯示點數據類型:
CREATE FUNCTION earth_circle_distance(point1 point, point2 point) RETURNS double
但我不認為它可能是真正的問題(我想,也許是一些phpMyAdmin的不知道),因為它標志着紅也是這個cration查詢:
CREATE TABLE gis_point (g POINT);
但它工作正常,沒有錯誤,並正確創建了表。
那么,錯了嗎? 可以依靠PhpMyAdmin還是我缺少什么? 此功能應存儲在哪里?
更改定界符。 否則,函數定義在第一個處結束;
這將使其不完整。
delimiter ||
CREATE FUNCTION earth_circle_distance(point1 point, point2 point) RETURNS double
DETERMINISTIC
begin
declare lon1, lon2 double;
declare lat1, lat2 double;
declare td double;
declare d_lat double;
declare d_lon double;
declare a, c, R double;
set lon1 = X(GeomFromText(AsText(point1)));
set lon2 = X(GeomFromText(AsText(point2)));
set lat1 = Y(GeomFromText(AsText(point1)));
set lat2 = Y(GeomFromText(AsText(point2)));
set d_lat = radians(lat2 - lat1);
set d_lon = radians(lon2 - lon1);
set lat1 = radians(lat1);
set lat2 = radians(lat2);
set R = 6372.8; -- in kilometers
set a = sin(d_lat / 2.0) * sin(d_lat / 2.0) + sin(d_lon / 2.0) * sin(d_lon / 2.0) * cos(lat1) * cos(lat2);
set c = 2 * asin(sqrt(a));
return R * c;
end
||
delimiter ;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.