在视图中使用 Oracle SDO_POINT 时丢失小数

发布于 2024-07-30 08:36:30 字数 615 浏览 3 评论 0原文

我们有一个包含坐标等内容的表。 我们过去将它们存储在两个数字字段(x 和 y)中,但现在我们已将其替换为 SDO_GEOMETRY 字段。 为了向后兼容,我们创建了一个视图(与以前的表同名),我们在其中执行以下操作:

创建视图 meas_pnt 或将其替换为 选择...,m.position.SDO_POINT.X x_坐标,m.position.SDO_POINT.Y y_坐标 来自 meas_pnt_tab m;

这适用于读取和写入,但是当将小数写入视图时,小数会丢失。 我不明白为什么。 有人可以帮忙吗? 下面说明了该问题:

update meas_pnt_tab m set m.position.SDO_POINT.x = 2.3 where meas_key=1; 从 meas_pnt_tab m 选择 m.position.SDO_POINT.X,其中 meas_key=1; -> x 为 2.3。 好的!

更新 meas_pnt 设置 x_coordinate = 2.3 其中 meas_key=1; 从 meas_pnt_tab m 选择 m.position.SDO_POINT.X,其中 meas_key=1; -> x 是 2。

We have a table containing coordinates, among other things. We used to store these in two number fields (x and y), but we've now replaced this with an SDO_GEOMETRY field. For backwards compatibility, we have created a view (with the same name as the table used to have), where we do:

create or replace view meas_pnt as
select ..., m.position.SDO_POINT.X x_coordinate, m.position.SDO_POINT.Y y_coordinate
from meas_pnt_tab m;

This works for both reading and writing, but when writing decimal numbers to the view, the decimals are lost. I can't figure out why. Can anybody help? The following illustrates the problem:

update meas_pnt_tab m set m.position.SDO_POINT.x = 2.3 where meas_key=1;
select m.position.SDO_POINT.X from meas_pnt_tab m where meas_key=1;
-> x is 2.3. Good!

update meas_pnt set x_coordinate = 2.3 where meas_key=1;
select m.position.SDO_POINT.X from meas_pnt_tab m where meas_key=1;
-> x is 2.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑饮青盏花 2024-08-06 08:36:30

我无法重现你的错误。 这就是我得到的:

SQL> CREATE TABLE meas_pnt_tab (position sdo_point_type, meas_key NUMBER);

Table created
SQL> INSERT INTO meas_pnt_tab (position, meas_key) 
  2  VALUES (sdo_point_type(2.3,0,0), 1);

1 row inserted
SQL> SELECT m.position.X FROM meas_pnt_tab m WHERE meas_key=1;

POSITION.X
----------
       2,3
SQL> CREATE OR REPLACE VIEW meas_pnt AS
  2  SELECT m.position.X x_coordinate,
  3         m.position.Y y_coordinate,
  4         m.meas_key
  5    FROM meas_pnt_tab m;

View created
SQL> UPDATE meas_pnt SET x_coordinate = 2.4 WHERE meas_key=1;

1 row updated
SQL> SELECT m.position.X FROM meas_pnt_tab m WHERE meas_key=1;

POSITION.X
----------
       2,4

你能发布你的 CREATE 语句吗?

I can not reproduce your error. This is what I get:

SQL> CREATE TABLE meas_pnt_tab (position sdo_point_type, meas_key NUMBER);

Table created
SQL> INSERT INTO meas_pnt_tab (position, meas_key) 
  2  VALUES (sdo_point_type(2.3,0,0), 1);

1 row inserted
SQL> SELECT m.position.X FROM meas_pnt_tab m WHERE meas_key=1;

POSITION.X
----------
       2,3
SQL> CREATE OR REPLACE VIEW meas_pnt AS
  2  SELECT m.position.X x_coordinate,
  3         m.position.Y y_coordinate,
  4         m.meas_key
  5    FROM meas_pnt_tab m;

View created
SQL> UPDATE meas_pnt SET x_coordinate = 2.4 WHERE meas_key=1;

1 row updated
SQL> SELECT m.position.X FROM meas_pnt_tab m WHERE meas_key=1;

POSITION.X
----------
       2,4

Can you post your CREATE statements ?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文